kubernetes/kops · error

failed to create cloud group instance for server %s(%d): %w

Error message

failed to create cloud group instance for server %s(%d): %w

What it means

buildCloudInstanceGroup calls NewCloudInstance, which rejects duplicate instance IDs within a group. This error wraps that failure for a Hetzner server, meaning two servers mapped to the same cloud instance group carry the same numeric ID (or the group state is inconsistent).

Source

Thrown at upup/pkg/fi/cloudup/hetzner/cloud.go:384

	cloudInstanceGroup := &cloudinstances.CloudInstanceGroup{
		HumanName:     ig.Name,
		InstanceGroup: ig,
		Raw:           sg,
		MinSize:       int(fi.ValueOf(ig.Spec.MinSize)),
		TargetSize:    int(fi.ValueOf(ig.Spec.MinSize)),
		MaxSize:       int(fi.ValueOf(ig.Spec.MaxSize)),
	}

	for _, server := range sg {
		status := cloudinstances.CloudInstanceStatusUpToDate
		if _, ok := server.Labels[TagKubernetesInstanceNeedsUpdate]; ok {
			status = cloudinstances.CloudInstanceStatusNeedsUpdate
		}

		id := strconv.FormatInt(server.ID, 10)
		cloudInstance, err := cloudInstanceGroup.NewCloudInstance(id, status, nodeMap[id])
		if err != nil {
			return nil, fmt.Errorf("failed to create cloud group instance for server %s(%d): %w", server.Name, server.ID, err)
		}

		// Add additional instance info
		cloudInstance.State = cloudinstances.State(server.Status)
		if role, ok := server.Labels[TagKubernetesInstanceRole]; ok {
			cloudInstance.Roles = append(cloudInstance.Roles, role)
		}
		if server.ServerType != nil {
			cloudInstance.MachineType = server.ServerType.Name
		}
		if len(server.PrivateNet) > 0 {
			cloudInstance.PrivateIP = server.PrivateNet[0].IP.String()
		}
	}

	return cloudInstanceGroup, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the server name/ID in the message and look for duplicate Hetzner servers with the same kops instance-group label.
  2. Delete any manually created duplicate servers so each ID is unique per group.
  3. Re-run `kops get instancegroups` / rolling-update to refresh group state.
  4. If caused by an interrupted operation, wait for reconciliation or run a rolling update to converge state.
Defensive patterns

Strategy: validation

Validate before calling

seen := map[int64]bool{}
for _, s := range servers {
  if seen[s.ID] { return fmt.Errorf("duplicate server ID %d in group %s", s.ID, groupName) }
  seen[s.ID] = true
}

Prevention

When it happens

Trigger: A server with an ID already present in the CloudInstanceGroup is processed again, e.g. duplicate servers listed or a server added twice to Ready/NeedUpdate sets.

Common situations: Corrupted cloud state after an interrupted scaling operation; manually duplicated Hetzner servers sharing the kops instance-group label; a kOps bug reprocessing the same server list entry.

Related errors


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