kubernetes/kops · error
marshaling Azure cloud config: %w
Error message
marshaling Azure cloud config: %w
What it means
Thrown in AzureCloudConfig when encoding the Azure cloud-provider configuration struct (built by azure.BuildCloudConfig) to JSON fails. json.Marshal almost never fails on plain config structs; if it fires, the built config contains a value of an unsupported type (e.g. a channel, function, complex number, or a cycle introduced by a config field).
Source
Thrown at upup/pkg/fi/cloudup/template_functions.go:735
// Azure reads its cloud config from the azure-cloud-provider Secret.
default:
argv = append(argv, "--cloud-config=/etc/kubernetes/cloud.config")
}
return argv, nil
}
// AzureCloudConfig returns the base64-encoded Azure cloud provider
// configuration. kOps publishes it in the azure-cloud-provider Secret, which the
// cloud-controller-manager and CSI drivers load via --cloud-config-secret-name.
func (tf *TemplateFunctions) AzureCloudConfig() (string, error) {
config, err := azure.BuildCloudConfig(tf.Cluster)
if err != nil {
return "", err
}
data, err := json.Marshal(config)
if err != nil {
return "", fmt.Errorf("marshaling Azure cloud config: %w", err)
}
return base64.StdEncoding.EncodeToString(data), nil
}
// DNSControllerArgv returns the args to the DNS controller
func (tf *TemplateFunctions) DNSControllerArgv() ([]string, error) {
cluster := tf.Cluster
var argv []string
// @check if the dns controller has custom configuration
if cluster.Spec.ExternalDNS == nil {
argv = append(argv, []string{"--watch-ingress=false"}...)
klog.V(4).Infof("watch-ingress=false set on dns-controller")
} else {
// @check if the watch ingress is set
var watchIngress boolView on GitHub (pinned to 4c8573c808)
Solutions
- Inspect the built Azure cloud config for unusual field types (cycles, func/chan fields) added by recent changes
- Fix the azure.BuildCloudConfig output so it only contains JSON-serializable values
- Capture the wrapped *json.MarshalerError details (type and field) to locate the offending value
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/template_functions.go:735 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/5339b48d0ebf6b3c.
Report an issue: GitHub.