Skip to content
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

🌱 Bump golangci to v1.60.2 #11132

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

mcbenjemaa
Copy link
Member

What this PR does / why we need it:
This PR bumps golang-ci to v1.60.2,
a lot of false positive issues have appeared, therefore i deal with them.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #11075

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 3, 2024
@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area PR is missing an area label size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 3, 2024
@mcbenjemaa
Copy link
Member Author

/area ci

@k8s-ci-robot k8s-ci-robot added area/ci Issues or PRs related to ci and removed do-not-merge/needs-area PR is missing an area label labels Sep 3, 2024
@mcbenjemaa mcbenjemaa changed the title Bump golangci to v1.60.2 🌱 Bump golangci to v1.60.2 Sep 3, 2024
.golangci.yml Outdated Show resolved Hide resolved
.golangci.yml Show resolved Hide resolved
.golangci.yml Outdated Show resolved Hide resolved
@mcbenjemaa
Copy link
Member Author

I also had this linter issues by gosec:

exp/internal/webhooks/machinepool.go:255:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
exp/internal/webhooks/machinepool.go:269:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
exp/internal/webhooks/machinepool.go:272:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMP.Spec.Replicas < int32(minSize):
                                                 ^
exp/internal/webhooks/machinepool.go:276:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
exp/internal/webhooks/machinepool.go:279:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMP.Spec.Replicas > int32(maxSize):
                                                 ^
exp/internal/webhooks/machinepool.go:283:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(maxSize), nil
                                    ^
internal/controllers/machinedeployment/mdutil/util.go:187:14: G115: integer overflow conversion int64 -> int32 (gosec)
        return int32(intValue), true
                    ^
internal/controllers/machinedeployment/mdutil/util.go:576:58: G115: integer overflow conversion int -> int32 (gosec)
                maxTotalMachines := *(deployment.Spec.Replicas) + int32(maxSurge)
                                                                       ^
internal/controllers/machinedeployment/mdutil/util.go:616:8: G115: integer overflow conversion int64 -> int32 (gosec)
                int32(desired) == *(deployment.Spec.Replicas) &&
                     ^
internal/controllers/machinedeployment/mdutil/util.go:647:14: G115: integer overflow conversion int -> int32 (gosec)
        return int32(surge), int32(unavailable), nil
                    ^
internal/webhooks/machinedeployment.go:355:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machinedeployment.go:369:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machinedeployment.go:372:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMD.Spec.Replicas < int32(minSize):
                                                 ^
internal/webhooks/machinedeployment.go:376:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machinedeployment.go:379:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMD.Spec.Replicas > int32(maxSize):
                                                 ^
internal/webhooks/machinedeployment.go:383:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(maxSize), nil
                                    ^
internal/webhooks/machineset.go:308:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machineset.go:322:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machineset.go:325:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMS.Spec.Replicas < int32(minSize):
                                                 ^
internal/webhooks/machineset.go:329:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machineset.go:332:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMS.Spec.Replicas > int32(maxSize):
                                                 ^
internal/webhooks/machineset.go:336:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(maxSize), nil
                                    ^
exp/internal/controllers/machinepool_controller_noderef.go:104:33: G115: integer overflow conversion int -> int32 (gosec)
        mp.Status.ReadyReplicas = int32(nodeRefsResult.ready)
                                       ^
exp/internal/controllers/machinepool_controller_noderef.go:105:37: G115: integer overflow conversion int -> int32 (gosec)
        mp.Status.AvailableReplicas = int32(nodeRefsResult.available)
                                           ^
exp/internal/controllers/machinepool_controller_phases_test.go:2089:36: G115: integer overflow conversion int -> int32 (gosec)
                        Replicas:    ptr.To[int32](int32(replicas)),
                                                        ^
