sigs.k8s.io/kueue@v0.6.2/apis/visibility/v1alpha1/types.go (about)

     1  /*
     2  Copyright 2023 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1alpha1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  )
    22  
    23  // +genclient
    24  // +kubebuilder:object:root=true
    25  // +k8s:openapi-gen=true
    26  // +genclient:nonNamespaced
    27  // +genclient:method=GetPendingWorkloadsSummary,verb=get,subresource=pendingworkloads,result=sigs.k8s.io/kueue/apis/visibility/v1alpha1.PendingWorkloadsSummary
    28  type ClusterQueue struct {
    29  	metav1.TypeMeta   `json:",inline"`
    30  	metav1.ObjectMeta `json:"metadata,omitempty"`
    31  
    32  	Summary PendingWorkloadsSummary `json:"pendingWorkloadsSummary"`
    33  }
    34  
    35  // +kubebuilder:object:root=true
    36  type ClusterQueueList struct {
    37  	metav1.TypeMeta `json:",inline"`
    38  	metav1.ListMeta `json:"metadata,omitempty"`
    39  
    40  	Items []ClusterQueue `json:"items"`
    41  }
    42  
    43  // +genclient
    44  // +kubebuilder:object:root=true
    45  // +k8s:openapi-gen=true
    46  // +genclient:method=GetPendingWorkloadsSummary,verb=get,subresource=pendingworkloads,result=sigs.k8s.io/kueue/apis/visibility/v1alpha1.PendingWorkloadsSummary
    47  type LocalQueue struct {
    48  	metav1.TypeMeta   `json:",inline"`
    49  	metav1.ObjectMeta `json:"metadata,omitempty"`
    50  
    51  	Summary PendingWorkloadsSummary `json:"pendingWorkloadsSummary"`
    52  }
    53  
    54  // +kubebuilder:object:root=true
    55  type LocalQueueList struct {
    56  	metav1.TypeMeta `json:",inline"`
    57  	metav1.ListMeta `json:"metadata,omitempty"`
    58  
    59  	Items []LocalQueue `json:"items"`
    60  }
    61  
    62  // PendingWorkload is a user-facing representation of a pending workload that summarizes the relevant information for
    63  // position in the cluster queue.
    64  type PendingWorkload struct {
    65  	metav1.ObjectMeta `json:"metadata,omitempty"`
    66  
    67  	// Priority indicates the workload's priority
    68  	Priority int32 `json:"priority"`
    69  
    70  	// LocalQueueName indicates the name of the LocalQueue the workload is submitted to
    71  	LocalQueueName string `json:"localQueueName"`
    72  
    73  	// PositionInClusterQueue indicates the workload's position in the ClusterQueue, starting from 0
    74  	PositionInClusterQueue int32 `json:"positionInClusterQueue"`
    75  
    76  	// PositionInLocalQueue indicates the workload's position in the LocalQueue, starting from 0
    77  	PositionInLocalQueue int32 `json:"positionInLocalQueue"`
    78  }
    79  
    80  // +k8s:openapi-gen=true
    81  // +kubebuilder:object:root=true
    82  
    83  // PendingWorkloadsSummary contains a list of pending workloads in the context
    84  // of the query (within LocalQueue or ClusterQueue).
    85  type PendingWorkloadsSummary struct {
    86  	metav1.TypeMeta   `json:",inline"`
    87  	metav1.ObjectMeta `json:"metadata,omitempty"`
    88  
    89  	Items []PendingWorkload `json:"items"`
    90  }
    91  
    92  // +kubebuilder:object:root=true
    93  type PendingWorkloadsSummaryList struct {
    94  	metav1.TypeMeta `json:",inline"`
    95  	metav1.ListMeta `json:"metadata,omitempty"`
    96  
    97  	Items []PendingWorkloadsSummary `json:"items"`
    98  }
    99  
   100  // +kubebuilder:object:root=true
   101  // +k8s:openapi-gen=true
   102  // +k8s:conversion-gen:explicit-from=net/url.Values
   103  // +k8s:defaulter-gen=true
   104  
   105  // PendingWorkloadOptions are query params used in the visibility queries
   106  type PendingWorkloadOptions struct {
   107  	metav1.TypeMeta `json:",inline"`
   108  
   109  	// Offset indicates position of the first pending workload that should be fetched, starting from 0. 0 by default
   110  	Offset int64 `json:"offset"`
   111  
   112  	// Limit indicates max number of pending workloads that should be fetched. 1000 by default
   113  	Limit int64 `json:"limit,omitempty"`
   114  }
   115  
   116  func init() {
   117  	SchemeBuilder.Register(
   118  		&PendingWorkloadsSummary{},
   119  		&PendingWorkloadOptions{},
   120  	)
   121  }