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

Chore: fixed lints errors #7542

Merged
merged 2 commits into from
Dec 3, 2024
Merged

Conversation

omerap12
Copy link
Member

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This PR addresses several linting issues identified in the codebase, as follows:

 ~/Desktop/PersonlRepos/autoscaler/vertical-pod-autoscaler/ [master] golangci-lint run          
pkg/updater/eviction/pods_eviction_restriction_test.go:645:18: Error return value of `eviction.Evict` is not checked (errcheck)
                        eviction.Evict(p.pod, testCase.vpa, mockRecorder)
                                      ^
pkg/updater/priority/update_priority_calculator.go:196:56: SA1019: sets.String is deprecated: use generic Set instead. new ways: s1 := Set[string]{} s2 := New[string]() (staticcheck)
func parseVpaObservedContainers(pod *apiv1.Pod) (bool, sets.String) {
                                                       ^
pkg/utils/status/status_object.go:177:10: SA1019: netError.Temporary has been deprecated since Go 1.18 because it shouldn't be used: Temporary errors are not well-defined. Most "temporary" errors are timeouts, and the few exceptions are surprising. Do not use this method. (staticcheck)
                return netError.Temporary() || netError.Timeout()
                       ^
pkg/utils/status/status_object.go:31:2: SA1019: "k8s.io/utils/pointer" is deprecated: Use functions in k8s.io/utils/ptr instead: ptr.To to obtain a pointer, ptr.Deref to dereference a pointer, ptr.Equal to compare dereferenced pointers. (staticcheck)
        "k8s.io/utils/pointer"
        ^

This PR fixes those issues.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Should we add golangci-lint run to our GitHub Actions pipeline? It seems like a helpful way to catch these issues early.

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

NONE

Signed-off-by: Omer Aplatony <omerap12@gmail.com>
@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Nov 29, 2024
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 29, 2024
@k8s-ci-robot k8s-ci-robot requested a review from kgolab November 29, 2024 10:20
@k8s-ci-robot k8s-ci-robot added area/vertical-pod-autoscaler size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 29, 2024
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
@@ -642,7 +642,7 @@ func TestEvictEmitEvent(t *testing.T) {
mockRecorder.On("Event", mock.Anything, apiv1.EventTypeNormal, "EvictedByVPA", mock.Anything).Return()
mockRecorder.On("Event", mock.Anything, apiv1.EventTypeNormal, "EvictedPod", mock.Anything).Return()

eviction.Evict(p.pod, testCase.vpa, mockRecorder)
_ = eviction.Evict(p.pod, testCase.vpa, mockRecorder)
Copy link
Member Author

@omerap12 omerap12 Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrianmoisey error check here caused a failure (https://github.com/kubernetes/autoscaler/actions/runs/12082981510/job/33695187736) so I ignore that for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting. Based on this test, I think that error is expected, since the pod can't be evicted.
Would you be able to change the test to include testing if an error is expected or not?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. In this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too fussed, your choice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@adrianmoisey
Copy link
Member

/lgtm

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

voelzmo commented Dec 3, 2024

Thanks for the PR!

Should we add golangci-lint run to our GitHub Actions pipeline? It seems like a helpful way to catch these issues early.

Yeah, absolutely! I think this is the only way to keep these errors out of the codebase.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: omerap12, voelzmo

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 Dec 3, 2024
@k8s-ci-robot k8s-ci-robot merged commit 7b44715 into kubernetes:master Dec 3, 2024
7 checks passed
@omerap12
Copy link
Member Author

omerap12 commented Dec 3, 2024

Thanks for the PR!

Should we add golangci-lint run to our GitHub Actions pipeline? It seems like a helpful way to catch these issues early.

Yeah, absolutely! I think this is the only way to keep these errors out of the codebase.

/approve

Ill raise a PR then :)

HolderIdentity: pointer.String(c.holderIdentity),
LeaseDurationSeconds: pointer.Int32(c.leaseDurationSeconds),
HolderIdentity: ptr.To(c.holderIdentity),

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you introduce a new no-op empty line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by mistake, Ill raise a PR to fix thanks

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/vertical-pod-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants