Skip to content

Commit 1593477

Browse files
Rename version-schedule-plugin label to version-schedule-pod
This shortens the label prefix by 3 characters, increasing maxCombinedLength from 38 to 41 and allowing longer Module name+namespace combinations when versioning is enabled. Upstream-Commit: b20329271317acd0cbfe597225c9ab63bf9cf7b5
1 parent 33d1d14 commit 1593477

13 files changed

Lines changed: 201 additions & 201 deletions

internal/constants/constants.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const (
1212
ResourceHashAnnotation = "kmm.node.kubernetes.io/last-hash"
1313
NamespaceLabelKey = "kmm.node.k8s.io/contains-modules"
1414

15-
WorkerPodVersionLabelPrefix = "beta.kmm.node.kubernetes.io/version-worker-pod"
16-
SchedulePluginVersionLabelPrefix = "beta.kmm.node.kubernetes.io/version-schedule-plugin"
17-
ModuleVersionLabelPrefix = "kmm.node.kubernetes.io/version-module"
15+
WorkerPodVersionLabelPrefix = "beta.kmm.node.kubernetes.io/version-worker-pod"
16+
SchedulePodVersionLabelPrefix = "beta.kmm.node.kubernetes.io/version-schedule-pod"
17+
ModuleVersionLabelPrefix = "kmm.node.kubernetes.io/version-module"
1818

1919
GCDelayFinalizer = "kmm.node.kubernetes.io/gc-delay"
2020
ModuleFinalizer = "kmm.node.kubernetes.io/module-finalizer"

internal/controllers/device_plugin_reconciler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ func generateDevicePluginLabelsAndSelector(mod *kmmv1beta1.Module) (map[string]s
553553
}
554554

555555
if mod.Spec.ModuleLoader != nil && mod.Spec.ModuleLoader.Container.Version != "" {
556-
versionLabel := utils.GetSchedulePluginVersionLabelName(mod.Namespace, mod.Name)
556+
versionLabel := utils.GetSchedulePodVersionLabelName(mod.Namespace, mod.Name)
557557
labels[versionLabel] = mod.Spec.ModuleLoader.Container.Version
558558
nodeSelector[versionLabel] = mod.Spec.ModuleLoader.Container.Version
559559
} else if mod.Spec.ModuleLoader == nil {
@@ -589,7 +589,7 @@ func getExistingDSFromVersion(existingDS []appsv1.DaemonSet,
589589
version = moduleLoader.Container.Version
590590
}
591591

592-
versionLabel := utils.GetSchedulePluginVersionLabelName(moduleNamespace, moduleName)
592+
versionLabel := utils.GetSchedulePodVersionLabelName(moduleNamespace, moduleName)
593593
for _, ds := range existingDS {
594594
dsModuleVersion := ds.GetLabels()[versionLabel]
595595
if dsModuleVersion == version {
@@ -602,7 +602,7 @@ func getExistingDSFromVersion(existingDS []appsv1.DaemonSet,
602602
func isOlderVersionUnusedDevicePluginDaemonset(ds *appsv1.DaemonSet, moduleVersion string) bool {
603603
moduleName := ds.Labels[constants.ModuleNameLabel]
604604
moduleNamespace := ds.Namespace
605-
versionLabel := utils.GetSchedulePluginVersionLabelName(moduleNamespace, moduleName)
605+
versionLabel := utils.GetSchedulePodVersionLabelName(moduleNamespace, moduleName)
606606
return ds.Labels[versionLabel] != moduleVersion && ds.Status.DesiredNumberScheduled == 0
607607
}
608608

internal/controllers/device_plugin_reconciler_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,16 @@ var _ = Describe("DevicePluginReconciler_garbageCollect", func() {
328328
},
329329
},
330330
}
331-
schedulePluginVersionLabel := utils.GetSchedulePluginVersionLabelName(mod.Namespace, mod.Name)
331+
schedulePodVersionLabel := utils.GetSchedulePodVersionLabelName(mod.Namespace, mod.Name)
332332

333333
DescribeTable("device-plugin GC", func(devicePluginFormerLabel bool, devicePluginFormerDesired int) {
334334
devicePluginDS := appsv1.DaemonSet{
335335
ObjectMeta: metav1.ObjectMeta{
336336
Name: "devicePlugin",
337337
Namespace: "namespace",
338338
Labels: map[string]string{
339-
schedulePluginVersionLabel: currentModuleVersion,
340-
constants.ModuleNameLabel: mod.Name,
339+
schedulePodVersionLabel: currentModuleVersion,
340+
constants.ModuleNameLabel: mod.Name,
341341
},
342342
},
343343
}
@@ -347,7 +347,7 @@ var _ = Describe("DevicePluginReconciler_garbageCollect", func() {
347347
if devicePluginFormerLabel {
348348
devicePluginFormerVersionDS = devicePluginDS.DeepCopy()
349349
devicePluginFormerVersionDS.SetName("devicePluginFormer")
350-
devicePluginFormerVersionDS.Labels[schedulePluginVersionLabel] = "former label"
350+
devicePluginFormerVersionDS.Labels[schedulePodVersionLabel] = "former label"
351351
devicePluginFormerVersionDS.Status.DesiredNumberScheduled = int32(devicePluginFormerDesired)
352352
existingDS = append(existingDS, *devicePluginFormerVersionDS)
353353
}
@@ -369,7 +369,7 @@ var _ = Describe("DevicePluginReconciler_garbageCollect", func() {
369369
ObjectMeta: metav1.ObjectMeta{
370370
Name: "devicePlugin",
371371
Namespace: "namespace",
372-
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePluginVersionLabel: "formerVersion"},
372+
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePodVersionLabel: "formerVersion"},
373373
},
374374
}
375375
clnt.EXPECT().Delete(context.Background(), &deleteDS).Return(fmt.Errorf("some error"))
@@ -387,7 +387,7 @@ var _ = Describe("DevicePluginReconciler_garbageCollect", func() {
387387
ObjectMeta: metav1.ObjectMeta{
388388
Name: "devicePlugin",
389389
Namespace: "namespace",
390-
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePluginVersionLabel: "formerVersion"},
390+
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePodVersionLabel: "formerVersion"},
391391
},
392392
}
393393

@@ -776,7 +776,7 @@ var _ = Describe("DevicePluginReconciler_setDevicePluginAsDesired", func() {
776776
err := dsc.setDevicePluginAsDesired(context.Background(), &ds, &mod)
777777

778778
Expect(err).NotTo(HaveOccurred())
779-
versionLabel := utils.GetSchedulePluginVersionLabelName(namespace, moduleName)
779+
versionLabel := utils.GetSchedulePodVersionLabelName(namespace, moduleName)
780780
Expect(ds.GetLabels()).Should(HaveKeyWithValue(versionLabel, "some version"))
781781
})
782782

@@ -1013,7 +1013,7 @@ var _ = Describe("DevicePluginReconciler_getExistingDSFromVersion", func() {
10131013
)
10141014

10151015
devicePluginLabels := map[string]string{
1016-
utils.GetSchedulePluginVersionLabelName(moduleNamespace, moduleName): moduleVersion,
1016+
utils.GetSchedulePodVersionLabelName(moduleNamespace, moduleName): moduleVersion,
10171017
}
10181018

10191019
ds := appsv1.DaemonSet{

internal/controllers/dra_reconciler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func getExistingDRADSFromVersion(existingDS []appsv1.DaemonSet,
269269
version = moduleLoader.Container.Version
270270
}
271271

272-
versionLabel := utils.GetSchedulePluginVersionLabelName(moduleNamespace, moduleName)
272+
versionLabel := utils.GetSchedulePodVersionLabelName(moduleNamespace, moduleName)
273273
for _, ds := range existingDS {
274274
dsModuleVersion := ds.GetLabels()[versionLabel]
275275
if dsModuleVersion == version {
@@ -281,7 +281,7 @@ func getExistingDRADSFromVersion(existingDS []appsv1.DaemonSet,
281281

282282
func isOlderVersionUnusedDRADaemonSet(ds *appsv1.DaemonSet, moduleNamespace, moduleVersion string) bool {
283283
moduleName := ds.Labels[constants.ModuleNameLabel]
284-
versionLabel := utils.GetSchedulePluginVersionLabelName(moduleNamespace, moduleName)
284+
versionLabel := utils.GetSchedulePodVersionLabelName(moduleNamespace, moduleName)
285285
return ds.Labels[versionLabel] != moduleVersion && ds.Status.DesiredNumberScheduled == 0
286286
}
287287

@@ -544,7 +544,7 @@ func (dsci *draDaemonSetCreatorImpl) setDRAAsDesired(
544544
}
545545

546546
if mod.Spec.ModuleLoader != nil && mod.Spec.ModuleLoader.Container.Version != "" {
547-
versionLabel := utils.GetSchedulePluginVersionLabelName(mod.Namespace, mod.Name)
547+
versionLabel := utils.GetSchedulePodVersionLabelName(mod.Namespace, mod.Name)
548548
standardLabels[versionLabel] = mod.Spec.ModuleLoader.Container.Version
549549
nodeSelector[versionLabel] = mod.Spec.ModuleLoader.Container.Version
550550
}

internal/controllers/dra_reconciler_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ var _ = Describe("DRAReconciler_setDRAAsDesired", func() {
844844
err := dsc.setDRAAsDesired(context.Background(), &ds, &mod)
845845
Expect(err).NotTo(HaveOccurred())
846846

847-
versionLabel := utils.GetSchedulePluginVersionLabelName(namespace, draModuleName)
847+
versionLabel := utils.GetSchedulePodVersionLabelName(namespace, draModuleName)
848848

849849
Expect(ds.Labels).To(HaveKeyWithValue(versionLabel, "1"))
850850
Expect(ds.Spec.Template.Spec.NodeSelector).To(HaveKeyWithValue(versionLabel, "1"))
@@ -882,16 +882,16 @@ var _ = Describe("DRAReconciler_garbageCollectDRADaemonSets", func() {
882882
},
883883
},
884884
}
885-
schedulePluginVersionLabel := utils.GetSchedulePluginVersionLabelName(mod.Namespace, mod.Name)
885+
schedulePodVersionLabel := utils.GetSchedulePodVersionLabelName(mod.Namespace, mod.Name)
886886

887887
DescribeTable("DRA GC", func(formerDSExists bool, formerDesired int) {
888888
currentDS := appsv1.DaemonSet{
889889
ObjectMeta: metav1.ObjectMeta{
890890
Name: "dra-current",
891891
Namespace: "namespace",
892892
Labels: map[string]string{
893-
schedulePluginVersionLabel: currentModuleVersion,
894-
constants.ModuleNameLabel: mod.Name,
893+
schedulePodVersionLabel: currentModuleVersion,
894+
constants.ModuleNameLabel: mod.Name,
895895
},
896896
},
897897
}
@@ -901,7 +901,7 @@ var _ = Describe("DRAReconciler_garbageCollectDRADaemonSets", func() {
901901
if formerDSExists {
902902
formerDS = currentDS.DeepCopy()
903903
formerDS.SetName("dra-former")
904-
formerDS.Labels[schedulePluginVersionLabel] = "former"
904+
formerDS.Labels[schedulePodVersionLabel] = "former"
905905
formerDS.Status.DesiredNumberScheduled = int32(formerDesired)
906906
existingDS = append(existingDS, *formerDS)
907907
}
@@ -922,7 +922,7 @@ var _ = Describe("DRAReconciler_garbageCollectDRADaemonSets", func() {
922922
ObjectMeta: metav1.ObjectMeta{
923923
Name: "dra-old",
924924
Namespace: "namespace",
925-
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePluginVersionLabel: "formerVersion"},
925+
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePodVersionLabel: "formerVersion"},
926926
},
927927
}
928928
clnt.EXPECT().Delete(context.Background(), &deleteDS).Return(fmt.Errorf("some error"))
@@ -938,7 +938,7 @@ var _ = Describe("DRAReconciler_garbageCollectDRADaemonSets", func() {
938938
ObjectMeta: metav1.ObjectMeta{
939939
Name: "dra-old",
940940
Namespace: "namespace",
941-
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePluginVersionLabel: "formerVersion"},
941+
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePodVersionLabel: "formerVersion"},
942942
},
943943
}
944944

internal/controllers/mock_node_label_module_version_reconciler.go

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controllers/module_version_label_action_table.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const (
1313
)
1414

1515
type labelActionKey struct {
16-
module string
17-
workerPod string
18-
schedulePlugin string
16+
module string
17+
workerPod string
18+
schedulePod string
1919
}
2020

2121
type labelAction struct {
@@ -25,42 +25,42 @@ type labelAction struct {
2525

2626
var labelActionTable = map[labelActionKey]labelAction{
2727
{
28-
module: labelMissing,
29-
workerPod: labelMissing,
30-
schedulePlugin: labelMissing}: {getLabelName: nil, action: noneAction},
28+
module: labelMissing,
29+
workerPod: labelMissing,
30+
schedulePod: labelMissing}: {getLabelName: nil, action: noneAction},
3131

3232
{
33-
module: labelMissing,
34-
workerPod: labelPresent,
35-
schedulePlugin: labelPresent}: {getLabelName: utils.GetSchedulePluginVersionLabelName, action: deleteAction},
33+
module: labelMissing,
34+
workerPod: labelPresent,
35+
schedulePod: labelPresent}: {getLabelName: utils.GetSchedulePodVersionLabelName, action: deleteAction},
3636

3737
{
38-
module: labelMissing,
39-
workerPod: labelPresent,
40-
schedulePlugin: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: deleteAction},
38+
module: labelMissing,
39+
workerPod: labelPresent,
40+
schedulePod: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: deleteAction},
4141

4242
{
43-
module: labelPresent,
44-
workerPod: labelMissing,
45-
schedulePlugin: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: addAction},
43+
module: labelPresent,
44+
workerPod: labelMissing,
45+
schedulePod: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: addAction},
4646

4747
{
48-
module: labelPresent,
49-
workerPod: labelPresent,
50-
schedulePlugin: labelMissing}: {getLabelName: utils.GetSchedulePluginVersionLabelName, action: addAction},
48+
module: labelPresent,
49+
workerPod: labelPresent,
50+
schedulePod: labelMissing}: {getLabelName: utils.GetSchedulePodVersionLabelName, action: addAction},
5151

5252
{
53-
module: labelPresent,
54-
workerPod: labelPresent,
55-
schedulePlugin: labelPresent}: {getLabelName: nil, action: noneAction},
53+
module: labelPresent,
54+
workerPod: labelPresent,
55+
schedulePod: labelPresent}: {getLabelName: nil, action: noneAction},
5656

5757
{
58-
module: labelPresent,
59-
workerPod: labelDifferent,
60-
schedulePlugin: labelDifferent}: {getLabelName: utils.GetSchedulePluginVersionLabelName, action: deleteAction},
58+
module: labelPresent,
59+
workerPod: labelDifferent,
60+
schedulePod: labelDifferent}: {getLabelName: utils.GetSchedulePodVersionLabelName, action: deleteAction},
6161

6262
{
63-
module: labelPresent,
64-
workerPod: labelDifferent,
65-
schedulePlugin: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: deleteAction},
63+
module: labelPresent,
64+
workerPod: labelDifferent,
65+
schedulePod: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: deleteAction},
6666
}

0 commit comments

Comments
 (0)