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

server: fix unexported-return lint issue #19052

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aladesawe
Copy link
Contributor

@aladesawe aladesawe commented Dec 12, 2024

PR to fix unexported-return lint issues under the server folder as mentioned in Issue 18370.

This PR:

  • uses existing interfaces to fix

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@k8s-ci-robot
Copy link

Hi @aladesawe. Thanks for your PR.

I'm waiting for a etcd-io 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-sigs/prow repository.

@ivanvc
Copy link
Member

ivanvc commented Dec 13, 2024

Hi, @aladesawe. Thanks for your pull request 🙇.

One of many PRs to fix unexported-return lint issues under the server folder as mentioned in #18370.

Do you know how many issues there are in server? If there are not too many, it may be better to open a single pull request. We ideally want to keep the PR under 100 or 200 lines.

Thanks, again.

@aladesawe
Copy link
Contributor Author

Hi, @aladesawe. Thanks for your pull request 🙇.

One of many PRs to fix unexported-return lint issues under the server folder as mentioned in #18370.

Do you know how many issues there are in server? If there are not too many, it may be better to open a single pull request. We ideally want to keep the PR under 100 or 200 lines.

Thanks, again.

Hello @ivanvc sure thing, I'll pull more updates into this PR. There are about 10 more files with the error under the server module.

@aladesawe aladesawe marked this pull request as draft December 13, 2024 04:52
@aladesawe aladesawe changed the title auth: fix unexported-return lint issue server: fix unexported-return lint issue Dec 15, 2024
@aladesawe aladesawe marked this pull request as ready for review December 16, 2024 22:08
@ivanvc
Copy link
Member

ivanvc commented Dec 18, 2024

/ok-to-test

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.92%. Comparing base (85931e1) to head (43c1b44).
Report is 17 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
server/auth/store.go 83.79% <100.00%> (ø)
server/etcdserver/adapters.go 66.66% <100.00%> (ø)
server/etcdserver/apply/apply.go 78.02% <ø> (ø)
server/mock/mockstorage/storage_recorder.go 95.00% <ø> (ø)
server/storage/mvcc/kvstore.go 89.86% <ø> (ø)
server/storage/mvcc/watchable_store.go 93.89% <100.00%> (ø)
server/storage/schema/alarm.go 86.66% <ø> (ø)
server/storage/schema/auth.go 100.00% <100.00%> (ø)
server/storage/schema/membership.go 59.85% <ø> (ø)
server/storage/wal/version.go 51.53% <ø> (ø)

... and 16 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #19052      +/-   ##
==========================================
+ Coverage   68.85%   68.92%   +0.06%     
==========================================
  Files         420      420              
  Lines       35716    35723       +7     
==========================================
+ Hits        24593    24622      +29     
+ Misses       9693     9681      -12     
+ Partials     1430     1420      -10     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85931e1...43c1b44. Read the comment docs.

@ivanvc
Copy link
Member

ivanvc commented Dec 19, 2024

/test pull-etcd-govulncheck

@ivanvc
Copy link
Member

ivanvc commented Jan 16, 2025

@aladesawe, I'm sorry it took me a while to respond to this pull request. I was out for the holidays and had a long backlog.

A heads up that I raised this question in a similar pull request: #19105 (comment)

Thanks for bearing with us :)

@aladesawe
Copy link
Contributor Author

@aladesawe, I'm sorry it took me a while to respond to this pull request. I was out for the holidays and had a long backlog.

A heads up that I raised this question in a similar pull request: #19105 (comment)

Thanks for bearing with us :)

No worries Ivan, understandable :). I see the comment, and will follow the conversation there.

Copy link
Member

@ivanvc ivanvc left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks, @aladesawe.

server/auth/store_test.go Outdated Show resolved Hide resolved
server/storage/mvcc/watchable_store_test.go Outdated Show resolved Hide resolved
server/storage/mvcc/watchable_store_test.go Outdated Show resolved Hide resolved
@aladesawe aladesawe requested a review from mmorel-35 January 27, 2025 04:44
@aladesawe
Copy link
Contributor Author

/retest

@ivanvc
Copy link
Member

ivanvc commented Jan 27, 2025

@aladesawe, could you please squash your commits?

@aladesawe aladesawe force-pushed the server-auth-unexported-return branch from 66c71ea to e2a99cf Compare January 27, 2025 21:46
@@ -938,7 +938,7 @@ func (as *authStore) IsAuthEnabled() bool {
}

