kubernetes/kops · error

error creating ServerGroup: %v

Error message

error creating ServerGroup: %v

What it means

This error is returned by RenderOpenstack when the OpenStack API call to create a new Server Group (t.Cloud.CreateServerGroup) fails. Server Groups in OpenStack control anti-affinity/affinity scheduling policies for instances, and kOps creates one per instance group policy set. The wrapped %v carries the underlying gophercloud error (auth failure, quota, policy name invalid, etc.).

Source

Thrown at upup/pkg/fi/cloudup/openstacktasks/servergroup.go:154

		if changes.Name != nil {
			return fi.CannotChangeField("Name")
		}
	}
	return nil
}

func (_ *ServerGroup) RenderOpenstack(t *openstack.OpenstackAPITarget, a, e, changes *ServerGroup) error {
	if a == nil {
		klog.V(2).Infof("Creating ServerGroup with Name:%q", fi.ValueOf(e.Name))

		opt := servergroups.CreateOpts{
			Name:     fi.ValueOf(e.Name),
			Policies: e.Policies,
		}

		g, err := t.Cloud.CreateServerGroup(opt)
		if err != nil {
			return fmt.Errorf("error creating ServerGroup: %v", err)
		}
		e.ID = new(g.ID)
		return nil
	} else if changes.IGMap != nil {
		for igName, maxSize := range changes.IGMap {
			actualIG := a.IGMap[igName]
			if fi.ValueOf(actualIG) > fi.ValueOf(maxSize) {
				currentLastIndex := fi.ValueOf(actualIG)

				for currentLastIndex > fi.ValueOf(maxSize) {
					iName := strings.ToLower(fmt.Sprintf("%s-%d.%s", igName, currentLastIndex, fi.ValueOf(a.ClusterName)))
					instanceName := strings.ReplaceAll(iName, ".", "-")
					opts := servers.ListOpts{
						Name: fmt.Sprintf("^%s", igName),
					}
					allInstances, err := t.Cloud.ListInstances(opts)
					if err != nil {
						return fmt.Errorf("error fetching instance list: %v", err)

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run 'openstack server group create --policy anti-affinity test' with the same credentials to see the raw Nova error and confirm auth/quota issues.
  2. Verify OpenStack credentials (OS_AUTH_URL, OS_USERNAME/OS_APPLICATION_CREDENTIAL_ID, OS_PROJECT_NAME, region) used by the kOps cloud provider.
  3. Check that Policies in the ServerGroup task spec only contain values supported by your Nova version (affinity, anti-affinity, soft-affinity, soft-anti-affinity).
  4. Check/raise the 'server groups' quota for the project in OpenStack, or delete unused server groups.
  5. Confirm the compute (Nova) service and server group API are enabled in the target cloud/region.

Example fix

// before: policies guessed / typo'd
Policies: []string{"anti affinity"}
// after: only valid Nova policies
Policies: []string{"anti-affinity"}
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate credentials and policy before creating a cluster
test -n "$OS_AUTH_URL" && test -n "$OS_APPLICATION_CREDENTIAL_ID" || echo "OpenStack creds missing"
openstack server group list 2>/dev/null || echo "Nova server-group API not reachable"
case "${POLICY:-anti-affinity}" in
  affinity|anti-affinity|soft-affinity|soft-anti-affinity) ;;
  *) echo "unsupported Nova policy: $POLICY" && exit 1 ;;
esac

Try / catch

// in Go, if driving fi yourself
g, err := cloud.CreateServerGroup(opt)
if err != nil {
    klog.Warningf("server group create failed (%v); check quota/auth then retry", err)
    return retryable(err)
}

Prevention

When it happens

Trigger: RenderOpenstack executing the create branch of the ServerGroup task: t.Cloud.CreateServerGroup(opt) returns a non-nil error. Causes include expired/missing OpenStack credentials, nonexistent or disabled Nova service, invalid policy names (e.g. not 'affinity'/'anti-affinity'/'soft-anti-affinity'), or project quota exceeded for server groups.

Common situations: Cluster creation/upgrade on OpenStack with wrong OS_* environment variables or an expired application credential; a user specifying an unsupported policy in the cluster spec; the cloud having no server-group quota left (default 10 per project); Nova API endpoint unreachable or version mismatch.

Related errors


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