Skip to content

Commit af02708

Browse files
authored
Add option to inject queue name if missing (#137)
1 parent 16f772f commit af02708

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

internal/webhook/appwrapper_webhook.go

+7
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import (
4848
const (
4949
AppWrapperUsernameLabel = "workload.codeflare.dev/user"
5050
AppWrapperUserIDLabel = "workload.codeflare.dev/userid"
51+
QueueNameLabel = "kueue.x-k8s.io/queue-name"
5152
)
5253

5354
type AppWrapperWebhook struct {
@@ -81,6 +82,12 @@ func (w *AppWrapperWebhook) Default(ctx context.Context, obj runtime.Object) err
8182
userInfo := request.UserInfo
8283
username := utils.SanitizeLabel(userInfo.Username)
8384
aw.Labels = utilmaps.MergeKeepFirst(map[string]string{AppWrapperUsernameLabel: username, AppWrapperUserIDLabel: userInfo.UID}, aw.Labels)
85+
86+
// inject default queue name if missing from appwrapper and configured on controller
87+
if w.Config.QueueName != "" && aw.Annotations[QueueNameLabel] == "" && aw.Labels[QueueNameLabel] == "" {
88+
aw.Labels[QueueNameLabel] = w.Config.QueueName
89+
}
90+
8491
return nil
8592
}
8693

pkg/config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type AppWrapperConfig struct {
3535
UserRBACAdmissionCheck bool `json:"userRBACAdmissionCheck,omitempty"`
3636
FaultTolerance *FaultToleranceConfig `json:"faultTolerance,omitempty"`
3737
SchedulerName string `json:"schedulerName,omitempty"`
38+
QueueName string `json:"queueName,omitempty"`
3839
}
3940

4041
type FaultToleranceConfig struct {

0 commit comments

Comments
 (0)