Skip to content
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

Renamed Queue to LocalQueue #341

Merged
merged 1 commit into from
Aug 19, 2022
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
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resources:
controller: true
domain: x-k8s.io
group: kueue
kind: Queue
kind: LocalQueue
path: sigs.k8s.io/kueue/apis/kueue/v1alpha1
version: v1alpha1
webhooks:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// QueueSpec defines the desired state of Queue
type QueueSpec struct {
// clusterQueue is a reference to a clusterQueue that backs this queue.
// LocalQueueSpec defines the desired state of LocalQueue
type LocalQueueSpec struct {
// clusterQueue is a reference to a clusterQueue that backs this localQueue.
ClusterQueue ClusterQueueReference `json:"clusterQueue,omitempty"`
}

// ClusterQueueReference is the name of the ClusterQueue.
type ClusterQueueReference string

// QueueStatus defines the observed state of Queue
type QueueStatus struct {
// LocalQueueStatus defines the observed state of LocalQueue
type LocalQueueStatus struct {
// PendingWorkloads is the number of workloads currently admitted to this
// queue not yet admitted to a ClusterQueue.
// localQueue not yet admitted to a ClusterQueue.
// +optional
PendingWorkloads int32 `json:"pendingWorkloads"`
}
Expand All @@ -41,25 +41,26 @@ type QueueStatus struct {
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="ClusterQueue",JSONPath=".spec.clusterQueue",type=string,description="Backing ClusterQueue"
//+kubebuilder:printcolumn:name="Pending Workloads",JSONPath=".status.pendingWorkloads",type=integer,description="Number of pending workloads"
ahg-g marked this conversation as resolved.
Show resolved Hide resolved
//+kubebuilder:resource:shortName={queue,queues}

// Queue is the Schema for the queues API
type Queue struct {
// LocalQueue is the Schema for the localQueues API
type LocalQueue struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec QueueSpec `json:"spec,omitempty"`
Status QueueStatus `json:"status,omitempty"`
Spec LocalQueueSpec `json:"spec,omitempty"`
Status LocalQueueStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// QueueList contains a list of Queue
type QueueList struct {
// LocalQueueList contains a list of LocalQueue
type LocalQueueList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Queue `json:"items"`
Items []LocalQueue `json:"items"`
}

func init() {
SchemeBuilder.Register(&Queue{}, &QueueList{})
SchemeBuilder.Register(&LocalQueue{}, &LocalQueueList{})
}
114 changes: 57 additions & 57 deletions apis/kueue/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/kueue/webhooks/clusterqueue_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (

var (
// log is for logging in this package.
clusterQueueLog = ctrl.Log.WithName("cluster-queue-webhook")
clusterQueueLog = ctrl.Log.WithName("clusterqueue-webhook")

queueingStrategies = sets.NewString(string(kueue.StrictFIFO), string(kueue.BestEffortFIFO))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,48 +30,48 @@ import (
)

// log is for logging in this package.
var queueLog = ctrl.Log.WithName("queue-webhook")
var localQueueLog = ctrl.Log.WithName("localqueue-webhook")

type QueueWebhook struct{}
type LocalQueueWebhook struct{}

func setupWebhookForQueue(mgr ctrl.Manager) error {
func setupWebhookForLocalQueue(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(&kueue.Queue{}).
WithValidator(&QueueWebhook{}).
For(&kueue.LocalQueue{}).
WithValidator(&LocalQueueWebhook{}).
Complete()
}

// +kubebuilder:webhook:path=/validate-kueue-x-k8s-io-v1alpha1-queue,mutating=false,failurePolicy=fail,sideEffects=None,groups=kueue.x-k8s.io,resources=queues,verbs=create;update,versions=v1alpha1,name=vqueue.kb.io,admissionReviewVersions=v1
// +kubebuilder:webhook:path=/validate-kueue-x-k8s-io-v1alpha1-localqueue,mutating=false,failurePolicy=fail,sideEffects=None,groups=kueue.x-k8s.io,resources=localqueues,verbs=create;update,versions=v1alpha1,name=vlocalqueue.kb.io,admissionReviewVersions=v1
ahg-g marked this conversation as resolved.
Show resolved Hide resolved

var _ webhook.CustomValidator = &QueueWebhook{}
var _ webhook.CustomValidator = &LocalQueueWebhook{}

// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type
func (w *QueueWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) error {
q := obj.(*kueue.Queue)
queueLog.V(5).Info("Validating create", "queue", klog.KObj(q))
return ValidateQueue(q).ToAggregate()
func (w *LocalQueueWebhook) ValidateCreate(ctx context.Context, obj runtime.Object) error {
q := obj.(*kueue.LocalQueue)
localQueueLog.V(5).Info("Validating create", "localQueue", klog.KObj(q))
return ValidateLocalQueue(q).ToAggregate()
}

// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type
func (w *QueueWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error {
newQ := newObj.(*kueue.Queue)
oldQ := oldObj.(*kueue.Queue)
queueLog.V(5).Info("Validating update", "queue", klog.KObj(newQ))
return ValidateQueueUpdate(newQ, oldQ).ToAggregate()
func (w *LocalQueueWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj runtime.Object) error {
newQ := newObj.(*kueue.LocalQueue)
oldQ := oldObj.(*kueue.LocalQueue)
localQueueLog.V(5).Info("Validating update", "localQueue", klog.KObj(newQ))
return ValidateLocalQueueUpdate(newQ, oldQ).ToAggregate()
}

// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type
func (w *QueueWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) error {
func (w *LocalQueueWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) error {
return nil
}

func ValidateQueue(q *kueue.Queue) field.ErrorList {
func ValidateLocalQueue(q *kueue.LocalQueue) field.ErrorList {
var allErrs field.ErrorList
clusterQueuePath := field.NewPath("spec", "clusterQueue")
allErrs = append(allErrs, validateNameReference(string(q.Spec.ClusterQueue), clusterQueuePath)...)
return allErrs
}

func ValidateQueueUpdate(newObj, oldObj *kueue.Queue) field.ErrorList {
func ValidateLocalQueueUpdate(newObj, oldObj *kueue.LocalQueue) field.ErrorList {
return apivalidation.ValidateImmutableField(newObj.Spec.ClusterQueue, oldObj.Spec.ClusterQueue, field.NewPath("spec", "clusterQueue"))
}
Loading