Skip to content

Add extraLabels to both subcontroller and vbsc pods#735

Open
jdoupe wants to merge 4 commits intoplanetscale:mainfrom
jdoupe:add-extra-labels
Open

Add extraLabels to both subcontroller and vbsc pods#735
jdoupe wants to merge 4 commits intoplanetscale:mainfrom
jdoupe:add-extra-labels

Conversation

@jdoupe
Copy link
Copy Markdown
Contributor

@jdoupe jdoupe commented Nov 26, 2025

Fixes #736

By adding the following:
vitessbackupschedules.spec.extraLabels
vitessbackupstorages.spec.extraLabels
vitessclusters.spec.backup.extraLabels

For vtbackup(-init), the code has just been modified to pass along the existing extraLabels on the tabletPool.

@mattlord / @frouioui

@mattlord
Copy link
Copy Markdown
Collaborator

mattlord commented Dec 1, 2025

@jdoupe can you please create a quick issue that describes what problem you're trying to solve? And link it to the PR here. Thanks!

@jdoupe jdoupe force-pushed the add-extra-labels branch 2 times, most recently from c7ba815 to ce2285c Compare December 3, 2025 03:26
@jdoupe
Copy link
Copy Markdown
Contributor Author

jdoupe commented Dec 3, 2025

Administrative note: (and you're probably already aware) the backup-schedule-test failed previously. I made a blank comment adjustment and force-pushed, and it then passed. I guess some sort of race condition.

@mattlord mattlord self-requested a review December 4, 2025 03:49
Copy link
Copy Markdown
Collaborator

@mattlord mattlord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a couple of tiny nits. Thanks, @jdoupe !

Comment thread pkg/controller/vitesscluster/reconcile_backup_storage.go Outdated
Comment thread pkg/operator/vitessbackup/schedule.go Outdated
@mattlord mattlord requested a review from frouioui December 5, 2025 15:15
@jdoupe
Copy link
Copy Markdown
Contributor Author

jdoupe commented Feb 2, 2026

Bump @frouioui

Copy link
Copy Markdown
Member

@frouioui frouioui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! The operator manifest and the vitess repository will need to be modified given this PR updates the CRDs. A guide on how to do this is available here:

#629 (comment)

@jdoupe jdoupe force-pushed the add-extra-labels branch 2 times, most recently from 55a0f83 to a20ed6a Compare April 4, 2026 18:02
@jdoupe
Copy link
Copy Markdown
Contributor Author

jdoupe commented Apr 4, 2026

@frouioui - I wanted to mention that in addition to the steps outlined in #629 (comment)

that it appears that the WATCH_NAMESPACE variable has also been altered (by you ;P ) in the time since, and likely needs to be "watched" on any change, as well as the securityContext that @mattlord added in the recent past.

Don't know if either or both of those are appropriate to add to the source (deploy/deployment.yaml).

I'll also note that kustomize(?) looks like it may have changed a bunch of whitespace things, as well as some other mundane bits.

All in all, this looks relatively straightforward, so do let me know if something else needs a tweak.

Thanks!

jdoupe added 4 commits April 26, 2026 13:53
Signed-off-by: Jeremy Doupe <jeremy@doupe.com>
Signed-off-by: Jeremy Doupe <jeremy@doupe.com>
Signed-off-by: Jeremy Doupe <jeremy@doupe.com>
Signed-off-by: Jeremy Doupe <jeremy@doupe.com>
@jdoupe jdoupe force-pushed the add-extra-labels branch from a20ed6a to 757fb6e Compare April 26, 2026 22:52
Copy link
Copy Markdown

@mhamza15 mhamza15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, LGTM otherwise. I also wrote up some regression tests that should reproduce the cases the two comments are referring to: mhamza15@f685780

Comment on lines +91 to +94
spec.ExtraLabels = make(map[string]string, len(extraLabels))
for k, v := range extraLabels {
spec.ExtraLabels[k] = v
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can use maps.Clone

Comment on lines +49 to +52
spec.ExtraLabels = make(map[string]string, len(vt.Spec.Backup.ExtraLabels))
for k, v := range vt.Spec.Backup.ExtraLabels {
spec.ExtraLabels[k] = v
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, can use maps.Clone

}
// Merge user-provided extra labels from ClusterBackupSpec.
if vbs.Spec.ExtraLabels != nil {
update.Labels(&labels, vbs.Spec.ExtraLabels)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds the custom labels to the label set that ReconcileObject uses to decide whether the existing pod belongs to this controller. If a subcontroller pod already exists and the user adds extraLabels later, the pod will not have those new labels yet, so reconciliation fails with NameCollision before it gets a chance to update the pod. I believe we should keep labels to only the stable operator labels here, and add vbs.Spec.ExtraLabels directly to the pod in New and UpdateInPlace instead.

}

// Apply ExtraLabels to the pod, similar to regular vttablet pods.
update.Labels(&pod.Labels, tabletSpec.ExtraLabels)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scheduled backup pods still will not get the custom tablet pool labels because the job only copies the generated pod spec, not the generated pod labels: https://github.com/jdoupe/vitess-operator/blob/757fb6e82d4eb3bbfbd5db7eeeda54faebe57154/pkg/controller/vitessbackupschedule/vitessbackupschedule_controller.go#L684-L686.

Those labels are lost before Kubernetes creates the real backup pod. I think we need to also add the custom tablet pool labels to the job template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add extraLabels option for backup pods

4 participants