kubernetes/kops · error

error setting labels on created Disk: %v

Error message

error setting labels on created Disk: %v

What it means

When labels must be applied to a newly created disk, kOps calls Disks().SetLabels with the merged fingerprint/labels; this error wraps a failure of that call. The disk exists, but labeling could not be applied.

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/disk.go:162

		d, err := cloud.Compute().Disks().Get(t.Cloud.Project(), *e.Zone, disk.Name)
		if err != nil {
			return fmt.Errorf("error reading created Disk: %v", err)
		}

		labelsRequest := &compute.ZoneSetLabelsRequest{
			LabelFingerprint: d.LabelFingerprint,
			Labels:           make(map[string]string),
		}
		// Danger: labels replace tags on instances; but thankfully volumes don't have tags
		//for _, k := range d.Tags {
		//	labelsRequest.Labels[k] = ""
		//}
		maps.Copy(labelsRequest.Labels, d.Labels)
		maps.Copy(labelsRequest.Labels, t.Cloud.Labels())
		maps.Copy(labelsRequest.Labels, e.Labels)
		klog.V(2).Infof("Setting labels on disk %q: %v", disk.Name, labelsRequest.Labels)
		if err = t.Cloud.Compute().Disks().SetLabels(t.Cloud.Project(), *e.Zone, disk.Name, labelsRequest); err != nil {
			return fmt.Errorf("error setting labels on created Disk: %v", err)
		}
		changes.Labels = nil
	}

	if a != nil && changes != nil {
		empty := &Disk{}
		if !reflect.DeepEqual(empty, changes) {
			return fmt.Errorf("cannot apply changes to Disk: %v", changes)
		}
	}

	return nil
}

type terraformDisk struct {
	Name                  *string           `cty:"name"`
	VolumeType            *string           `cty:"type"`
	SizeGB                *int64            `cty:"size"`

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Re-run kops update to fetch a fresh LabelFingerprint and retry
  2. Ensure only one kops update runs at a time
  3. Grant the service account compute.disks.setLabels / compute.disks.update IAM role
  4. Check the wrapped error for ablfingerprint-mismatch and retry after the conflicting writer finishes
Defensive patterns

Strategy: retry

Validate before calling

// fetch fresh fingerprint immediately before SetLabels
d, err := computeService.Disks.Get(project, zone, name).Do()
req := &compute.ZoneSetLabelsRequest{LabelFingerprint: d.LabelFingerprint, Labels: merged}

Try / catch

if err := setLabels(...); err != nil {
  if isFingerprintConflict(err) { time.Sleep(backoff); reGetAndRetry() }
  return err
}

Prevention

When it happens

Trigger: changes.Labels != nil and cloud.Compute().Disks().Disks().SetLabels(project, zone, disk.Name, labelsRequest) fails — commonly a LabelFingerprint conflict because the disk's labels changed concurrently.

Common situations: Another process modified disk labels between Get and SetLabels (stale fingerprint); insufficient compute.disks.setLabels IAM permission; concurrent kops runs against the same cluster.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/7fd09ccfeb6464fd. Report an issue: GitHub.