Skip to content

Commit

Permalink
Use KWOK label instead of annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
gshaibi committed Nov 26, 2024
1 parent 83b94a7 commit 998f2e7
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion internal/common/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const (
AnnotationPodGroupName = "pod-group-name"
AnnotationReservationPodGpuIdx = "run.ai/reserve_for_gpu_index"
AnnotationMigMapping = "run.ai/mig-mapping"
AnnotationKwokNode = "kwok.x-k8s.io/node"

LabelGpuGroup = "runai-gpu-group"
LabelGpuProduct = "nvidia.com/gpu.product"
LabelMigConfigState = "nvidia.com/mig.config.state"
LabelFakeNodeDeploymentTemplate = "run.ai/fake-node-deployment-template"
LabelTopologyCMNodeTopology = "node-topology"
LabelTopologyCMNodeName = "node-name"
LabelKwokNode = "kwok.x-k8s.io/node"

ReservationNs = "runai-reservation"

Expand Down
8 changes: 4 additions & 4 deletions internal/common/topology/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ func CreateNodeTopologyCM(kubeclient kubernetes.Interface, nodeTopology *NodeTop
if err != nil {
return err
}
if value, found := node.Annotations[constants.AnnotationKwokNode]; found {
if cm.Annotations == nil {
cm.Annotations = make(map[string]string)
if value, found := node.Labels[constants.LabelKwokNode]; found {
if cm.Labels == nil {
cm.Labels = make(map[string]string)
}
cm.Annotations[constants.AnnotationKwokNode] = value
cm.Labels[constants.LabelKwokNode] = value
}

_, err = kubeclient.CoreV1().ConfigMaps(
Expand Down
10 changes: 3 additions & 7 deletions internal/kwok-gpu-device-plugin/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ var _ = Describe("KwokGpuDevicePlugin", func() {
ObjectMeta: metav1.ObjectMeta{
Name: "node1",
Labels: map[string]string{
nodePoolLabelKey: defaultNodePoolName,
},
Annotations: map[string]string{
constants.AnnotationKwokNode: "fake",
nodePoolLabelKey: defaultNodePoolName,
constants.LabelKwokNode: "fake",
},
},
}
Expand All @@ -127,9 +125,7 @@ var _ = Describe("KwokGpuDevicePlugin", func() {
cm, _, err := topology.ToNodeTopologyCM(&nodeTopology, node1.Name)
Expect(err).ToNot(HaveOccurred())
cm.Namespace = gpuOperatorNamespace
cm.Annotations = map[string]string{
constants.AnnotationKwokNode: "fake",
}
cm.Labels[constants.LabelKwokNode] = "fake"

_, err = kubeClient.CoreV1().ConfigMaps(gpuOperatorNamespace).Create(context.TODO(), cm, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func (c *ConfigMapController) Run(stopCh <-chan struct{}) {
}

func (c *ConfigMapController) isFakeGpuKWOKNodeConfigMap(cm *v1.ConfigMap) bool {
if cm == nil || cm.Labels == nil || cm.Annotations == nil {
if cm == nil || cm.Labels == nil {
return false
}
_, foundNodeName := cm.Labels[constants.LabelTopologyCMNodeName]
if !foundNodeName {
return false
}

return cm.Annotations[constants.AnnotationKwokNode] == "fake"
return cm.Labels[constants.LabelKwokNode] == "fake"
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ func generateFakeNodeDeploymentFromTemplate(template *appsv1.Deployment, node *v
}

func isFakeNode(node *v1.Node) bool {
return node != nil && node.Annotations[constants.AnnotationKwokNode] == "fake"
return node != nil && node.Annotations[constants.LabelKwokNode] == "fake"
}

0 comments on commit 998f2e7

Please sign in to comment.