Skip to content

simplify configuration of handling of app wrappers without user-provided queue names #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2024
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
1 change: 0 additions & 1 deletion config/default/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ data:
config.yaml: |
appwrapper:
enableKueueIntegrations: true
manageJobsWithoutQueueName: true
controllerManager:
health:
bindAddress: ":8081"
Expand Down
1 change: 0 additions & 1 deletion config/dev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ data:
config.yaml: |
appwrapper:
enableKueueIntegrations: true
manageJobsWithoutQueueName: true
controllerManager:
health:
bindAddress: "localhost:0"
Expand Down
1 change: 0 additions & 1 deletion config/standalone/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ data:
config.yaml: |
appwrapper:
enableKueueIntegrations: false
manageJobsWithoutQueueName: false
controllerManager:
health:
bindAddress: ":8081"
Expand Down
9 changes: 3 additions & 6 deletions internal/webhook/appwrapper_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,10 @@ func (w *AppWrapperWebhook) Default(ctx context.Context, obj runtime.Object) err

// Queue name and Suspend
if w.Config.EnableKueueIntegrations {
if w.Config.QueueName != "" && aw.Annotations[QueueNameLabel] == "" && aw.Labels[QueueNameLabel] == "" {
if aw.Labels == nil {
aw.Labels = map[string]string{}
}
aw.Labels[QueueNameLabel] = w.Config.QueueName
if w.Config.DefaultQueueName != "" {
aw.Labels = utilmaps.MergeKeepFirst(aw.Labels, map[string]string{QueueNameLabel: w.Config.DefaultQueueName})
}
jobframework.ApplyDefaultForSuspend((*wlc.AppWrapper)(aw), w.Config.ManageJobsWithoutQueueName)
jobframework.ApplyDefaultForSuspend((*wlc.AppWrapper)(aw), true)
}

// inject labels with user name and id
Expand Down
2 changes: 1 addition & 1 deletion internal/webhook/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())

conf := config.NewAppWrapperConfig()
conf.QueueName = defaultQueueName // add default queue name
conf.DefaultQueueName = defaultQueueName // add default queue name
err = (&AppWrapperWebhook{Config: conf}).SetupWebhookWithManager(mgr)
Expect(err).NotTo(HaveOccurred())

Expand Down
20 changes: 9 additions & 11 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ type OperatorConfig struct {
}

type AppWrapperConfig struct {
ManageJobsWithoutQueueName bool `json:"manageJobsWithoutQueueName,omitempty"`
EnableKueueIntegrations bool `json:"enableKueueIntegrations,omitempty"`
DisableChildAdmissionCtrl bool `json:"disableChildAdmissionCtrl,omitempty"`
UserRBACAdmissionCheck bool `json:"userRBACAdmissionCheck,omitempty"`
FaultTolerance *FaultToleranceConfig `json:"faultTolerance,omitempty"`
SchedulerName string `json:"schedulerName,omitempty"`
QueueName string `json:"queueName,omitempty"`
EnableKueueIntegrations bool `json:"enableKueueIntegrations,omitempty"`
DisableChildAdmissionCtrl bool `json:"disableChildAdmissionCtrl,omitempty"`
UserRBACAdmissionCheck bool `json:"userRBACAdmissionCheck,omitempty"`
FaultTolerance *FaultToleranceConfig `json:"faultTolerance,omitempty"`
SchedulerName string `json:"schedulerName,omitempty"`
DefaultQueueName string `json:"defaultQueueName,omitempty"`
}

type FaultToleranceConfig struct {
Expand Down Expand Up @@ -79,10 +78,9 @@ type HealthConfiguration struct {
// NewAppWrapperConfig constructs an AppWrapperConfig and fills in default values
func NewAppWrapperConfig() *AppWrapperConfig {
return &AppWrapperConfig{
ManageJobsWithoutQueueName: true,
EnableKueueIntegrations: true,
DisableChildAdmissionCtrl: false,
UserRBACAdmissionCheck: true,
EnableKueueIntegrations: true,
DisableChildAdmissionCtrl: false,
UserRBACAdmissionCheck: true,
FaultTolerance: &FaultToleranceConfig{
AdmissionGracePeriod: 1 * time.Minute,
WarmupGracePeriod: 5 * time.Minute,
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func SetupControllers(mgr ctrl.Manager, awConfig *config.AppWrapperConfig) error
if err := workload.WorkloadReconciler(
mgr.GetClient(),
mgr.GetEventRecorderFor("kueue"),
jobframework.WithManageJobsWithoutQueueName(awConfig.ManageJobsWithoutQueueName),
jobframework.WithManageJobsWithoutQueueName(true),
).SetupWithManager(mgr); err != nil {
return fmt.Errorf("workload controller: %w", err)
}
Expand Down