Problem
When trying to update OS base image on Managed Instance Groups (MIG) with an automated process, you get the following error message:
ERROR: (gcloud.compute.instance-groups.managed.rolling-action.replace) Could not fetch resource: Invalid value for field 'resource.updatePolicy.type': 'PROACTIVE'. UpdatePolicy with type set to PROACTIVE is not allowed when Stateful is used (instanceGroupManager has statefulPolicy or perInstanceConfigs). Set updatePolicy.type to OPPORTUNISTIC to apply this update.
Environment
- Google Compute Engine Virtual Machine, Instance Group Manager (IGM)
- Google Cloud API
Solution
- For implementing a rolling replace, you have the option to do it manually (with updatePolicy.type set to OPPORTUNISTIC)
- You can set a new instance template and use the applyUpdatetoInstances API method or the update-instances gcloud command
- To control updates and limit disruption, specific instances can also be updated if and when needed
- If you use custom instance names, and if you do not configure stateful disks or metadata, you can use proactive updates, but they must set the replacement method to RECREATE in order to preserve instance names.
Cause
Automated replacement of IGM.updatePolicy.type is not supported by (Instance Group Manager) IGM. You cannot currently use proactive rolling updates if they configure stateful disks or stateful metadata. PROACTIVE update mode is not yet supported by Stateful MIGs. Rolling actions trigger proactive rollout and therefore are not yet supported.