rancher / dashboard

The Rancher UI
https://rancher.com
Apache License 2.0
450 stars 256 forks source link

Editing configmap in rancher adds newline characters breaking kustomize #10589

Closed gaktive closed 1 month ago

gaktive commented 6 months ago

Internal reference: SURE-7824

Issue description: When you edit a ConfigMap in the Rancher UI via "Edit Config", the last-applied-configuration is corrupted by adding \n newline characters.

This does not happen if you use the 3 dot menu and click "Edit Yaml" but it does happen if you go to Edit Config, and then click Edit as YAML

The belief is that this is happening because Edit Config is using > as the operator in the last-applied-configuration section, while also wrapping long lines. If you use Edit Yaml it uses the | operator. This was tested going to Edit Config, clicking Edit as YAML and then replacing the > operator on the last-applied-configuration with a | and it did not experience the issue.

Impact: One environment's CI workflow is failing with Invalid Json when using kustomize on resources that have been modified through Rancher

Repro steps:

    kubectl create ns dims
    kubectl create -f test.json
    kubectl get n dims configmap dimsmanagement-config -o json
    Note there are no \n characters in the last-applied-configuration
    Edit the ConfigMap in Rancher via Edit Config, change automatic-error-replay.cron-expression from 0 30 * ? * * to 0 31 * ? * * and click save
    kubectl get -n dims configmap dimsmanagement-config -o json
    Note there are now \n characters present in the last-applied-configuration

Workaround: Edit the ConfigMap via Edit Yaml instead of Edit Config

Actual behavior: last-applied-configuration has \n characters added to it

Expected behavior: last-applied-configuration does not have \n characters added to it

Past efforts addressed in https://github.com/rancher/dashboard/issues/10044 though this is still happening on the main branch.

izaac commented 4 months ago

The final validation looks good to me. @yonasberhe23 @IsaSih what's your opinon on validating this manually using kustomize. I think this would depend on the test configuration if whether it's possible to keep it simple in one file/configmap.

yonasberhe23 commented 4 months ago

The final validation looks good to me. @yonasberhe23 @IsaSih what's your opinon on validating this manually using kustomize. I think this would depend on the test configuration if whether it's possible to keep it simple in one file/configmap.

I think thats a good call @izaac. moving to 'To Test'

floatingman commented 1 month ago

I ran through repro steps and confirmed that the newline was not added to the configmap Tested on Rancher: v2.9-dd23578d3e3499f54d80c4ed88cc52c44ee69539-head Dashoard: release-2.9 289516a