internal/controllers/topology/cluster/cluster_controller_test.go:966:11: G115: integer overflow conversion int64 -> int32 (gosec)
                if int32(*replicas) != *cluster.Spec.Topology.ControlPlane.Replicas {
                        ^
internal/controllers/topology/cluster/cluster_controller_test.go:967:67: G115: integer overflow conversion int64 -> int32 (gosec)
                        return fmt.Errorf("replicas %v do not match expected %v", int32(*replicas), *cluster.Spec.Topology.ControlPlane.Replicas)
                                                                                       ^
controlplane/kubeadm/internal/controllers/remediation.go:503:20: G115: integer overflow conversion int -> int32 (gosec)
                RetryCount: int32(r.RetryCount),
                                 ^
controlplane/kubeadm/internal/controllers/status.go:43:49: G115: integer overflow conversion int -> int32 (gosec)
        controlPlane.KCP.Status.UpdatedReplicas = int32(len(upToDateMachines))
                                                       ^
controlplane/kubeadm/internal/controllers/status.go:45:19: G115: integer overflow conversion int -> int32 (gosec)
        replicas := int32(len(controlPlane.Machines))
                         ^
controlplane/kubeadm/internal/controllers/status.go:80:11: G115: integer overflow conversion int -> int32 (gosec)
                if int32(len(readyMachines)) == replicas {
                        ^
controlplane/kubeadm/internal/controllers/upgrade.go:121:54: G115: integer overflow conversion int -> int32 (gosec)
                maxNodes := *controlPlane.KCP.Spec.Replicas + int32(controlPlane.KCP.Spec.RolloutStrategy.RollingUpdate.MaxSurge.IntValue())
                                                                   ^
controlplane/kubeadm/internal/controllers/upgrade.go:122:11: G115: integer overflow conversion int -> int32 (gosec)
                if int32(controlPlane.Machines.Len()) < maxNodes {
                        ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:221:35: G115: integer overflow conversion int -> int32 (gosec)
        m.Status.ExpectedMachines = int32(totalTargets)
                                         ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:236:33: G115: integer overflow conversion int -> int32 (gosec)
        m.Status.CurrentHealthy = int32(len(healthy))
                                       ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:589:27: G115: integer overflow conversion int -> int32 (gosec)
                remediationCount = int32(maxVal - unhealthyMachineCount)
                                        ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:601:26: G115: integer overflow conversion int -> int32 (gosec)
        remediationCount = int32(maxUnhealthy - unhealthyMachineCount)
                                ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:627:12: G115: integer overflow conversion uint64 -> int (gosec)
        return int(minVal), int(maxVal), nil
                  ^
internal/controllers/machinedeployment/machinedeployment_rollout_ondelete.go:122:29: G115: integer overflow conversion int -> int32 (gosec)
                totalMachineCount := int32(len(allMachinesInOldMS.Items))
                                          ^
internal/controllers/machinedeployment/machinedeployment_sync.go:612:15: G115: integer overflow conversion int -> int32 (gosec)
        diff := int32(len(cleanableMSes)) - *deployment.Spec.RevisionHistoryLimit
                     ^
internal/controllers/machineset/machineset_controller.go:952:28: G115: integer overflow conversion int -> int32 (gosec)
        newStatus.Replicas = int32(len(filteredMachines))
                                  ^
internal/controllers/machineset/machineset_controller.go:953:40: G115: integer overflow conversion int -> int32 (gosec)
        newStatus.FullyLabeledReplicas = int32(fullyLabeledReplicasCount)
                                              ^
internal/controllers/machineset/machineset_controller.go:954:33: G115: integer overflow conversion int -> int32 (gosec)
        newStatus.ReadyReplicas = int32(readyReplicasCount)
                                       ^
internal/controllers/machineset/machineset_controller.go:955:37: G115: integer overflow conversion int -> int32 (gosec)
        newStatus.AvailableReplicas = int32(availableReplicasCount)
                                           ^
internal/controllers/machineset/machineset_controller_test.go:1718:49: G115: integer overflow conversion int -> int32 (gosec)
                                                MaxInFlight: ptr.To(intstr.FromInt32(int32(maxInFlight))),
                                                                                          ^

Should I do the same?

@mcbenjemaa
Copy link
Member Author

I also had this linter issues by gosec:

exp/internal/webhooks/machinepool.go:255:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
exp/internal/webhooks/machinepool.go:269:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
exp/internal/webhooks/machinepool.go:272:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMP.Spec.Replicas < int32(minSize):
                                                 ^
exp/internal/webhooks/machinepool.go:276:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
exp/internal/webhooks/machinepool.go:279:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMP.Spec.Replicas > int32(maxSize):
                                                 ^
exp/internal/webhooks/machinepool.go:283:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(maxSize), nil
                                    ^
internal/controllers/machinedeployment/mdutil/util.go:187:14: G115: integer overflow conversion int64 -> int32 (gosec)
        return int32(intValue), true
                    ^
internal/controllers/machinedeployment/mdutil/util.go:576:58: G115: integer overflow conversion int -> int32 (gosec)
                maxTotalMachines := *(deployment.Spec.Replicas) + int32(maxSurge)
                                                                       ^
internal/controllers/machinedeployment/mdutil/util.go:616:8: G115: integer overflow conversion int64 -> int32 (gosec)
                int32(desired) == *(deployment.Spec.Replicas) &&
                     ^
internal/controllers/machinedeployment/mdutil/util.go:647:14: G115: integer overflow conversion int -> int32 (gosec)
        return int32(surge), int32(unavailable), nil
                    ^
internal/webhooks/machinedeployment.go:355:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machinedeployment.go:369:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machinedeployment.go:372:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMD.Spec.Replicas < int32(minSize):
                                                 ^
internal/webhooks/machinedeployment.go:376:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machinedeployment.go:379:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMD.Spec.Replicas > int32(maxSize):
                                                 ^
internal/webhooks/machinedeployment.go:383:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(maxSize), nil
                                    ^
internal/webhooks/machineset.go:308:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machineset.go:322:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machineset.go:325:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMS.Spec.Replicas < int32(minSize):
                                                 ^
internal/webhooks/machineset.go:329:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(minSize), nil
                                    ^
internal/webhooks/machineset.go:332:36: G115: integer overflow conversion int64 -> int32 (gosec)
                case *oldMS.Spec.Replicas > int32(maxSize):
                                                 ^
internal/webhooks/machineset.go:336:16: G115: integer overflow conversion int64 -> int32 (gosec)
                        return int32(maxSize), nil
                                    ^
exp/internal/controllers/machinepool_controller_noderef.go:104:33: G115: integer overflow conversion int -> int32 (gosec)
        mp.Status.ReadyReplicas = int32(nodeRefsResult.ready)
                                       ^
exp/internal/controllers/machinepool_controller_noderef.go:105:37: G115: integer overflow conversion int -> int32 (gosec)
        mp.Status.AvailableReplicas = int32(nodeRefsResult.available)
                                           ^
exp/internal/controllers/machinepool_controller_phases_test.go:2089:36: G115: integer overflow conversion int -> int32 (gosec)
                        Replicas:    ptr.To[int32](int32(replicas)),
                                                        ^
internal/controllers/topology/cluster/cluster_controller_test.go:966:11: G115: integer overflow conversion int64 -> int32 (gosec)
                if int32(*replicas) != *cluster.Spec.Topology.ControlPlane.Replicas {
                        ^
internal/controllers/topology/cluster/cluster_controller_test.go:967:67: G115: integer overflow conversion int64 -> int32 (gosec)
                        return fmt.Errorf("replicas %v do not match expected %v", int32(*replicas), *cluster.Spec.Topology.ControlPlane.Replicas)
                                                                                       ^
controlplane/kubeadm/internal/controllers/remediation.go:503:20: G115: integer overflow conversion int -> int32 (gosec)
                RetryCount: int32(r.RetryCount),
                                 ^
controlplane/kubeadm/internal/controllers/status.go:43:49: G115: integer overflow conversion int -> int32 (gosec)
        controlPlane.KCP.Status.UpdatedReplicas = int32(len(upToDateMachines))
                                                       ^
controlplane/kubeadm/internal/controllers/status.go:45:19: G115: integer overflow conversion int -> int32 (gosec)
        replicas := int32(len(controlPlane.Machines))
                         ^
controlplane/kubeadm/internal/controllers/status.go:80:11: G115: integer overflow conversion int -> int32 (gosec)
                if int32(len(readyMachines)) == replicas {
                        ^
controlplane/kubeadm/internal/controllers/upgrade.go:121:54: G115: integer overflow conversion int -> int32 (gosec)
                maxNodes := *controlPlane.KCP.Spec.Replicas + int32(controlPlane.KCP.Spec.RolloutStrategy.RollingUpdate.MaxSurge.IntValue())
                                                                   ^
controlplane/kubeadm/internal/controllers/upgrade.go:122:11: G115: integer overflow conversion int -> int32 (gosec)
                if int32(controlPlane.Machines.Len()) < maxNodes {
                        ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:221:35: G115: integer overflow conversion int -> int32 (gosec)
        m.Status.ExpectedMachines = int32(totalTargets)
                                         ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:236:33: G115: integer overflow conversion int -> int32 (gosec)
        m.Status.CurrentHealthy = int32(len(healthy))
                                       ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:589:27: G115: integer overflow conversion int -> int32 (gosec)
                remediationCount = int32(maxVal - unhealthyMachineCount)
                                        ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:601:26: G115: integer overflow conversion int -> int32 (gosec)
        remediationCount = int32(maxUnhealthy - unhealthyMachineCount)
                                ^
internal/controllers/machinehealthcheck/machinehealthcheck_controller.go:627:12: G115: integer overflow conversion uint64 -> int (gosec)
        return int(minVal), int(maxVal), nil
                  ^
internal/controllers/machinedeployment/machinedeployment_rollout_ondelete.go:122:29: G115: integer overflow conversion int -> int32 (gosec)
                totalMachineCount := int32(len(allMachinesInOldMS.Items))
                                          ^
internal/controllers/machinedeployment/machinedeployment_sync.go:612:15: G115: integer overflow conversion int -> int32 (gosec)
        diff := int32(len(cleanableMSes)) - *deployment.Spec.RevisionHistoryLimit
                     ^
internal/controllers/machineset/machineset_controller.go:952:28: G115: integer overflow conversion int -> int32 (gosec)
        newStatus.Replicas = int32(len(filteredMachines))
                                  ^
internal/controllers/machineset/machineset_controller.go:953:40: G115: integer overflow conversion int -> int32 (gosec)
        newStatus.FullyLabeledReplicas = int32(fullyLabeledReplicasCount)
                                              ^
internal/controllers/machineset/machineset_controller.go:954:33: G115: integer overflow conversion int -> int32 (gosec)
        newStatus.ReadyReplicas = int32(readyReplicasCount)
                                       ^
internal/controllers/machineset/machineset_controller.go:955:37: G115: integer overflow conversion int -> int32 (gosec)
        newStatus.AvailableReplicas = int32(availableReplicasCount)
                                           ^
internal/controllers/machineset/machineset_controller_test.go:1718:49: G115: integer overflow conversion int -> int32 (gosec)
                                                MaxInFlight: ptr.To(intstr.FromInt32(int32(maxInFlight))),
                                                                                          ^

Should I do the same?

Alright, i see you're okay with the disable the specific rule.

@sbueringer
Copy link
Member

@mcbenjemaa Can you please rebase? There was another PR touching the golangci-lint file merged in the meantime

@sbueringer
Copy link
Member

PR in general lgtm. Just not sure if the merge works correctly because exclude-files was added in another place in the other PR. So I'm not sure if we get a duplicate when we just merge this PR

.golangci.yml Outdated Show resolved Hide resolved
@sbueringer sbueringer added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Sep 9, 2024
@mcbenjemaa
Copy link
Member Author

/test pull-cluster-api-verify-main

@sbueringer
Copy link
Member

Thank you very much!!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 10, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2262e576124e8b5a4022e6a69a5a81f0a9638601

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 10, 2024
@k8s-ci-robot k8s-ci-robot merged commit 9856847 into kubernetes-sigs:main Sep 10, 2024
20 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Sep 10, 2024
@mcbenjemaa mcbenjemaa deleted the bump-golangci branch September 11, 2024 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/ci Issues or PRs related to ci cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bump golangci-lint to v1.60.2
3 participants