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
5 changes: 4 additions & 1 deletion api/v1beta2/appwrapper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ const (
RetryableExitCodesAnnotation = "workload.codeflare.dev.appwrapper/retryableExitCodes"
)

const AppWrapperControllerName = "workload.codeflare.dev/appwrapper-controller"
const (
AppWrapperControllerName = "workload.codeflare.dev/appwrapper-controller"
AppWrapperLabel = "workload.codeflare.dev/appwrapper"
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
Expand Down
6 changes: 2 additions & 4 deletions internal/controller/appwrapper/appwrapper_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ import (
)

const (
AppWrapperLabel = "workload.codeflare.dev/appwrapper"
AppWrapperFinalizer = "workload.codeflare.dev/finalizer"
childJobQueueName = "workload.codeflare.dev.admitted"
)

// AppWrapperReconciler reconciles an appwrapper
Expand Down Expand Up @@ -546,7 +544,7 @@ func (r *AppWrapperReconciler) getPodStatus(ctx context.Context, aw *workloadv1b
pods := &v1.PodList{}
if err := r.List(ctx, pods,
client.InNamespace(aw.Namespace),
client.MatchingLabels{AppWrapperLabel: aw.Name}); err != nil {
client.MatchingLabels{workloadv1beta2.AppWrapperLabel: aw.Name}); err != nil {
return nil, err
}
pc, err := utils.ExpectedPodCount(aw)
Expand Down Expand Up @@ -913,7 +911,7 @@ func clearCondition(aw *workloadv1beta2.AppWrapper, condition workloadv1beta2.Ap
// podMapFunc maps pods to appwrappers and generates reconcile.Requests for those whose Status.Phase is PodSucceeded
func (r *AppWrapperReconciler) podMapFunc(ctx context.Context, obj client.Object) []reconcile.Request {
pod := obj.(*v1.Pod)
if name, ok := pod.Labels[AppWrapperLabel]; ok {
if name, ok := pod.Labels[workloadv1beta2.AppWrapperLabel]; ok {
if pod.Status.Phase == v1.PodSucceeded {
return []reconcile.Request{{NamespacedName: types.NamespacedName{Namespace: pod.Namespace, Name: name}}}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/appwrapper/appwrapper_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ var _ = Describe("AppWrapper Controller", func() {

By("Validate expected markers and Autopilot anti-affinities were injected")
for _, p := range pods {
Expect(p.Labels).Should(HaveKeyWithValue(AppWrapperLabel, awName.Name))
Expect(p.Labels).Should(HaveKeyWithValue(workloadv1beta2.AppWrapperLabel, awName.Name))
validateMarkers(&p)
validateAutopilot(&p)
}
Expand All @@ -382,7 +382,7 @@ var _ = Describe("AppWrapper Controller", func() {

By("Validate expected markers and Autopilot anti-affinities were injected")
for _, p := range pods {
Expect(p.Labels).Should(HaveKeyWithValue(AppWrapperLabel, awName.Name))
Expect(p.Labels).Should(HaveKeyWithValue(workloadv1beta2.AppWrapperLabel, awName.Name))
validateMarkers(&p)
validateAutopilot(&p)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/appwrapper/fixtures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func getPods(aw *workloadv1beta2.AppWrapper) []v1.Pod {
err := k8sClient.List(ctx, podList, &client.ListOptions{Namespace: aw.Namespace})
Expect(err).NotTo(HaveOccurred())
for _, pod := range podList.Items {
if awn, found := pod.Labels[AppWrapperLabel]; found && awn == aw.Name {
if awn, found := pod.Labels[workloadv1beta2.AppWrapperLabel]; found && awn == aw.Name {
result = append(result, pod)
}
}
Expand All @@ -93,7 +93,7 @@ func setPodStatus(aw *workloadv1beta2.AppWrapper, phase v1.PodPhase, numToChange
if numToChange <= 0 {
return nil
}
if awn, found := pod.Labels[AppWrapperLabel]; found && awn == aw.Name {
if awn, found := pod.Labels[workloadv1beta2.AppWrapperLabel]; found && awn == aw.Name {
pod.Status.Phase = phase
err = k8sClient.Status().Update(ctx, &pod)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/appwrapper/resource_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (r *AppWrapperReconciler) createComponent(ctx context.Context, aw *workload
if err != nil {
return err, true
}
awLabels := map[string]string{AppWrapperLabel: aw.Name}
awLabels := map[string]string{workloadv1beta2.AppWrapperLabel: aw.Name}
obj.SetLabels(utilmaps.MergeKeepFirst(obj.GetLabels(), awLabels))

for podSetsIdx, podSet := range componentStatus.PodSets {
Expand Down Expand Up @@ -411,7 +411,7 @@ func (r *AppWrapperReconciler) deleteComponents(ctx context.Context, aw *workloa
if err := r.List(ctx, pods,
client.UnsafeDisableDeepCopy,
client.InNamespace(aw.Namespace),
client.MatchingLabels{AppWrapperLabel: aw.Name}); err != nil {
client.MatchingLabels{workloadv1beta2.AppWrapperLabel: aw.Name}); err != nil {
log.FromContext(ctx).Error(err, "Pod list error")
}

Expand Down
7 changes: 3 additions & 4 deletions test/e2e/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

workloadv1beta2 "github.com/project-codeflare/appwrapper/api/v1beta2"
"github.com/project-codeflare/appwrapper/internal/controller/appwrapper"
"github.com/project-codeflare/appwrapper/pkg/utils"
)

Expand Down Expand Up @@ -216,7 +215,7 @@ func getNodeForAppwrapper(ctx context.Context, awName types.NamespacedName) (str
return "", err
}
for _, pod := range podList.Items {
if awn, found := pod.Labels[appwrapper.AppWrapperLabel]; found && awn == awName.Name {
if awn, found := pod.Labels[workloadv1beta2.AppWrapperLabel]; found && awn == awName.Name {
return pod.Spec.NodeName, nil
}
}
Expand Down Expand Up @@ -249,7 +248,7 @@ func podsInPhase(awNamespace string, awName string, phase []v1.PodPhase, minimum

matchingPodCount := int32(0)
for _, pod := range podList.Items {
if awn, found := pod.Labels[appwrapper.AppWrapperLabel]; found && awn == awName {
if awn, found := pod.Labels[workloadv1beta2.AppWrapperLabel]; found && awn == awName {
for _, p := range phase {
if pod.Status.Phase == p {
matchingPodCount++
Expand All @@ -272,7 +271,7 @@ func noPodsExist(awNamespace string, awName string) wait.ConditionWithContextFun
}

for _, podFromPodList := range podList.Items {
if awn, found := podFromPodList.Labels[appwrapper.AppWrapperLabel]; found && awn == awName {
if awn, found := podFromPodList.Labels[workloadv1beta2.AppWrapperLabel]; found && awn == awName {
return false, nil
}
}
Expand Down
Loading