// NewAuthStore creates a new AuthStore.
func NewAuthStore(lg *zap.Logger, be AuthBackend, tp TokenProvider, bcryptCost int) *authStore {
func NewAuthStore(lg *zap.Logger, be AuthBackend, tp TokenProvider, bcryptCost int) AuthStore {
Copy link
Member

Choose a reason for hiding this comment

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

Nice change!

@@ -33,7 +33,7 @@ type serverVersionAdapter struct {
*EtcdServer
}

func NewServerVersionAdapter(s *EtcdServer) *serverVersionAdapter {
func NewServerVersionAdapter(s *EtcdServer) serverversion.Server {
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@ahrtr
Copy link
Member

ahrtr commented Jan 31, 2025

The changes, which use the existing interfaces, should can be merged right away. Could you raise a separate PR for that?

All other changes, which introduce new interfaces, really need more careful review. Please raise a PR for each new interface.

@aladesawe
Copy link
Contributor Author

aladesawe commented Feb 5, 2025

The changes, which use the existing interfaces, should can be merged right away. Could you raise a separate PR for that?

All other changes, which introduce new interfaces, really need more careful review. Please raise a PR for each new interface.

@ahrtr Moved all new interfaces to the own PRs

@aladesawe
Copy link
Contributor Author

/retest

server/storage/wal/version.go Outdated Show resolved Hide resolved
@@ -47,10 +48,7 @@ func localBinaryVersion() semver.Version {
return semver.Version{Major: v.Major, Minor: v.Minor}
}

type WALVersion interface {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ahrtr see here. Version below is wal.Version. Please let me know what your concerns are

Copy link
Member

Choose a reason for hiding this comment

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

OK, got it. thx for the clarification. Since the WALVersion is only included in main (release-3.5 doesn't have this interface), and we haven't release 3.6 yet. So it should be OK to rename it.

cc @serathius

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ahrtr this makes sense. I've moved the changes here

@@ -47,10 +48,7 @@ func localBinaryVersion() semver.Version {
return semver.Version{Major: v.Major, Minor: v.Minor}
}

type WALVersion interface {
Copy link
Member

Choose a reason for hiding this comment

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

OK, got it. thx for the clarification. Since the WALVersion is only included in main (release-3.5 doesn't have this interface), and we haven't release 3.6 yet. So it should be OK to rename it.

cc @serathius

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahrtr, aladesawe, ivanvc, mmorel-35

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

@aladesawe aladesawe force-pushed the server-auth-unexported-return branch from da82a69 to 977673a Compare February 5, 2025 22:31
@aladesawe aladesawe force-pushed the server-auth-unexported-return branch 2 times, most recently from c3e312c to 87026bd Compare February 5, 2025 23:23
@ivanvc ivanvc requested a review from ahrtr February 6, 2025 07:14
@ivanvc
Copy link
Member

ivanvc commented Feb 6, 2025

Asking for a review from @ahrtr again, as @aladesawe removed the change to wal.Version.

Comment on lines +116 to +117
asImpl, ok := as.(*authStore)
require.Truef(t, ok, "addUserWithNoOption: needs an AuthStore implementation")
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a validation in production code similar to below?

var _ auth.AuthBackend = (*authBackend)(nil)

Suggested change
asImpl, ok := as.(*authStore)
require.Truef(t, ok, "addUserWithNoOption: needs an AuthStore implementation")

Comment on lines +343 to +344
sImpl, ok := s.(*watchableStore)
require.Truef(t, ok, "TestWatchNoEventLossOnCompact: needs a WatchableKV implementation")
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Suggested change
sImpl, ok := s.(*watchableStore)
require.Truef(t, ok, "TestWatchNoEventLossOnCompact: needs a WatchableKV implementation")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This already exists

var _ WatchableKV = (*watchableStore)(nil)

Confirming if also suggesting to remove the assertions?

Comment on lines +571 to +572
sImpl, ok := s.(*watchableStore)
require.Truef(t, ok, "TestWatchBatchUnsynced: needs a WatchableKV implementation")
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exists

var _ WatchableKV = (*watchableStore)(nil)

@ivanvc
Copy link
Member

ivanvc commented Feb 6, 2025

@aladesawe, with breaking this pull request into multiple ones. I would suggest adding a ignore comment directive (// revive:disable-next-line:unexported-return). So, technically, by merging this pull request, we can enable the linter. We address each of the special cases in different pull requests (and remove the comment directive).

@aladesawe
Copy link
Contributor Author

@aladesawe, with breaking this pull request into multiple ones. I would suggest adding a ignore comment directive (// revive:disable-next-line:unexported-return). So, technically, by merging this pull request, we can enable the linter. We address each of the special cases in different pull requests (and remove the comment directive).

@ivanvc makes sense, that's good feedback. Do you anticipate we'll turn on the lint rule after this goes in, to target the server module specifically? Mind showing me how that'll be done? I had to go into the test script to localize server module while testing. I wasn't able to do include/exclude successfully via revive settings

@aladesawe aladesawe force-pushed the server-auth-unexported-return branch from 87026bd to 43c1b44 Compare February 6, 2025 21:39
@k8s-ci-robot
Copy link

@aladesawe: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-etcd-verify 43c1b44 link true /test pull-etcd-verify
pull-etcd-e2e-amd64 43c1b44 link true /test pull-etcd-e2e-amd64

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants