klusterlet label syncing does not support numerical strings as the label values (e.g., my-label: "123"
)
#530
Labels
bug
Something isn't working
my-label: "123"
)
#530
Describe the bug
We have a label with the
string
type, but actually a number inside the double quotes as a string. Gettingjson: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string
fromklusterlet
.To Reproduce
Scenario 1:
my-label: "123"
to klusterletkubectl get klusterlet -o yaml
produces following:message: '["klusterlet/managed/klusterlet-registration-serviceaccount.yaml" (string): cannot decode "klusterlet/managed/klusterlet-registration-serviceaccount.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-registration-clusterrole.yaml" (string): cannot decode "klusterlet/managed/klusterlet-registration-clusterrole.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-registration-clusterrole-addon-management.yaml" (string): cannot decode "klusterlet/managed/klusterlet-registration-clusterrole-addon-management.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-registration-clusterrolebinding.yaml" (string): cannot decode "klusterlet/managed/klusterlet-registration-clusterrolebinding.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-registration-clusterrolebinding-addon-management.yaml" (string): cannot decode "klusterlet/managed/klusterlet-registration-clusterrolebinding-addon-management.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-work-serviceaccount.yaml" (string): cannot decode "klusterlet/managed/klusterlet-work-serviceaccount.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-work-clusterrole.yaml" (string): cannot decode "klusterlet/managed/klusterlet-work-clusterrole.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-work-clusterrole-execution.yaml" (string): cannot decode "klusterlet/managed/klusterlet-work-clusterrole-execution.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-work-clusterrolebinding.yaml" (string): cannot decode "klusterlet/managed/klusterlet-work-clusterrolebinding.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-work-clusterrolebinding-aggregate.yaml" (string): cannot decode "klusterlet/managed/klusterlet-work-clusterrolebinding-aggregate.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string, "klusterlet/managed/klusterlet-work-clusterrolebinding-execution-admin.yaml" (string): cannot decode "klusterlet/managed/klusterlet-work-clusterrolebinding-execution-admin.yaml": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string]' reason: ManagedClusterResourceApplyFailed status: "False" type: Applied
message: 'Failed to get deployment "open-cluster-management-agent" "klusterlet-agent": deployments.apps "klusterlet-agent" not found' observedGeneration: 1 reason: GetDeploymentFailed status: "False" type: Available
Scenario 2: Then, we tested the integration test in the ocm repo.
Labels: map[string]string{"test": "123", "component": "klusterlet"},
make test-registration-operator-integration
locallyGetting:
E0618 11:37:56.802024 54730 helpers.go:592] failed to generate relatedResource [35 32 ... 93 10], and skip to set into status. json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string
Expected behavior
Should have create the resources successfully with the labels
Environment:
OCM version:
0.13.3
clusteradm version:
0.8.4
Kubernetes version:
v1.28.10
The text was updated successfully, but these errors were encountered: