Skip to content

Commit fb58429

Browse files
authored
[Chore] Fix lint errors caused by casting int to int32 (#2368)
1 parent 22c2b45 commit fb58429

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

ray-operator/controllers/ray/common/pod.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,14 @@ func initLivenessAndReadinessProbe(rayContainer *corev1.Container, rayNodeType r
264264
}
265265

266266
if rayContainer.LivenessProbe == nil {
267-
probeTimeout := utils.DefaultLivenessProbeTimeoutSeconds
267+
probeTimeout := int32(utils.DefaultLivenessProbeTimeoutSeconds)
268268
if rayNodeType == rayv1.HeadNode {
269-
probeTimeout = utils.DefaultHeadLivenessProbeTimeoutSeconds
269+
probeTimeout = int32(utils.DefaultHeadLivenessProbeTimeoutSeconds)
270270
}
271271

272272
rayContainer.LivenessProbe = &corev1.Probe{
273273
InitialDelaySeconds: utils.DefaultLivenessProbeInitialDelaySeconds,
274-
TimeoutSeconds: int32(probeTimeout),
274+
TimeoutSeconds: probeTimeout,
275275
PeriodSeconds: utils.DefaultLivenessProbePeriodSeconds,
276276
SuccessThreshold: utils.DefaultLivenessProbeSuccessThreshold,
277277
FailureThreshold: utils.DefaultLivenessProbeFailureThreshold,
@@ -280,13 +280,13 @@ func initLivenessAndReadinessProbe(rayContainer *corev1.Container, rayNodeType r
280280
}
281281

282282
if rayContainer.ReadinessProbe == nil {
283-
probeTimeout := utils.DefaultReadinessProbeTimeoutSeconds
283+
probeTimeout := int32(utils.DefaultReadinessProbeTimeoutSeconds)
284284
if rayNodeType == rayv1.HeadNode {
285-
probeTimeout = utils.DefaultHeadReadinessProbeTimeoutSeconds
285+
probeTimeout = int32(utils.DefaultHeadReadinessProbeTimeoutSeconds)
286286
}
287287
rayContainer.ReadinessProbe = &corev1.Probe{
288288
InitialDelaySeconds: utils.DefaultReadinessProbeInitialDelaySeconds,
289-
TimeoutSeconds: int32(probeTimeout),
289+
TimeoutSeconds: probeTimeout,
290290
PeriodSeconds: utils.DefaultReadinessProbePeriodSeconds,
291291
SuccessThreshold: utils.DefaultReadinessProbeSuccessThreshold,
292292
FailureThreshold: utils.DefaultReadinessProbeFailureThreshold,

ray-operator/controllers/ray/raycluster_controller.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
errstd "errors"
66
"fmt"
7-
"math"
87
"os"
98
"reflect"
109
"runtime"
@@ -769,21 +768,16 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv
769768
if worker.NumOfHosts <= 0 {
770769
worker.NumOfHosts = 1
771770
}
772-
numExpectedPods := workerReplicas * worker.NumOfHosts
773-
774-
if len(runningPods.Items) > math.MaxInt32 {
775-
return errstd.New("len(runningPods.Items) exceeds math.MaxInt32")
776-
}
777-
diff := numExpectedPods - int32(len(runningPods.Items)) //nolint:gosec // Already checked in the previous line.
771+
numExpectedPods := int(workerReplicas * worker.NumOfHosts)
772+
diff := numExpectedPods - len(runningPods.Items)
778773

779774
logger.Info("reconcilePods", "workerReplicas", workerReplicas, "NumOfHosts", worker.NumOfHosts, "runningPods", len(runningPods.Items), "diff", diff)
780775

781776
if diff > 0 {
782777
// pods need to be added
783778
logger.Info("reconcilePods", "Number workers to add", diff, "Worker group", worker.GroupName)
784779
// create all workers of this group
785-
var i int32
786-
for i = 0; i < diff; i++ {
780+
for i := 0; i < diff; i++ {
787781
logger.Info("reconcilePods", "creating worker for group", worker.GroupName, fmt.Sprintf("index %d", i), fmt.Sprintf("in total %d", diff))
788782
if err := r.createWorkerPod(ctx, *instance, *worker.DeepCopy()); err != nil {
789783
return errstd.Join(utils.ErrFailedCreateWorkerPod, err)
@@ -814,7 +808,7 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv
814808
// diff < 0 means that we need to delete some Pods to meet the desired number of replicas.
815809
randomlyRemovedWorkers := -diff
816810
logger.Info("reconcilePods", "Number workers to delete randomly", randomlyRemovedWorkers, "Worker group", worker.GroupName)
817-
for i := 0; i < int(randomlyRemovedWorkers); i++ {
811+
for i := 0; i < randomlyRemovedWorkers; i++ {
818812
randomPodToDelete := runningPods.Items[i]
819813
logger.Info("Randomly deleting Pod", "progress", fmt.Sprintf("%d / %d", i+1, randomlyRemovedWorkers), "with name", randomPodToDelete.Name)
820814
if err := r.Delete(ctx, &randomPodToDelete); err != nil {

ray-operator/controllers/ray/rayservice_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func (r *RayServiceReconciler) calculateStatus(ctx context.Context, rayServiceIn
251251
if numServeEndpoints > math.MaxInt32 {
252252
return errstd.New("numServeEndpoints exceeds math.MaxInt32")
253253
}
254-
rayServiceInstance.Status.NumServeEndpoints = int32(numServeEndpoints) //nolint:gosec // Already checked in the previous line.
254+
rayServiceInstance.Status.NumServeEndpoints = int32(numServeEndpoints) //nolint:gosec // This is a false positive from gosec. See https://github.com/securego/gosec/issues/1212 for more details.
255255
return nil
256256
}
257257

0 commit comments

Comments
 (0)