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
fix staticcheck failures: apiserver/pkg/{storage,util} #95683
Conversation
Welcome @obeyda! |
Hi @obeyda. 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 Once the patch is verified, the new status will be reflected by the 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. |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. I understand the commands that are listed here. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: obeyda The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/check-cla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ok-to-test
Please squash the commits together, and maybe add the static check output to the commit message so we can understand why the changes are made.
/assign @jingyih |
b63357d
to
2f4f6a0
Compare
Commits squashed, also I've updated the description with the static check output |
fix static check failures for these folders: - vendor/k8s.io/apiserver/pkg/storage - vendor/k8s.io/apiserver/pkg/storage/cacher - vendor/k8s.io/apiserver/pkg/storage/etcd3 - vendor/k8s.io/apiserver/pkg/storage/tests - vendor/k8s.io/apiserver/pkg/storage/value/encrypt/envelope - vendor/k8s.io/apiserver/pkg/util/webhook - vendor/k8s.io/apiserver/pkg/util/wsstream Errors from staticcheck: vendor/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go:656:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go:666:6: call to T.Fatalf vendor/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go:724:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go:734:5: call to T.Fatalf vendor/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go:927:4: ineffective break statement. Did you mean to break out of the outer loop? (SA4011) vendor/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go:978:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/storage/cacher/cacher_whitebox_test.go:983:5: call to T.Fatalf vendor/k8s.io/apiserver/pkg/storage/cacher/caching_object_test.go:137:3: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/storage/cacher/caching_object_test.go:152:5: call to T.Fatalf vendor/k8s.io/apiserver/pkg/storage/cacher/watch_cache_test.go:407:2: this value of err is never used (SA4006) vendor/k8s.io/apiserver/pkg/storage/etcd3/store_test.go:1914:3: field t is unused (U1000) vendor/k8s.io/apiserver/pkg/storage/selection_predicate_test.go:33:6: type IgnoredList is unused (U1000) vendor/k8s.io/apiserver/pkg/storage/tests/cacher_test.go:949:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/storage/tests/cacher_test.go:959:6: call to T.Fatalf vendor/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service_unix_test.go:135:4: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service_unix_test.go:141:6: call to T.Fatalf vendor/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service_unix_test.go:150:4: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service_unix_test.go:159:6: call to T.Fatalf vendor/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service_unix_test.go:224:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service_unix_test.go:231:4: call to T.Fatalf vendor/k8s.io/apiserver/pkg/util/webhook/certs_test.go:71:5: var badCAKey is unused (U1000) vendor/k8s.io/apiserver/pkg/util/wsstream/conn_test.go:58:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/util/wsstream/conn_test.go:62:4: call to T.Fatal vendor/k8s.io/apiserver/pkg/util/wsstream/conn_test.go:75:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/util/wsstream/conn_test.go:78:4: call to T.Fatalf vendor/k8s.io/apiserver/pkg/util/wsstream/conn_test.go:140:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/util/wsstream/conn_test.go:144:4: call to T.Fatal vendor/k8s.io/apiserver/pkg/util/wsstream/conn_test.go:157:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002) vendor/k8s.io/apiserver/pkg/util/wsstream/conn_test.go:160:4: call to T.Fatalf Part of kubernetes#92402
cc3cc21
to
3e1b498
Compare
/retest |
I think the failing tests aren't related to my changes, before rebase all tests were passing |
/test pull-kubernetes-e2e-kind |
@jingyih, PTAL |
@@ -682,9 +684,15 @@ func TestCacherNoLeakWithMultipleWatchers(t *testing.T) { | |||
} | |||
} | |||
}() | |||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I do not follow why we need a new go routine here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is so we don't block and allow receive on errorCh on line 693 if err = <- errorCh; err != nil {...}
@@ -731,7 +740,7 @@ func testCacherSendBookmarkEvents(t *testing.T, allowWatchBookmarks, expectedBoo | |||
ResourceVersion: fmt.Sprintf("%v", resourceVersion+uint64(i)), | |||
}}) | |||
if err != nil { | |||
t.Fatalf("failed to add a pod: %v", err) | |||
errorCh <- fmt.Errorf("failed to add a pod: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon getting a non-nil error, we should return here? (as apposed to keep trying in the loop)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will add it.
errorCh <- fmt.Errorf("failed to add a pod: %v", err) | |
errorCh <- fmt.Errorf("failed to add a pod: %v", err) | |
return |
@@ -720,6 +728,7 @@ func testCacherSendBookmarkEvents(t *testing.T, allowWatchBookmarks, expectedBoo | |||
t.Fatalf("Failed to create watch: %v", err) | |||
} | |||
|
|||
errorCh := make(chan error, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defer close this channel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think we'll need to close this since it's only used in a select
statement, but if you think it's necessary I'll update that.
@@ -924,7 +937,6 @@ func TestDispatchingBookmarkEventsWithConcurrentStop(t *testing.T) { | |||
|
|||
select { | |||
case <-done: | |||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because this is an ineffective break,
error from static check:
ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
} | ||
if event.Type == watch.Bookmark && rv == uint64(expectedRV) { | ||
select { | ||
case <-done: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I do not follow why we need the done channel to exit the function? Aren't the existing return
statements in this function enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad 😄, this is actually not needed here (I had in mind this is multiple goroutines, but it's only one)
} | ||
} | ||
}() | ||
|
||
// Simulate progress notify event. | ||
cacher.watchCache.UpdateResourceVersion(strconv.Itoa(expectedRV)) | ||
|
||
wg.Wait() | ||
go func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, not sure why a new go routine is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, to avoid blocking and allow receive on if err = <- errorCh; err != nil {...}
@@ -141,20 +143,34 @@ func TestCachingObjectRaces(t *testing.T) { | |||
for _, encoder := range encoders { | |||
buffer.Reset() | |||
if err := object.CacheEncode(encoder.identifier, encoder.encode, buffer); err != nil { | |||
t.Errorf("unexpected error: %v", err) | |||
errorCh <- fmt.Errorf("unexpected error: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the staticcheck complaining these "Errorf" statements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the staticcheck is complaining about the Fatalf
that exists in this goroutine, but since I fixed that, I also updated the Errorf
statements to use the same approach.
remove unneeded channel defer close for errorCh add missing return after errorCh send
@obeyda: PR needs rebase. 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
@obeyda: PR needs rebase. 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. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
Rotten issues close after 30d of inactivity. Send feedback to sig-contributor-experience at kubernetes/community. |
@fejta-bot: Closed this PR. In response to this:
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. |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
fix static check failures for these folders:
Errors reported by static check:
Which issue(s) this PR fixes:
Part of #92402
Does this PR introduce a user-facing change?: