Skip to content

USHIFT-1031: fix golangci-lint reported issues#1605

Merged
openshift-merge-robot merged 9 commits intoopenshift:mainfrom
copejon:ushift-1031
Apr 18, 2023
Merged

USHIFT-1031: fix golangci-lint reported issues#1605
openshift-merge-robot merged 9 commits intoopenshift:mainfrom
copejon:ushift-1031

Conversation

@copejon
Copy link
Contributor

@copejon copejon commented Mar 31, 2023

Which issue(s) this PR addresses:

USHIFT-1031

This PR applies fixes to errors caught by golangci-lint, or applies ignore directives when applicable.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 31, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 31, 2023

@copejon: This pull request references USHIFT-1031 which is a valid jira issue.

Details

In response to this:

Which issue(s) this PR addresses:

USHIFT-1031

This PR applies fixes to errors caught by golangci-lint, or applies ignore directives when applicable.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 31, 2023

@copejon: This pull request references USHIFT-1031 which is a valid jira issue.

Details

In response to this:

Which issue(s) this PR addresses:

USHIFT-1031

This PR applies fixes to errors caught by golangci-lint, or applies ignore directives when applicable.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 31, 2023
@copejon
Copy link
Contributor Author

copejon commented Mar 31, 2023

/cherry-pick release-4.13

@openshift-cherrypick-robot

@copejon: once the present PR merges, I will cherry-pick it on top of release-4.13 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-4.13

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot requested review from dhellmann and ggiguash March 31, 2023 20:45
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 31, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 31, 2023
Copy link
Contributor

@dhellmann dhellmann left a comment

Choose a reason for hiding this comment

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

Most of these changes look like things we want.

I don't see a change to enable the linter in the Makefile, and I think we'll want that as part of this PR so we don't end up regressing.

Since the PR touches so many files, I'm hoping we can land the configuration refactoring in #1442 before this. Or at least not change the config package in this PR so I don't have to rebase again.

@copejon
Copy link
Contributor Author

copejon commented Apr 3, 2023

Most of these changes look like things we want.

I don't see a change to enable the linter in the Makefile, and I think we'll want that as part of this PR so we don't end up regressing.

Thanks, that's a good point. Will add.

Since the PR touches so many files, I'm hoping we can land the configuration refactoring in #1442 before this. Or at least not change the config package in this PR so I don't have to rebase again.

I'm fine keeping this one on hold until then.
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 3, 2023
Copy link
Member

Choose a reason for hiding this comment

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

Looks like 1st usage of go generics in microshift? :)

@copejon copejon force-pushed the ushift-1031 branch 3 times, most recently from 848df23 to 8019687 Compare April 3, 2023 21:50
Copy link
Contributor

@eggfoobar eggfoobar left a comment

Choose a reason for hiding this comment

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

Just a small suggestion on order

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 5, 2023
@copejon copejon force-pushed the ushift-1031 branch 2 times, most recently from 5fb9a60 to eb78cce Compare April 6, 2023 19:01
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 6, 2023
@copejon
Copy link
Contributor Author

copejon commented Apr 6, 2023

/retest

1 similar comment
@ggiguash
Copy link
Contributor

/retest

@copejon
Copy link
Contributor Author

copejon commented Apr 10, 2023

Failure is due to the golangci-lint trying and failing to create a .cache dir in the user's home dir, which doesn't exist. I'm working on a fix in CI to override the default cache location.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 10, 2023
@copejon
Copy link
Contributor Author

copejon commented Apr 13, 2023

/test verify

@ggiguash
Copy link
Contributor

/retest

@ggiguash
Copy link
Contributor

@copejon , looks like the Verify test requires some fixes in the code

path_prefixer: 2/2, cgo: 57/57, uniq_by_line: 2/2, source_code: 2/2, severity-rules: 2/2, path_prettifier: 57/57, skip_dirs: 57/57, autogenerated_exclude: 56/57, nolint: 2/4, path_shortener: 2/2, fixer: 2/2, sort_results: 2/2, identifier_marker: 56/56, exclude: 56/56, max_per_file_from_linter: 2/2"
level=info msg="[runner] processing took 7.378718ms with stages: nolint: 3.187383ms, autogenerated_exclude: 1.096068ms, identifier_marker: 1.044983ms, path_prettifier: 934.479µs, exclude-rules: 711.378µs, skip_dirs: 161.01µs, source_code: 91.681µs, cgo: 76.37µs, filename_unadjuster: 41.556µs, max_from_linter: 12.311µs, uniq_by_line: 9.266µs, max_same_issues: 5.412µs, path_shortener: 1.979µs, skip_files: 1.176µs, max_per_file_from_linter: 831ns, exclude: 692ns, diff: 569ns, fixer: 488ns, sort_results: 442ns, severity-rules: 427ns, path_prefixer: 217ns"
level=info msg="[runner] linters took 2m19.546670502s with stages: goanalysis_metalinter: 2m19.539099305s"
pkg/cmd/init_test.go:147:11: Error return value of `os.Mkdir` is not checked (errcheck)
		os.Mkdir(filepath.Join(rootDir, dir), 0600)
		        ^
