-
Notifications
You must be signed in to change notification settings - Fork 430
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
[Chore] Fix lint errors caused by casting int to int32 #2368
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -264,14 +264,14 @@ func initLivenessAndReadinessProbe(rayContainer *corev1.Container, rayNodeType r | |
} | ||
|
||
if rayContainer.LivenessProbe == nil { | ||
probeTimeout := utils.DefaultLivenessProbeTimeoutSeconds | ||
probeTimeout := int32(utils.DefaultLivenessProbeTimeoutSeconds) | ||
if rayNodeType == rayv1.HeadNode { | ||
probeTimeout = utils.DefaultHeadLivenessProbeTimeoutSeconds | ||
probeTimeout = int32(utils.DefaultHeadLivenessProbeTimeoutSeconds) | ||
} | ||
|
||
rayContainer.LivenessProbe = &corev1.Probe{ | ||
InitialDelaySeconds: utils.DefaultLivenessProbeInitialDelaySeconds, | ||
TimeoutSeconds: int32(probeTimeout), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The linter is not smart enough to determine whether casting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is not the fault of the linter. Because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can check securego/gosec#1212. The |
||
TimeoutSeconds: probeTimeout, | ||
PeriodSeconds: utils.DefaultLivenessProbePeriodSeconds, | ||
SuccessThreshold: utils.DefaultLivenessProbeSuccessThreshold, | ||
FailureThreshold: utils.DefaultLivenessProbeFailureThreshold, | ||
|
@@ -280,13 +280,13 @@ func initLivenessAndReadinessProbe(rayContainer *corev1.Container, rayNodeType r | |
} | ||
|
||
if rayContainer.ReadinessProbe == nil { | ||
probeTimeout := utils.DefaultReadinessProbeTimeoutSeconds | ||
probeTimeout := int32(utils.DefaultReadinessProbeTimeoutSeconds) | ||
if rayNodeType == rayv1.HeadNode { | ||
probeTimeout = utils.DefaultHeadReadinessProbeTimeoutSeconds | ||
probeTimeout = int32(utils.DefaultHeadReadinessProbeTimeoutSeconds) | ||
} | ||
rayContainer.ReadinessProbe = &corev1.Probe{ | ||
InitialDelaySeconds: utils.DefaultReadinessProbeInitialDelaySeconds, | ||
TimeoutSeconds: int32(probeTimeout), | ||
TimeoutSeconds: probeTimeout, | ||
PeriodSeconds: utils.DefaultReadinessProbePeriodSeconds, | ||
SuccessThreshold: utils.DefaultReadinessProbeSuccessThreshold, | ||
FailureThreshold: utils.DefaultReadinessProbeFailureThreshold, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -769,21 +769,20 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv | |
if worker.NumOfHosts <= 0 { | ||
worker.NumOfHosts = 1 | ||
} | ||
numExpectedPods := workerReplicas * worker.NumOfHosts | ||
numExpectedPods := int(workerReplicas * worker.NumOfHosts) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Converting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code is doing the opposite, it converts to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, it is a typo in my comment. |
||
|
||
if len(runningPods.Items) > math.MaxInt32 { | ||
return errstd.New("len(runningPods.Items) exceeds math.MaxInt32") | ||
} | ||
kevin85421 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
diff := numExpectedPods - int32(len(runningPods.Items)) //nolint:gosec // Already checked in the previous line. | ||
diff := numExpectedPods - len(runningPods.Items) | ||
|
||
logger.Info("reconcilePods", "workerReplicas", workerReplicas, "NumOfHosts", worker.NumOfHosts, "runningPods", len(runningPods.Items), "diff", diff) | ||
|
||
if diff > 0 { | ||
// pods need to be added | ||
logger.Info("reconcilePods", "Number workers to add", diff, "Worker group", worker.GroupName) | ||
// create all workers of this group | ||
var i int32 | ||
for i = 0; i < diff; i++ { | ||
for i := 0; i < diff; i++ { | ||
logger.Info("reconcilePods", "creating worker for group", worker.GroupName, fmt.Sprintf("index %d", i), fmt.Sprintf("in total %d", diff)) | ||
if err := r.createWorkerPod(ctx, *instance, *worker.DeepCopy()); err != nil { | ||
return errstd.Join(utils.ErrFailedCreateWorkerPod, err) | ||
|
@@ -814,7 +813,7 @@ func (r *RayClusterReconciler) reconcilePods(ctx context.Context, instance *rayv | |
// diff < 0 means that we need to delete some Pods to meet the desired number of replicas. | ||
randomlyRemovedWorkers := -diff | ||
logger.Info("reconcilePods", "Number workers to delete randomly", randomlyRemovedWorkers, "Worker group", worker.GroupName) | ||
for i := 0; i < int(randomlyRemovedWorkers); i++ { | ||
for i := 0; i < randomlyRemovedWorkers; i++ { | ||
randomPodToDelete := runningPods.Items[i] | ||
logger.Info("Randomly deleting Pod", "progress", fmt.Sprintf("%d / %d", i+1, randomlyRemovedWorkers), "with name", randomPodToDelete.Name) | ||
if err := r.Delete(ctx, &randomPodToDelete); err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
G115 is reporting false negatives, and the gosec community still hasn't reached a final conclusion. Therefore, I’ve decided to disable it by default: securego/gosec#1212.