You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Backup Job and its pod template share one label map #1743
createBackupJob in controllers/backupcronjob/backupcronjob_controller.go builds one jobLabels map and assigns that same map to both job.ObjectMeta.Labels and job.Spec.Template.ObjectMeta.Labels.
In Go a map is a reference, so a later write to either field changes the other. Nothing in createBackupJob writes to the map after it is assigned, and client.Create only serializes it, so this does not mislabel Jobs today. The two label sets are meant to carry the same keys (controller.devfile.io/devworkspace_id, controller.devfile.io/devworkspace_name, controller.devfile.io/backup-job, and controller.devfile.io/creator).
This was noted in review of #1741. The previous code used two independent map literals. Giving the pod template its own map, with maps.Clone or a second literal, keeps a future pod-only label from also landing on the Job.
pkg/provision/storage/cleanup.go uses the same shared-map pattern for the PVC cleanup Job. There the restricted-access label is written into jobLabels before both fields are set, so both objects receive it. That call site has the same aliasing.
How To Reproduce
Not reproducible as a failure with the current code. The alias is visible in createBackupJob: both label fields are set to jobLabels.
Expected behavior
The Job metadata labels and the pod template labels are separate maps, initialized with the same entries. Editing one after construction does not change the other.
Additional context
Raised while reviewing #1741. No current caller depends on the two fields diverging.
Activity