Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 4e53bef

Browse files
committed
Restore single label implementation
1 parent b190cf9 commit 4e53bef

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

internal/controller/appwrapper_controller.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ type AppWrapperReconciler struct {
4949
}
5050

5151
const (
52-
namespaceLabel = "mcad.codeflare.dev/namespace" // owner namespace label for wrapped resources
53-
nameLabel = "mcad.codeflare.dev" // owner name label for wrapped resources
54-
uidLabel = "mcad.codeflare.dev/uid" // owner UID label for wrapped resources
55-
finalizer = "mcad.codeflare.dev/finalizer" // finalizer name
56-
nvidiaGpu = "nvidia.com/gpu" // GPU resource name
57-
specNodeName = ".spec.nodeName" // key to index pods based on node placement
52+
nameLabel = "mcad.codeflare.dev" // owner name label for wrapped resources
53+
finalizer = "mcad.codeflare.dev/finalizer" // finalizer name
54+
nvidiaGpu = "nvidia.com/gpu" // GPU resource name
55+
specNodeName = ".spec.nodeName" // key to index pods based on node placement
5856
)
5957

6058
// PodCounts summarize the status of the pods associated with one AppWrapper
@@ -235,10 +233,9 @@ func (r *AppWrapperReconciler) SetupWithManager(mgr ctrl.Manager) error {
235233
// Map labelled pods to corresponding AppWrappers
236234
func (r *AppWrapperReconciler) podMapFunc(ctx context.Context, obj client.Object) []reconcile.Request {
237235
pod := obj.(*v1.Pod)
238-
if namespace, ok := pod.Labels[namespaceLabel]; ok {
239-
if name, ok := pod.Labels[nameLabel]; ok {
240-
return []reconcile.Request{{NamespacedName: types.NamespacedName{Namespace: namespace, Name: name}}}
241-
}
236+
if name, ok := pod.Labels[nameLabel]; ok {
237+
// assume the AppWrapper is in the same namespace, if not we rely on polling
238+
return []reconcile.Request{{NamespacedName: types.NamespacedName{Namespace: pod.Namespace, Name: name}}}
242239
}
243240
return nil
244241
}

internal/controller/resource_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (r *AppWrapperReconciler) parseResource(appWrapper *mcadv1beta1.AppWrapper,
4343
if namespaced && obj.GetNamespace() == "" {
4444
obj.SetNamespace(appWrapper.Namespace) // use AppWrapper namespace as default
4545
}
46-
obj.SetLabels(map[string]string{namespaceLabel: appWrapper.Namespace, nameLabel: appWrapper.Name, uidLabel: string(appWrapper.UID)})
46+
obj.SetLabels(map[string]string{nameLabel: appWrapper.Name})
4747
return obj, nil
4848
}
4949

internal/controller/timings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,5 @@ const (
3939
// may be triggered earlier due for instance to pod phase changes. Moreover, the reconciliation
4040
// itself may be delayed due to the on-going reconciliation of other events.
4141
runDelay = time.Minute // maximum delay before next reconciliation when running pods
42-
dispatchDelay = time.Minute // maximum delay before triggering dispatchNext with queued AppWrappers
42+
dispatchDelay = time.Minute // maximum delay before next dispatch attempt with queued AppWrappers
4343
)

0 commit comments

Comments
 (0)