pkg/cmd/init_test.go:154:25: Error return value is not checked (errcheck)
	cleanupStaleKubeconfigs(cfg, rootDir)
	                       ^

Copy link
Contributor

Choose a reason for hiding this comment

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

Flipping this condition around will cause problems when more validations get added later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point. I've reverted the change and added a linter skip tag.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a linter skip tag here. Was a change lost in a rebase?

Copy link
Contributor

Choose a reason for hiding this comment

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

to happen

@copejon
Copy link
Contributor Author

copejon commented Apr 14, 2023

/retest

@copejon
Copy link
Contributor Author

copejon commented Apr 17, 2023

/test verify

@copejon
Copy link
Contributor Author

copejon commented Apr 17, 2023

The linter is satisfied, however the vulnerability check found 4 items and is failing the verify test.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a linter skip tag here. Was a change lost in a rebase?

pkg/cmd/run.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be the context that everything else is using to know when to exit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the runCtx declaration above the AddServer chunk so it can be passed down to services

copejon added 5 commits April 17, 2023 16:43
Signed-off-by: Jon Cope <jcope@redhat.com>
use Set generics over deprecated Set types
Signed-off-by: Jon Cope <jcope@redhat.com>

the presence of a vendor dir causes install to place the bin outside of PATH, forcing it to behave as a module fixes this

Signed-off-by: Jon Cope <jcope@redhat.com>

post-rebase fixes.  These include err checking, nested ifs, empty newlines, and a couple ctx passing errors
copejon and others added 4 commits April 18, 2023 09:37
…d up linter fixes b/c of it, instead follow up in another PR

Signed-off-by: Jon Cope <jcope@redhat.com>
…to 3m

Signed-off-by: Jon Cope <jcope@redhat.com>
Signed-off-by: Jon Cope <jcope@redhat.com>
@dhellmann dhellmann added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Apr 18, 2023
@dhellmann
Copy link
Contributor

This looks good. I set the merge method to squash, but you can remove that if you want. Remove the hold when you're ready.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 18, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: copejon, dhellmann

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

The pull request process is described here

Details 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

@copejon
Copy link
Contributor Author

copejon commented Apr 18, 2023

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 18, 2023
@openshift-merge-robot openshift-merge-robot merged commit 6e88dfc into openshift:main Apr 18, 2023
@openshift-cherrypick-robot

@copejon: #1605 failed to apply on top of branch "release-4.13":

Applying: sets.String is deprecated, use the new generic call instead
Using index info to reconstruct a base tree...
A	.golangci.yaml
M	pkg/components/render_test.go
M	pkg/controllers/cluster-policy-controller.go
M	pkg/controllers/etcd.go
M	pkg/controllers/infra-services-controller.go
M	pkg/controllers/kube-apiserver.go
M	pkg/controllers/kube-scheduler.go
M	pkg/controllers/openshift-crd-manager.go
M	pkg/controllers/version.go
M	pkg/loadbalancerservice/controller.go
M	pkg/mdns/controller.go
M	pkg/util/net.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/util/net.go
CONFLICT (content): Merge conflict in pkg/util/net.go
Auto-merging pkg/mdns/controller.go
Auto-merging pkg/loadbalancerservice/controller.go
Auto-merging pkg/controllers/version.go
Auto-merging pkg/controllers/openshift-crd-manager.go
Auto-merging pkg/controllers/kube-scheduler.go
Auto-merging pkg/controllers/kube-apiserver.go
CONFLICT (content): Merge conflict in pkg/controllers/kube-apiserver.go
Auto-merging pkg/controllers/infra-services-controller.go
Auto-merging pkg/controllers/etcd.go
Auto-merging pkg/controllers/cluster-policy-controller.go
Auto-merging pkg/components/render_test.go
CONFLICT (modify/delete): .golangci.yaml deleted in HEAD and modified in sets.String is deprecated, use the new generic call instead. Version sets.String is deprecated, use the new generic call instead of .golangci.yaml left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 sets.String is deprecated, use the new generic call instead
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Details

In response to this:

/cherry-pick release-4.13

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@copejon copejon deleted the ushift-1031 branch April 19, 2023 15:22
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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. 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.

9 participants