Skip to content

Commit b0eb686

Browse files
committed
destroy/gcp: set value for DiscardLocalSsd
Instance types for which `OnHostMaintenance` is set to `Terminate`, GCP requires the `DiscardLocalSsd` value to be defined, otherwise we get the following error when destroying a cluster: ``` WARNING failed to stop instance jiwei-0530b-q9t8w-worker-c-ck6s8 in zone us-central1-c: googleapi: Error 400: VM has a Local SSD attached but an undefined value for `discard-local-ssd`. If using gcloud, please add `--discard-local-ssd=false` or `--discard-local-ssd=true` to your command., badRequest ``` We are setting the value to `true` because we are about to destroy the cluster, which means destroying the instances and all cluster-owned resources.
1 parent 29fd804 commit b0eb686

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/destroy/gcp/instance.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ func (o *ClusterUninstaller) stopInstance(ctx context.Context, item cloudResourc
130130
o.Logger.Debugf("Stopping compute instance %s in zone %s", item.name, item.zone)
131131
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
132132
defer cancel()
133-
op, err := o.computeSvc.Instances.Stop(o.ProjectID, item.zone, item.name).RequestId(o.requestID("stopinstance", item.zone, item.name)).Context(ctx).Do()
133+
op, err := o.computeSvc.Instances.
134+
Stop(o.ProjectID, item.zone, item.name).
135+
RequestId(o.requestID("stopinstance", item.zone, item.name)).
136+
DiscardLocalSsd(true).
137+
Context(ctx).
138+
Do()
134139
if err != nil && !isNoOp(err) {
135140
o.resetRequestID("stopinstance", item.zone, item.name)
136141
return errors.Wrapf(err, "failed to stop instance %s in zone %s", item.name, item.zone)

0 commit comments

Comments
 (0)