Netflix/chaosmonkey · error

retrieve cloud provider failed

Error message

retrieve cloud provider failed

What it means

Spinnaker.GetApp throws this when s.CloudProvider(account) fails for one of the accounts configured for the app. It wraps the underlying error from CloudProvider (which calls the internal account(name) lookup), meaning the account's cloud provider could not be retrieved from the Spinnaker API.

Source

Thrown at spinnaker/spinnaker.go:304

	asg := D.ASGName(data.Name)
	instances := make([]D.InstanceID, len(data.Instances))
	for i, instance := range data.Instances {
		instances[i] = D.InstanceID(instance.Name)
	}

	return asg, instances, nil

}

// GetApp implements deploy.Deployment.GetApp
func (s Spinnaker) GetApp(appName string) (*D.App, error) {
	// data arg is a map like {accountName: {clusterName: {regionName: {asgName: [instanceId]}}}}
	data := make(D.AppMap)
	for account, clusters := range s.clusters(appName) {
		cloudProvider, err := s.CloudProvider(account)
		if err != nil {
			return nil, errors.Wrap(err, "retrieve cloud provider failed")
		}
		account := D.AccountName(account)
		data[account] = D.AccountInfo{
			CloudProvider: cloudProvider,
			Clusters:      make(map[D.ClusterName]map[D.RegionName]map[D.ASGName][]D.InstanceID),
		}
		for _, clusterName := range clusters {
			clusterName := D.ClusterName(clusterName)
			data[account].Clusters[clusterName] = make(map[D.RegionName]map[D.ASGName][]D.InstanceID)
			asgs, err := s.asgs(appName, string(account), string(clusterName))
			if err != nil {
				log.Printf("WARNING: could not retrieve asgs for app:%s account:%s cluster:%s : %v", appName, account, clusterName, err)
				continue
			}
			for _, asg := range asgs {

				// We don't terminate instances in disabled ASGs
				if asg.Disabled {

View on GitHub (pinned to eaa28fb761)

Solutions

  1. Inspect the wrapped inner error (use %v on the chain) to see whether it was network, JSON, or 'account name doesn't exist'.
  2. Verify the account name exists: query the Spinnaker /accounts endpoint or UI and compare with the app's configured accounts.
  3. Re-check the app's cluster naming convention that yields the account name — stale configs after account renames are common.
  4. Ensure Spinnaker gate is reachable and credentials are valid.
  5. If one account is intentionally missing, remove it from the app's configuration or skip it upstream.

Example fix

// before
cloudProvider, err := s.CloudProvider(account)
if err != nil {
    return nil, errors.Wrap(err, "retrieve cloud provider failed")
}
// after (caller-side check)
_, err := sp.GetApp("myapp")
if err != nil {
    log.Printf("GetApp failed: %+v", err) // print full chain to see the root cause
}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the account exists before GetApp
accounts, err := fetchSpinnakerAccountNames(baseURL, client) // GET /accounts
if err != nil {
    return err
}
accountSet := make(map[string]bool, len(accounts))
for _, a := range accounts {
    accountSet[a] = true
}
for _, acct := range configuredAccounts {
    if !accountSet[acct] {
        return fmt.Errorf("account %q configured for app but missing in spinnaker", acct)
    }
}

Try / catch

// Go: unwrap the chain to find the root cause
app, err := sp.GetApp(appName)
if err != nil {
    root := errors.Cause(err)
    switch {
    case strings.Contains(root.Error(), "doesn't exist"):
        log.Printf("stale account config: %v", err) // fix app config
    default:
        log.Printf("spinnaker account lookup failed: %+v", err)
    }
    return app, err
}

Prevention

When it happens

Trigger: Calling GetApp (directly or via Apps) when the Spinnaker /accounts endpoint is unreachable, returns non-JSON, or the account name from s.clusters(appName) does not exist in Spinnaker — the inner error is wrapped with this message.

Common situations: Stale app configuration referencing an account deleted from Spinnaker (clouddriver account removed/renamed); Spinnaker gate down; typo in account name in app cluster naming convention; permissions preventing the accounts listing.

Related errors


AI-assisted analysis of Netflix/chaosmonkey@eaa28fb761 (2026-09-03). Data as JSON: /api/errors/86330a2041871d17. Report an issue: GitHub.