Skip to content

Commit a43217b

Browse files
[Style] Fix golangci-lint rule: govet (#2144)
1 parent 828afba commit a43217b

29 files changed

+560
-562
lines changed

docs/reference/api.md

Lines changed: 38 additions & 38 deletions
Large diffs are not rendered by default.

ray-operator/.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ linters:
6767
- goimports
6868
- gosec
6969
- gosimple
70-
# - govet
70+
- govet
7171
- ineffassign
7272
# - lll
7373
- makezero

ray-operator/apis/config/v1alpha1/configuration_types.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ type Configuration struct {
2828
// resources live. Defaults to the pod namesapce if not set.
2929
LeaderElectionNamespace string `json:"leaderElectionNamespace,omitempty"`
3030

31-
// ReconcileConcurrency is the max concurrency for each reconciler.
32-
ReconcileConcurrency int `json:"reconcileConcurrency,omitempty"`
33-
3431
// WatchNamespace specifies a list of namespaces to watch for custom resources, separated by commas.
3532
// If empty, all namespaces will be watched.
3633
WatchNamespace string `json:"watchNamespace,omitempty"`
@@ -46,6 +43,17 @@ type Configuration struct {
4643
// Defaults to `json` if empty.
4744
LogStdoutEncoder string `json:"logStdoutEncoder,omitempty"`
4845

46+
// HeadSidecarContainers includes specification for a sidecar container
47+
// to inject into every Head pod.
48+
HeadSidecarContainers []corev1.Container `json:"headSidecarContainers,omitempty"`
49+
50+
// WorkerSidecarContainers includes specification for a sidecar container
51+
// to inject into every Worker pod.
52+
WorkerSidecarContainers []corev1.Container `json:"workerSidecarContainers,omitempty"`
53+
54+
// ReconcileConcurrency is the max concurrency for each reconciler.
55+
ReconcileConcurrency int `json:"reconcileConcurrency,omitempty"`
56+
4957
// EnableBatchScheduler enables the batch scheduler. Currently this is supported
5058
// by Volcano to support gang scheduling.
5159
EnableBatchScheduler bool `json:"enableBatchScheduler,omitempty"`
@@ -55,14 +63,6 @@ type Configuration struct {
5563
// ingress traffic to the Ray cluster from other pods or Kuberay is running in a network without
5664
// connectivity to Pods.
5765
UseKubernetesProxy bool `json:"useKubernetesProxy,omitempty"`
58-
59-
// HeadSidecarContainers includes specification for a sidecar container
60-
// to inject into every Head pod.
61-
HeadSidecarContainers []corev1.Container `json:"headSidecarContainers,omitempty"`
62-
63-
// WorkerSidecarContainers includes specification for a sidecar container
64-
// to inject into every Worker pod.
65-
WorkerSidecarContainers []corev1.Container `json:"workerSidecarContainers,omitempty"`
6666
}
6767

6868
func (config Configuration) GetDashboardClient(mgr manager.Manager) func() utils.RayDashboardClientInterface {

ray-operator/apis/ray/v1/raycluster_types.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ import (
1111

1212
// RayClusterSpec defines the desired state of RayCluster
1313
type RayClusterSpec struct {
14+
// Suspend indicates whether a RayCluster should be suspended.
15+
// A suspended RayCluster will have head pods and worker pods deleted.
16+
Suspend *bool `json:"suspend,omitempty"`
17+
// AutoscalerOptions specifies optional configuration for the Ray autoscaler.
18+
AutoscalerOptions *AutoscalerOptions `json:"autoscalerOptions,omitempty"`
19+
HeadServiceAnnotations map[string]string `json:"headServiceAnnotations,omitempty"`
20+
// EnableInTreeAutoscaling indicates whether operator should create in tree autoscaling configs
21+
EnableInTreeAutoscaling *bool `json:"enableInTreeAutoscaling,omitempty"`
1422
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
1523
// Important: Run "make" to regenerate code after modifying this file
1624
// HeadGroupSpecs are the spec for the head pod
1725
HeadGroupSpec HeadGroupSpec `json:"headGroupSpec"`
18-
// WorkerGroupSpecs are the specs for the worker pods
19-
WorkerGroupSpecs []WorkerGroupSpec `json:"workerGroupSpecs,omitempty"`
2026
// RayVersion is used to determine the command for the Kubernetes Job managed by RayJob
2127
RayVersion string `json:"rayVersion,omitempty"`
22-
// EnableInTreeAutoscaling indicates whether operator should create in tree autoscaling configs
23-
EnableInTreeAutoscaling *bool `json:"enableInTreeAutoscaling,omitempty"`
24-
// AutoscalerOptions specifies optional configuration for the Ray autoscaler.
25-
AutoscalerOptions *AutoscalerOptions `json:"autoscalerOptions,omitempty"`
26-
HeadServiceAnnotations map[string]string `json:"headServiceAnnotations,omitempty"`
27-
// Suspend indicates whether a RayCluster should be suspended.
28-
// A suspended RayCluster will have head pods and worker pods deleted.
29-
Suspend *bool `json:"suspend,omitempty"`
28+
// WorkerGroupSpecs are the specs for the worker pods
29+
WorkerGroupSpecs []WorkerGroupSpec `json:"workerGroupSpecs,omitempty"`
3030
}
3131

3232
// HeadGroupSpec are the spec for the head pod
@@ -56,15 +56,15 @@ type WorkerGroupSpec struct {
5656
// MaxReplicas denotes the maximum number of desired Pods for this worker group, and the default value is maxInt32.
5757
// +kubebuilder:default:=2147483647
5858
MaxReplicas *int32 `json:"maxReplicas"`
59-
// NumOfHosts denotes the number of hosts to create per replica. The default value is 1.
60-
// +kubebuilder:default:=1
61-
NumOfHosts int32 `json:"numOfHosts,omitempty"`
6259
// RayStartParams are the params of the start command: address, object-store-memory, ...
6360
RayStartParams map[string]string `json:"rayStartParams"`
6461
// Template is a pod template for the worker
6562
Template corev1.PodTemplateSpec `json:"template"`
6663
// ScaleStrategy defines which pods to remove
6764
ScaleStrategy ScaleStrategy `json:"scaleStrategy,omitempty"`
65+
// NumOfHosts denotes the number of hosts to create per replica. The default value is 1.
66+
// +kubebuilder:default:=1
67+
NumOfHosts int32 `json:"numOfHosts,omitempty"`
6868
}
6969

7070
// ScaleStrategy to remove workers
@@ -82,12 +82,6 @@ type AutoscalerOptions struct {
8282
Image *string `json:"image,omitempty"`
8383
// ImagePullPolicy optionally overrides the autoscaler container's image pull policy. This override is for provided for autoscaler testing and development.
8484
ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"`
85-
// Optional list of environment variables to set in the autoscaler container.
86-
Env []corev1.EnvVar `json:"env,omitempty"`
87-
// Optional list of sources to populate environment variables in the autoscaler container.
88-
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
89-
// Optional list of volumeMounts. This is needed for enabling TLS for the autoscaler container.
90-
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
9185
// SecurityContext defines the security options the container should be run with.
9286
// If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext.
9387
// More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
@@ -101,6 +95,12 @@ type AutoscalerOptions struct {
10195
// Aggressive: An alias for Default; upscaling is not rate-limited.
10296
// It is not read by the KubeRay operator but by the Ray autoscaler.
10397
UpscalingMode *UpscalingMode `json:"upscalingMode,omitempty"`
98+
// Optional list of environment variables to set in the autoscaler container.
99+
Env []corev1.EnvVar `json:"env,omitempty"`
100+
// Optional list of sources to populate environment variables in the autoscaler container.
101+
EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`
102+
// Optional list of volumeMounts. This is needed for enabling TLS for the autoscaler container.
103+
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
104104
}
105105

106106
// +kubebuilder:validation:Enum=Default;Aggressive;Conservative
@@ -121,16 +121,6 @@ type RayClusterStatus struct {
121121
// Important: Run "make" to regenerate code after modifying this file
122122
// Status reflects the status of the cluster
123123
State ClusterState `json:"state,omitempty"`
124-
// ReadyWorkerReplicas indicates how many worker replicas are ready in the cluster
125-
ReadyWorkerReplicas int32 `json:"readyWorkerReplicas,omitempty"`
126-
// AvailableWorkerReplicas indicates how many replicas are available in the cluster
127-
AvailableWorkerReplicas int32 `json:"availableWorkerReplicas,omitempty"`
128-
// DesiredWorkerReplicas indicates overall desired replicas claimed by the user at the cluster level.
129-
DesiredWorkerReplicas int32 `json:"desiredWorkerReplicas,omitempty"`
130-
// MinWorkerReplicas indicates sum of minimum replicas of each node group.
131-
MinWorkerReplicas int32 `json:"minWorkerReplicas,omitempty"`
132-
// MaxWorkerReplicas indicates sum of maximum replicas of each node group.
133-
MaxWorkerReplicas int32 `json:"maxWorkerReplicas,omitempty"`
134124
// DesiredCPU indicates total desired CPUs for the cluster
135125
DesiredCPU resource.Quantity `json:"desiredCPU,omitempty"`
136126
// DesiredMemory indicates total desired memory for the cluster
@@ -150,6 +140,16 @@ type RayClusterStatus struct {
150140
Head HeadInfo `json:"head,omitempty"`
151141
// Reason provides more information about current State
152142
Reason string `json:"reason,omitempty"`
143+
// ReadyWorkerReplicas indicates how many worker replicas are ready in the cluster
144+
ReadyWorkerReplicas int32 `json:"readyWorkerReplicas,omitempty"`
145+
// AvailableWorkerReplicas indicates how many replicas are available in the cluster
146+
AvailableWorkerReplicas int32 `json:"availableWorkerReplicas,omitempty"`
147+
// DesiredWorkerReplicas indicates overall desired replicas claimed by the user at the cluster level.
148+
DesiredWorkerReplicas int32 `json:"desiredWorkerReplicas,omitempty"`
149+
// MinWorkerReplicas indicates sum of minimum replicas of each node group.
150+
MinWorkerReplicas int32 `json:"minWorkerReplicas,omitempty"`
151+
// MaxWorkerReplicas indicates sum of maximum replicas of each node group.
152+
MaxWorkerReplicas int32 `json:"maxWorkerReplicas,omitempty"`
153153
// observedGeneration is the most recent generation observed for this RayCluster. It corresponds to the
154154
// RayCluster's generation, which is updated on mutation by the API Server.
155155
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

ray-operator/apis/ray/v1/rayjob_types.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,51 +66,51 @@ type SubmitterConfig struct {
6666

6767
// RayJobSpec defines the desired state of RayJob
6868
type RayJobSpec struct {
69+
// ActiveDeadlineSeconds is the duration in seconds that the RayJob may be active before
70+
// KubeRay actively tries to terminate the RayJob; value must be positive integer.
71+
ActiveDeadlineSeconds *int32 `json:"activeDeadlineSeconds,omitempty"`
72+
// RayClusterSpec is the cluster template to run the job
73+
RayClusterSpec *RayClusterSpec `json:"rayClusterSpec,omitempty"`
74+
// SubmitterPodTemplate is the template for the pod that will run `ray job submit`.
75+
SubmitterPodTemplate *corev1.PodTemplateSpec `json:"submitterPodTemplate,omitempty"`
76+
// Metadata is data to store along with this job.
77+
Metadata map[string]string `json:"metadata,omitempty"`
78+
// clusterSelector is used to select running rayclusters by labels
79+
ClusterSelector map[string]string `json:"clusterSelector,omitempty"`
80+
// Configurations of submitter k8s job.
81+
SubmitterConfig *SubmitterConfig `json:"submitterConfig,omitempty"`
6982
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
7083
// Important: Run "make" to regenerate code after modifying this file
7184
Entrypoint string `json:"entrypoint"`
72-
// Metadata is data to store along with this job.
73-
Metadata map[string]string `json:"metadata,omitempty"`
7485
// RuntimeEnvYAML represents the runtime environment configuration
7586
// provided as a multi-line YAML string.
7687
RuntimeEnvYAML string `json:"runtimeEnvYAML,omitempty"`
7788
// If jobId is not set, a new jobId will be auto-generated.
7889
JobId string `json:"jobId,omitempty"`
79-
// ShutdownAfterJobFinishes will determine whether to delete the ray cluster once rayJob succeed or failed.
80-
ShutdownAfterJobFinishes bool `json:"shutdownAfterJobFinishes,omitempty"`
81-
// TTLSecondsAfterFinished is the TTL to clean up RayCluster.
82-
// It's only working when ShutdownAfterJobFinishes set to true.
83-
// +kubebuilder:default:=0
84-
TTLSecondsAfterFinished int32 `json:"ttlSecondsAfterFinished,omitempty"`
85-
// ActiveDeadlineSeconds is the duration in seconds that the RayJob may be active before
86-
// KubeRay actively tries to terminate the RayJob; value must be positive integer.
87-
ActiveDeadlineSeconds *int32 `json:"activeDeadlineSeconds,omitempty"`
88-
// RayClusterSpec is the cluster template to run the job
89-
RayClusterSpec *RayClusterSpec `json:"rayClusterSpec,omitempty"`
90-
// clusterSelector is used to select running rayclusters by labels
91-
ClusterSelector map[string]string `json:"clusterSelector,omitempty"`
9290
// SubmissionMode specifies how RayJob submits the Ray job to the RayCluster.
9391
// In "K8sJobMode", the KubeRay operator creates a submitter Kubernetes Job to submit the Ray job.
9492
// In "HTTPMode", the KubeRay operator sends a request to the RayCluster to create a Ray job.
9593
// +kubebuilder:default:=K8sJobMode
9694
SubmissionMode JobSubmissionMode `json:"submissionMode,omitempty"`
95+
// EntrypointResources specifies the custom resources and quantities to reserve for the
96+
// entrypoint command.
97+
EntrypointResources string `json:"entrypointResources,omitempty"`
98+
// EntrypointNumCpus specifies the number of cpus to reserve for the entrypoint command.
99+
EntrypointNumCpus float32 `json:"entrypointNumCpus,omitempty"`
100+
// EntrypointNumGpus specifies the number of gpus to reserve for the entrypoint command.
101+
EntrypointNumGpus float32 `json:"entrypointNumGpus,omitempty"`
102+
// TTLSecondsAfterFinished is the TTL to clean up RayCluster.
103+
// It's only working when ShutdownAfterJobFinishes set to true.
104+
// +kubebuilder:default:=0
105+
TTLSecondsAfterFinished int32 `json:"ttlSecondsAfterFinished,omitempty"`
106+
// ShutdownAfterJobFinishes will determine whether to delete the ray cluster once rayJob succeed or failed.
107+
ShutdownAfterJobFinishes bool `json:"shutdownAfterJobFinishes,omitempty"`
97108
// suspend specifies whether the RayJob controller should create a RayCluster instance
98109
// If a job is applied with the suspend field set to true,
99110
// the RayCluster will not be created and will wait for the transition to false.
100111
// If the RayCluster is already created, it will be deleted.
101112
// In case of transition to false a new RayCluster will be created.
102113
Suspend bool `json:"suspend,omitempty"`
103-
// SubmitterPodTemplate is the template for the pod that will run `ray job submit`.
104-
SubmitterPodTemplate *corev1.PodTemplateSpec `json:"submitterPodTemplate,omitempty"`
105-
// EntrypointNumCpus specifies the number of cpus to reserve for the entrypoint command.
106-
EntrypointNumCpus float32 `json:"entrypointNumCpus,omitempty"`
107-
// EntrypointNumGpus specifies the number of gpus to reserve for the entrypoint command.
108-
EntrypointNumGpus float32 `json:"entrypointNumGpus,omitempty"`
109-
// EntrypointResources specifies the custom resources and quantities to reserve for the
110-
// entrypoint command.
111-
EntrypointResources string `json:"entrypointResources,omitempty"`
112-
// Configurations of submitter k8s job.
113-
SubmitterConfig *SubmitterConfig `json:"submitterConfig,omitempty"`
114114
}
115115

116116
// RayJobStatus defines the observed state of RayJob

ray-operator/apis/ray/v1/rayservice_types.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,33 +51,33 @@ var DeploymentStatusEnum = struct {
5151

5252
// RayServiceSpec defines the desired state of RayService
5353
type RayServiceSpec struct {
54-
// Important: Run "make" to regenerate code after modifying this file
55-
// Defines the applications and deployments to deploy, should be a YAML multi-line scalar string.
56-
ServeConfigV2 string `json:"serveConfigV2,omitempty"`
57-
RayClusterSpec RayClusterSpec `json:"rayClusterConfig,omitempty"`
5854
// Deprecated: This field is not used anymore. ref: https://github.com/ray-project/kuberay/issues/1685
5955
ServiceUnhealthySecondThreshold *int32 `json:"serviceUnhealthySecondThreshold,omitempty"`
6056
// Deprecated: This field is not used anymore. ref: https://github.com/ray-project/kuberay/issues/1685
6157
DeploymentUnhealthySecondThreshold *int32 `json:"deploymentUnhealthySecondThreshold,omitempty"`
6258
// ServeService is the Kubernetes service for head node and worker nodes who have healthy http proxy to serve traffics.
6359
ServeService *corev1.Service `json:"serveService,omitempty"`
60+
// Important: Run "make" to regenerate code after modifying this file
61+
// Defines the applications and deployments to deploy, should be a YAML multi-line scalar string.
62+
ServeConfigV2 string `json:"serveConfigV2,omitempty"`
63+
RayClusterSpec RayClusterSpec `json:"rayClusterConfig,omitempty"`
6464
}
6565

6666
// RayServiceStatuses defines the observed state of RayService
6767
type RayServiceStatuses struct {
68+
// LastUpdateTime represents the timestamp when the RayService status was last updated.
69+
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
70+
// ServiceStatus indicates the current RayService status.
71+
ServiceStatus ServiceStatus `json:"serviceStatus,omitempty"`
6872
ActiveServiceStatus RayServiceStatus `json:"activeServiceStatus,omitempty"`
6973
// Pending Service Status indicates a RayCluster will be created or is being created.
7074
PendingServiceStatus RayServiceStatus `json:"pendingServiceStatus,omitempty"`
71-
// ServiceStatus indicates the current RayService status.
72-
ServiceStatus ServiceStatus `json:"serviceStatus,omitempty"`
7375
// NumServeEndpoints indicates the number of Ray Pods that are actively serving or have been selected by the serve service.
7476
// Ray Pods without a proxy actor or those that are unhealthy will not be counted.
7577
NumServeEndpoints int32 `json:"numServeEndpoints,omitempty"`
7678
// observedGeneration is the most recent generation observed for this RayService. It corresponds to the
7779
// RayService's generation, which is updated on mutation by the API Server.
7880
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
79-
// LastUpdateTime represents the timestamp when the RayService status was last updated.
80-
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
8181
}
8282

8383
type RayServiceStatus struct {
@@ -88,23 +88,23 @@ type RayServiceStatus struct {
8888
}
8989

9090
type AppStatus struct {
91-
Status string `json:"status,omitempty"`
92-
Message string `json:"message,omitempty"`
9391
// Keep track of how long the service is healthy.
9492
// Update when Serve deployment is healthy or first time convert to unhealthy from healthy.
9593
HealthLastUpdateTime *metav1.Time `json:"healthLastUpdateTime,omitempty"`
9694
Deployments map[string]ServeDeploymentStatus `json:"serveDeploymentStatuses,omitempty"`
95+
Status string `json:"status,omitempty"`
96+
Message string `json:"message,omitempty"`
9797
}
9898

9999
// ServeDeploymentStatus defines the current state of a Serve deployment
100100
type ServeDeploymentStatus struct {
101+
// Keep track of how long the service is healthy.
102+
// Update when Serve deployment is healthy or first time convert to unhealthy from healthy.
103+
HealthLastUpdateTime *metav1.Time `json:"healthLastUpdateTime,omitempty"`
101104
// Name, Status, Message are from Ray Dashboard and represent a Serve deployment's state.
102105
// TODO: change status type to enum
103106
Status string `json:"status,omitempty"`
104107
Message string `json:"message,omitempty"`
105-
// Keep track of how long the service is healthy.
106-
// Update when Serve deployment is healthy or first time convert to unhealthy from healthy.
107-
HealthLastUpdateTime *metav1.Time `json:"healthLastUpdateTime,omitempty"`
108108
}
109109

110110
// +kubebuilder:object:root=true

0 commit comments

Comments
 (0)