Get "failed to create resource: Secret in version "v1" cannot be handled as a Secret: json: cannot unmarshal number into Go struct field Secret.stringData of type string" when password contains only digits
On a cpam3 deployment, I got the following error:
$ kubectl describe hr cluster-bmh
Name: cluster-bmh
Namespace: sylva-system
[...]
Status:
Conditions:
Last Transition Time: 2025-02-03T15:57:55Z
Message: Failed to upgrade after 3 attempt(s)
Observed Generation: 1
Reason: RetriesExceeded
Status: True
Type: Stalled
Last Transition Time: 2025-02-03T15:57:55Z
Message: Helm upgrade failed for release sylva-system/cluster-bmh with chart sylva-capi-cluster@0.4.4: failed to create resource: Secret in version "v1" cannot be handled as a Secret: json: cannot unmarshal number into Go struct field Secret.stringData of type string
Observed Generation: 1
Reason: UpgradeFailed
Status: False
Type: Ready
Last Transition Time: 2025-02-03T15:55:18Z
Message: Helm upgrade failed for release sylva-system/cluster-bmh with chart sylva-capi-cluster@0.4.4: failed to create resource: Secret in version "v1" cannot be handled as a Secret: json: cannot unmarshal number into Go struct field Secret.stringData of type string
Observed Generation: 1
Reason: UpgradeFailed
Status: False
Type: Released
Failures: 4
Helm Chart: sylva-system/sylva-system-cluster-bmh
[...]
The root cause of the error is the fact that bmh password was only made with digits and copied in secret as a number instead of a string
Workaround
- change password
or
- add additional quotes around password
baremetal_hosts:
server1:
credentials:
password: '"123456789"'
username: my-user
Note: the second workaround would break with proposed fix in sylva-projects/sylva-elements/helm-charts/sylva-capi-cluster!577 (merged) as inner quotes would be included in password
Edited by Médéric de Verdilhac