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
[KMSv2] Drop the apimachinery #120225
[KMSv2] Drop the apimachinery #120225
Conversation
Skipping CI for Draft Pull Request. |
@@ -64,7 +64,7 @@ func TestGRPCService(t *testing.T) { | |||
client := newClient(t, address) | |||
|
|||
// make sure the gRPC server is up before running tests | |||
if err := wait.PollImmediateUntilWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) { | |||
if err := util.PollImmediateUntilWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) { |
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.
Just use a for loop with a sleep. Do not copy the entire implementation from the wait
package.
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.
Sure.
I will remove unnecessary logic, split the files according to apimachinery, and add some unit tests in the next steps.
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.
Just make this a simple inline for loop with a sleep.
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.
sure.
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.
@pegasas Mo's recommendation was to just make this a inline for loop with a sleep. We don't need to copy any of the poller code or PollImmediateUntilWithContext
from the apimachinery util.
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.
sure.
I removed other useless code and keeps a inline for loop with a sleep.
f6d2dcc
to
6025cc4
Compare
9a7884c
to
871604d
Compare
staging/src/k8s.io/kms/go.mod
Outdated
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect | ||
google.golang.org/protobuf v1.31.0 // indirect | ||
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect | ||
) | ||
|
||
replace ( | ||
k8s.io/api => ../api | ||
k8s.io/apimachinery => ../apimachinery | ||
k8s.io/client-go => ../client-go |
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 client-go an indirect dependency of "k8s.io/apimachinery/pkg/util/wait"
?
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.
#120216 (comment)
It seems this targets further complex implementation.
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.
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.
You need to make that into a separate go module so it no longer impacts the deps of the kms module.
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.
sure.
/triage accepted |
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.
The CI failures are legit!
- The linter failures should go away after you change the implementation to a for loop with sleep and remove the apimachinery code.
- Run
hack/update-vendor.sh
to fixpull-kubernetes-dependencies
failures.
@@ -21,6 +21,7 @@ import ( | |||
"context" | |||
"encoding/base64" | |||
"fmt" | |||
"k8s.io/kms/pkg/util" |
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.
Move the import to line 35. FYI, the imports are grouped this way
import (
stdlib
external packages
internal packages
)
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.
Thanks @aramase !
Corrected!
@@ -64,7 +64,7 @@ func TestGRPCService(t *testing.T) { | |||
client := newClient(t, address) | |||
|
|||
// make sure the gRPC server is up before running tests | |||
if err := wait.PollImmediateUntilWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) { | |||
if err := util.PollImmediateUntilWithContext(ctx, time.Second, func(ctx context.Context) (bool, error) { |
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.
@pegasas Mo's recommendation was to just make this a inline for loop with a sleep. We don't need to copy any of the poller code or PollImmediateUntilWithContext
from the apimachinery util.
@@ -52,3 +58,105 @@ func ParseEndpoint(endpoint string) (string, error) { | |||
|
|||
return u.Path, nil | |||
} | |||
|
|||
func PollImmediateUntilWithContext(ctx context.Context, interval time.Duration, condition func(context.Context) (done bool, err error)) error { |
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.
Added a comment above. The previous review comments suggested using a simple inline for loop with sleep instead of copying code from apimachinery/util.
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.
add comments inline.
func HandleCrash() { | ||
if r := recover(); r != nil { | ||
if r == http.ErrAbortHandler { | ||
// honor the http.ErrAbortHandler sentinel panic value: | ||
// ErrAbortHandler is a sentinel panic value to abort a handler. | ||
// While any panic from ServeHTTP aborts the response to the client, | ||
// panicking with ErrAbortHandler also suppresses logging of a stack trace to the server's error log. | ||
return | ||
} | ||
const size = 64 << 10 | ||
stacktrace := make([]byte, size) | ||
stacktrace = stacktrace[:runtime.Stack(stacktrace, false)] | ||
if _, ok := r.(string); ok { | ||
klog.Errorf("Observed a panic: %s\n%s", r, stacktrace) | ||
} else { | ||
klog.Errorf("Observed a panic: %#v (%v)\n%s", r, r, stacktrace) | ||
} | ||
} | ||
} |
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 not required!
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.
removed.
be4c747
to
ac5ecea
Compare
@pegasas: The following test failed, say
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/test-infra repository. I understand the commands that are listed here. |
/lgtm |
LGTM label has been added. Git tree hash: 96df378c8aa47696220f66966891d4f54424de38
|
/kind cleanup |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dims, enj, pegasas 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 |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Drop the apimachinery and client-go dependencies from https://github.com/kubernetes/kms/blob/master/go.mod to keep the import lighter.
Which issue(s) this PR fixes:
Fixes #120216
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: