Skip to content

Commit

Permalink
Renamed Queue to LocalQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
ahg-g committed Aug 18, 2022
1 parent c39e612 commit 59bf53b
Show file tree
Hide file tree
Showing 32 changed files with 347 additions and 347 deletions.
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 @@ -42,24 +42,24 @@ type QueueStatus struct {
//+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"

// 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

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

0 comments on commit 59bf53b

Please sign in to comment.