kubernetes/kops · error

error building Akamai (Linode) SSH key task: %w

Error message

error building Akamai (Linode) SSH key task: %w

What it means

buildSSHKeyTask creates the Linode SSH key task for the cluster and wraps any failure from computing the SSH key name (b.SSHKeyName()) with this error. The underlying cause (e.g. missing cluster name or SSH key naming input) is chained via %w, so the real reason is printed after this message.

Source

Thrown at pkg/model/linodemodel/instances.go:108

			Image:                  ig.Spec.Image,
			UserData:               userData,
			Tags:                   tags,
		}

		c.AddTask(&instanceGroup)
	}

	return nil
}

func (b *InstanceModelBuilder) buildSSHKeyTask(c *fi.CloudupModelBuilderContext) (*linodetasks.SSHKey, error) {
	if !b.UseSSHKey() {
		return nil, nil
	}

	name, err := b.SSHKeyName()
	if err != nil {
		return nil, fmt.Errorf("error building Akamai (Linode) SSH key task: %w", err)
	}
	name = linode.NormalizeLinodeLabel(name)
	if len(name) > maxLinodeSSHKeyNameLength {
		name = strings.Trim(name[:maxLinodeSSHKeyNameLength], "-_")
	}

	sshKeyTask := &linodetasks.SSHKey{
		Name:      new(name),
		Lifecycle: b.SSHKeyLifecycle,
	}
	if len(b.SSHPublicKeys) > 0 {
		publicKey := fi.Resource(fi.NewBytesResource(b.SSHPublicKeys[0]))
		sshKeyTask.PublicKey = &publicKey
	}
	c.AddTask(sshKeyTask)

	return sshKeyTask, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the wrapped cause after this message to find the real SSHKeyName() failure.
  2. Verify the cluster name and related spec fields are set correctly in the cluster manifest and state store.
  3. Ensure the cluster was created with a valid name (kops update cluster --name <cluster> with proper KOPS_STATE_STORE access).
  4. If SSH keys are not needed, disable SSH key usage for the instance groups so the task is skipped.
  5. Re-run with -v to trace the model context population.

Example fix

// before: running with an unset cluster name
kops update cluster
// after
kops update cluster --name mycluster.example.com --state s3://my-state-store
Defensive patterns

Strategy: try-catch

Validate before calling

if clusterName == "" {
    return errors.New("cluster name must be set before building Linode SSH key task")
}

Try / catch

sshKeyTask, err := b.buildSSHKeyTask(c)
if err != nil {
    return fmt.Errorf("failed to build instance model: %w", err)
}
// inspect chained cause: errors.Unwrap / %v will show SSHKeyName's error

Prevention

When it happens

Trigger: Calling kops update cluster for a Linode cluster when SSH keys are enabled (UseSSHKey() true) and SSHKeyName() returns an error — typically because the cluster or keyset name cannot be resolved from the model context.

Common situations: Cluster spec missing fields the SSH key name derives from; corrupted cluster name in state store; custom build flows/test harnesses invoking the builder without a fully populated LinodeModelContext.

Related errors


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