Skip to content

Commit

Permalink
AppWrapper implements JobWithManagedBy
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrove-oss committed Jan 28, 2025
1 parent cb8ac77 commit e5180cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 16 additions & 0 deletions pkg/controller/jobs/appwrapper/appwrapper_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (

kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
"sigs.k8s.io/kueue/pkg/controller/jobframework"
"sigs.k8s.io/kueue/pkg/features"
"sigs.k8s.io/kueue/pkg/podset"
)

Expand Down Expand Up @@ -90,6 +91,7 @@ func SetupIndexes(ctx context.Context, indexer client.FieldIndexer) error {
type AppWrapper awv1beta2.AppWrapper

var _ jobframework.GenericJob = (*AppWrapper)(nil)
var _ jobframework.JobWithManagedBy = (*AppWrapper)(nil)

func fromObject(o runtime.Object) *AppWrapper {
return (*AppWrapper)(o.(*awv1beta2.AppWrapper))
Expand Down Expand Up @@ -155,6 +157,20 @@ func (aw *AppWrapper) PodsReady() bool {
return meta.IsStatusConditionTrue(aw.Status.Conditions, string(awv1beta2.PodsReady))
}

func (j *AppWrapper) CanDefaultManagedBy() bool {
jobSpecManagedBy := j.Spec.ManagedBy
return features.Enabled(features.MultiKueue) &&
(jobSpecManagedBy == nil || *jobSpecManagedBy == awv1beta2.AppWrapperControllerName)
}

func (j *AppWrapper) ManagedBy() *string {
return j.Spec.ManagedBy
}

func (j *AppWrapper) SetManagedBy(managedBy *string) {
j.Spec.ManagedBy = managedBy
}

func GetWorkloadNameForAppWrapper(jobName string, jobUID types.UID) string {
return jobframework.GetWorkloadNameForOwnerWithGVK(jobName, jobUID, gvk)
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func (b *multikueueAdapter) IsJobManagedByKueue(ctx context.Context, c client.Cl
return false, fmt.Sprintf("Expecting spec.managedBy to be %q not %q", kueue.MultiKueueControllerName, awControllerName), nil
}
return true, "", nil

}

var _ jobframework.MultiKueueWatcher = (*multikueueAdapter)(nil)
Expand Down

0 comments on commit e5180cc

Please sign in to comment.