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

Fixes Golint Errors: staging/src/k8s.io/kube-aggregator #73369

Conversation

eloyekunle
Copy link
Contributor

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug

/kind cleanup

/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
Fixes lint issues in Go files under: staging/src/k8s.io/kube-aggregator.
Removed staging/src/k8s.io/kube-aggregator from hack/.golint_failures.

Special notes for your reviewer:
See #68026 for more information.

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 27, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @eloyekunle. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 27, 2019
@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 27, 2019
@eloyekunle
Copy link
Contributor Author

/assign @lavalamp

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

@eloyekunle thank you for the PR.
please squash the commits into one.

/priority backlog
/kind cleanup

@k8s-ci-robot k8s-ci-robot added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 27, 2019
@eloyekunle eloyekunle force-pushed the lint/staging/src/k8s.io/kube-aggregator branch from 07978fb to f3c092b Compare January 27, 2019 18:05
@eloyekunle
Copy link
Contributor Author

Hi @neolit123
I've squashed the commits.

@neolit123
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 27, 2019
@eloyekunle eloyekunle force-pushed the lint/staging/src/k8s.io/kube-aggregator branch 2 times, most recently from 5ad37e2 to 000ceb6 Compare January 28, 2019 07:54
@fejta
Copy link
Contributor

fejta commented Jan 28, 2019

please pass tests

@eloyekunle eloyekunle force-pushed the lint/staging/src/k8s.io/kube-aggregator branch 2 times, most recently from e64fd8e to b92dba9 Compare January 28, 2019 11:14
@eloyekunle
Copy link
Contributor Author

@fejta I don't know why the pull-kubernetes-node-e2e test is still failing. From the logs, it seems something is wrong with GCE.

@fejta
Copy link
Contributor

fejta commented Jan 28, 2019

/retest

@eloyekunle
Copy link
Contributor Author

@fejta @neolit123
Thanks, the tests pass now.

@eloyekunle eloyekunle force-pushed the lint/staging/src/k8s.io/kube-aggregator branch from f655570 to 342dfc3 Compare February 7, 2019 10:57
// unconditionally (irrespective of the latest resource version), when
// there is no resource version specified in the object.
AllowUnconditionalUpdate() bool
}
Copy link
Contributor

Choose a reason for hiding this comment

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

can one test that it is complete?

var _ RESTUpdateStrategy = nil.(RESTCreateUpdateStrategy)

Is that valid code?

Copy link
Contributor Author

@eloyekunle eloyekunle Feb 7, 2019

Choose a reason for hiding this comment

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

Yes, one can test with:

var _ RESTCreateStrategy = (RESTCreateUpdateStrategy)(nil)

I've added the tests.

@@ -0,0 +1,46 @@
/*
Copyright 2014 The Kubernetes Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

2019

@sttts
Copy link
Contributor

sttts commented Feb 7, 2019

Some last nit, then lgtm.

@eloyekunle eloyekunle force-pushed the lint/staging/src/k8s.io/kube-aggregator branch from 342dfc3 to 833a300 Compare February 7, 2019 12:58
@eloyekunle
Copy link
Contributor Author

eloyekunle commented Feb 7, 2019

@sttts
I've addressed the comments.

@@ -0,0 +1,52 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could you name this file create_update.go (underscore) instead of the hyphen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @rajathagasthya
I've updated the file name.

@eloyekunle eloyekunle force-pushed the lint/staging/src/k8s.io/kube-aggregator branch 2 times, most recently from 7cddc77 to c174300 Compare February 8, 2019 09:53
// for cases where you want to auto-register APIs like TPRs or groups from the core kube-apiserver
type autoRegisterController struct {
type Controller struct {
Copy link
Member

Choose a reason for hiding this comment

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

we shouldn't export this type just to make lint happy

Copy link
Contributor Author

@eloyekunle eloyekunle Feb 9, 2019

Choose a reason for hiding this comment

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

Across the codebase, most controllers similar to this are exported.

For example:

and many others are exported, and they all have 'getters', similar to this one (i.e. NewControllerName) returning the exported controller.

Is there another way to satisfy Golint, or will I have to leave this package in .golint_failures?

Copy link
Contributor

Choose a reason for hiding this comment

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

@liggitt I agree with @eloyekunle. Let's not block this by making Controller public. We need a better golint exception mechanism.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @eloyekunle. Let's not block this by making Controller public

not sure if you are suggesting keeping this package in .golint_failures or making Controller public. I'd prefer not to export just to make golint happy, but I don't feel that strongly

Copy link
Contributor

Choose a reason for hiding this comment

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

Jordan, why is it important for this to stay private?

Automated systems like this and gofmt don't always produce the ideal decision at the micro level (maybe you hate tabs, or disagree with lint's exported type directives), but at the macro level the value of providing consistent expectations makes it easier for large teams to collaborate on large code bases.

Removing this package from .golint_failures is useful for two reasons:

  1. It ensures no other, potentially more useful failures, get checked into this package.
  2. A shorter .golint_failure exception lint makes it more likely other packages will fix their lint errors rather than being one of the few special-cased packages.

IMO it is generally an unproductive use of time to try and fight the linting system (but maybe this is an exceptional circumstance?)

Copy link
Member

Choose a reason for hiding this comment

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

why is it important for this to stay private?

this is a package in an exported repo, so making the controller class public implies it is a suitable API for other projects to depend on. I don't think its structure has been considered in that light, so simply making it public to pass a linting check seems subpar

Copy link
Contributor

Choose a reason for hiding this comment

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

Jordan, is this the only controversial part about the PR?

Elijah, if so how would you feel about removing this part from this PR. This will expedite removing most of the lint errors.

If you're up for it, I'd suggest creating a second PR with just the autoRegisterController change (and removing the lint exception). We can continue the discussion there.

Copy link
Member

Choose a reason for hiding this comment

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

yes, everything else looked fine to me

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I've removed this part from the PR. The controller is now unexported.

@liggitt
Copy link
Member

liggitt commented Feb 8, 2019

one comment on exported type, lgtm otherwise

@sttts
Copy link
Contributor

sttts commented Feb 11, 2019

one comment on exported type, lgtm otherwise

We had this discussion before, even with the golint people. I still consider export of private structs as a good pattern, golint doesn't. Introducing interfaces is ugly.

@eloyekunle eloyekunle force-pushed the lint/staging/src/k8s.io/kube-aggregator branch from c174300 to 6e9fc74 Compare February 11, 2019 20:15
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 11, 2019
@liggitt liggitt added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Feb 11, 2019
@liggitt
Copy link
Member

liggitt commented Feb 11, 2019

/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 Feb 11, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: eloyekunle, fejta, liggitt

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 Feb 11, 2019
@k8s-ci-robot k8s-ci-robot merged commit 805a9e7 into kubernetes:master Feb 11, 2019
@eloyekunle eloyekunle deleted the lint/staging/src/k8s.io/kube-aggregator branch February 11, 2019 22:31
@eloyekunle
Copy link
Contributor Author

Feels so good to have my first contribution to Kubernetes! 😄
Thanks everyone.

@s-chand
Copy link

s-chand commented Feb 12, 2019

Nice work man!

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/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 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.

None yet