Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const (
ResourceHashAnnotation = "kmm.node.kubernetes.io/last-hash"
NamespaceLabelKey = "kmm.node.k8s.io/contains-modules"

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

GCDelayFinalizer = "kmm.node.kubernetes.io/gc-delay"
ModuleFinalizer = "kmm.node.kubernetes.io/module-finalizer"
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/device_plugin_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ func generateDevicePluginLabelsAndSelector(mod *kmmv1beta1.Module) (map[string]s
}

if mod.Spec.ModuleLoader != nil && mod.Spec.ModuleLoader.Container.Version != "" {
versionLabel := utils.GetSchedulePluginVersionLabelName(mod.Namespace, mod.Name)
versionLabel := utils.GetSchedulePodVersionLabelName(mod.Namespace, mod.Name)
labels[versionLabel] = mod.Spec.ModuleLoader.Container.Version
nodeSelector[versionLabel] = mod.Spec.ModuleLoader.Container.Version
} else if mod.Spec.ModuleLoader == nil {
Expand Down Expand Up @@ -589,7 +589,7 @@ func getExistingDSFromVersion(existingDS []appsv1.DaemonSet,
version = moduleLoader.Container.Version
}

versionLabel := utils.GetSchedulePluginVersionLabelName(moduleNamespace, moduleName)
versionLabel := utils.GetSchedulePodVersionLabelName(moduleNamespace, moduleName)
for _, ds := range existingDS {
dsModuleVersion := ds.GetLabels()[versionLabel]
if dsModuleVersion == version {
Expand All @@ -602,7 +602,7 @@ func getExistingDSFromVersion(existingDS []appsv1.DaemonSet,
func isOlderVersionUnusedDevicePluginDaemonset(ds *appsv1.DaemonSet, moduleVersion string) bool {
moduleName := ds.Labels[constants.ModuleNameLabel]
moduleNamespace := ds.Namespace
versionLabel := utils.GetSchedulePluginVersionLabelName(moduleNamespace, moduleName)
versionLabel := utils.GetSchedulePodVersionLabelName(moduleNamespace, moduleName)
return ds.Labels[versionLabel] != moduleVersion && ds.Status.DesiredNumberScheduled == 0
}

Expand Down
16 changes: 8 additions & 8 deletions internal/controllers/device_plugin_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,16 @@ var _ = Describe("DevicePluginReconciler_garbageCollect", func() {
},
},
}
schedulePluginVersionLabel := utils.GetSchedulePluginVersionLabelName(mod.Namespace, mod.Name)
schedulePodVersionLabel := utils.GetSchedulePodVersionLabelName(mod.Namespace, mod.Name)

DescribeTable("device-plugin GC", func(devicePluginFormerLabel bool, devicePluginFormerDesired int) {
devicePluginDS := appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: "devicePlugin",
Namespace: "namespace",
Labels: map[string]string{
schedulePluginVersionLabel: currentModuleVersion,
constants.ModuleNameLabel: mod.Name,
schedulePodVersionLabel: currentModuleVersion,
constants.ModuleNameLabel: mod.Name,
},
},
}
Expand All @@ -347,7 +347,7 @@ var _ = Describe("DevicePluginReconciler_garbageCollect", func() {
if devicePluginFormerLabel {
devicePluginFormerVersionDS = devicePluginDS.DeepCopy()
devicePluginFormerVersionDS.SetName("devicePluginFormer")
devicePluginFormerVersionDS.Labels[schedulePluginVersionLabel] = "former label"
devicePluginFormerVersionDS.Labels[schedulePodVersionLabel] = "former label"
devicePluginFormerVersionDS.Status.DesiredNumberScheduled = int32(devicePluginFormerDesired)
existingDS = append(existingDS, *devicePluginFormerVersionDS)
}
Expand All @@ -369,7 +369,7 @@ var _ = Describe("DevicePluginReconciler_garbageCollect", func() {
ObjectMeta: metav1.ObjectMeta{
Name: "devicePlugin",
Namespace: "namespace",
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePluginVersionLabel: "formerVersion"},
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePodVersionLabel: "formerVersion"},
},
}
clnt.EXPECT().Delete(context.Background(), &deleteDS).Return(fmt.Errorf("some error"))
Expand All @@ -387,7 +387,7 @@ var _ = Describe("DevicePluginReconciler_garbageCollect", func() {
ObjectMeta: metav1.ObjectMeta{
Name: "devicePlugin",
Namespace: "namespace",
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePluginVersionLabel: "formerVersion"},
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePodVersionLabel: "formerVersion"},
},
}

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

Expect(err).NotTo(HaveOccurred())
versionLabel := utils.GetSchedulePluginVersionLabelName(namespace, moduleName)
versionLabel := utils.GetSchedulePodVersionLabelName(namespace, moduleName)
Expect(ds.GetLabels()).Should(HaveKeyWithValue(versionLabel, "some version"))
})

Expand Down Expand Up @@ -1013,7 +1013,7 @@ var _ = Describe("DevicePluginReconciler_getExistingDSFromVersion", func() {
)

devicePluginLabels := map[string]string{
utils.GetSchedulePluginVersionLabelName(moduleNamespace, moduleName): moduleVersion,
utils.GetSchedulePodVersionLabelName(moduleNamespace, moduleName): moduleVersion,
}

ds := appsv1.DaemonSet{
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/dra_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func getExistingDRADSFromVersion(existingDS []appsv1.DaemonSet,
version = moduleLoader.Container.Version
}

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

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

Expand Down Expand Up @@ -544,7 +544,7 @@ func (dsci *draDaemonSetCreatorImpl) setDRAAsDesired(
}

if mod.Spec.ModuleLoader != nil && mod.Spec.ModuleLoader.Container.Version != "" {
versionLabel := utils.GetSchedulePluginVersionLabelName(mod.Namespace, mod.Name)
versionLabel := utils.GetSchedulePodVersionLabelName(mod.Namespace, mod.Name)
standardLabels[versionLabel] = mod.Spec.ModuleLoader.Container.Version
nodeSelector[versionLabel] = mod.Spec.ModuleLoader.Container.Version
}
Expand Down
14 changes: 7 additions & 7 deletions internal/controllers/dra_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ var _ = Describe("DRAReconciler_setDRAAsDesired", func() {
err := dsc.setDRAAsDesired(context.Background(), &ds, &mod)
Expect(err).NotTo(HaveOccurred())

versionLabel := utils.GetSchedulePluginVersionLabelName(namespace, draModuleName)
versionLabel := utils.GetSchedulePodVersionLabelName(namespace, draModuleName)

Expect(ds.Labels).To(HaveKeyWithValue(versionLabel, "1"))
Expect(ds.Spec.Template.Spec.NodeSelector).To(HaveKeyWithValue(versionLabel, "1"))
Expand Down Expand Up @@ -882,16 +882,16 @@ var _ = Describe("DRAReconciler_garbageCollectDRADaemonSets", func() {
},
},
}
schedulePluginVersionLabel := utils.GetSchedulePluginVersionLabelName(mod.Namespace, mod.Name)
schedulePodVersionLabel := utils.GetSchedulePodVersionLabelName(mod.Namespace, mod.Name)

DescribeTable("DRA GC", func(formerDSExists bool, formerDesired int) {
currentDS := appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: "dra-current",
Namespace: "namespace",
Labels: map[string]string{
schedulePluginVersionLabel: currentModuleVersion,
constants.ModuleNameLabel: mod.Name,
schedulePodVersionLabel: currentModuleVersion,
constants.ModuleNameLabel: mod.Name,
},
},
}
Expand All @@ -901,7 +901,7 @@ var _ = Describe("DRAReconciler_garbageCollectDRADaemonSets", func() {
if formerDSExists {
formerDS = currentDS.DeepCopy()
formerDS.SetName("dra-former")
formerDS.Labels[schedulePluginVersionLabel] = "former"
formerDS.Labels[schedulePodVersionLabel] = "former"
formerDS.Status.DesiredNumberScheduled = int32(formerDesired)
existingDS = append(existingDS, *formerDS)
}
Expand All @@ -922,7 +922,7 @@ var _ = Describe("DRAReconciler_garbageCollectDRADaemonSets", func() {
ObjectMeta: metav1.ObjectMeta{
Name: "dra-old",
Namespace: "namespace",
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePluginVersionLabel: "formerVersion"},
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePodVersionLabel: "formerVersion"},
},
}
clnt.EXPECT().Delete(context.Background(), &deleteDS).Return(fmt.Errorf("some error"))
Expand All @@ -938,7 +938,7 @@ var _ = Describe("DRAReconciler_garbageCollectDRADaemonSets", func() {
ObjectMeta: metav1.ObjectMeta{
Name: "dra-old",
Namespace: "namespace",
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePluginVersionLabel: "formerVersion"},
Labels: map[string]string{constants.ModuleNameLabel: mod.Name, schedulePodVersionLabel: "formerVersion"},
},
}

Expand Down
20 changes: 10 additions & 10 deletions internal/controllers/mock_node_label_module_version_reconciler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 27 additions & 27 deletions internal/controllers/module_version_label_action_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const (
)

type labelActionKey struct {
module string
workerPod string
schedulePlugin string
module string
workerPod string
schedulePod string
}

type labelAction struct {
Expand All @@ -25,42 +25,42 @@ type labelAction struct {

var labelActionTable = map[labelActionKey]labelAction{
{
module: labelMissing,
workerPod: labelMissing,
schedulePlugin: labelMissing}: {getLabelName: nil, action: noneAction},
module: labelMissing,
workerPod: labelMissing,
schedulePod: labelMissing}: {getLabelName: nil, action: noneAction},

{
module: labelMissing,
workerPod: labelPresent,
schedulePlugin: labelPresent}: {getLabelName: utils.GetSchedulePluginVersionLabelName, action: deleteAction},
module: labelMissing,
workerPod: labelPresent,
schedulePod: labelPresent}: {getLabelName: utils.GetSchedulePodVersionLabelName, action: deleteAction},

{
module: labelMissing,
workerPod: labelPresent,
schedulePlugin: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: deleteAction},
module: labelMissing,
workerPod: labelPresent,
schedulePod: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: deleteAction},

{
module: labelPresent,
workerPod: labelMissing,
schedulePlugin: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: addAction},
module: labelPresent,
workerPod: labelMissing,
schedulePod: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: addAction},

{
module: labelPresent,
workerPod: labelPresent,
schedulePlugin: labelMissing}: {getLabelName: utils.GetSchedulePluginVersionLabelName, action: addAction},
module: labelPresent,
workerPod: labelPresent,
schedulePod: labelMissing}: {getLabelName: utils.GetSchedulePodVersionLabelName, action: addAction},

{
module: labelPresent,
workerPod: labelPresent,
schedulePlugin: labelPresent}: {getLabelName: nil, action: noneAction},
module: labelPresent,
workerPod: labelPresent,
schedulePod: labelPresent}: {getLabelName: nil, action: noneAction},

{
module: labelPresent,
workerPod: labelDifferent,
schedulePlugin: labelDifferent}: {getLabelName: utils.GetSchedulePluginVersionLabelName, action: deleteAction},
module: labelPresent,
workerPod: labelDifferent,
schedulePod: labelDifferent}: {getLabelName: utils.GetSchedulePodVersionLabelName, action: deleteAction},

{
module: labelPresent,
workerPod: labelDifferent,
schedulePlugin: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: deleteAction},
module: labelPresent,
workerPod: labelDifferent,
schedulePod: labelMissing}: {getLabelName: utils.GetWorkerPodVersionLabelName, action: deleteAction},
}
Loading
Loading