-
Notifications
You must be signed in to change notification settings - Fork 80
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
Implmentation of warning headers #69
Conversation
|
This seems to be working well. Sample output complements of curl...
|
pkg/client/factory.go
Outdated
return newClient(ctx, p.clientCfg, s, namespace, p.impersonate) | ||
func (p *Factory) Client(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error) { | ||
config := *p.clientCfg | ||
config.WarningHandler = warningHandler |
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.
Could this just be added to newClient
and/or newDynamicClient
?
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.
Could this just be added to
newClient
and/ornewDynamicClient
?
That might be a slightly cleaner way to 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.
Ok, I switched it up a bit and added it to newDynamicClient. I think I like that a bit better.
5679bad
to
0012e7c
Compare
Looks like a little rebasing is also in order. I'll work on that soon. |
be168df
to
7f3e90d
Compare
@@ -384,7 +385,7 @@ func toAPIEvent(apiOp *types.APIRequest, schema *types.APISchema, event watch.Ev | |||
return apiEvent | |||
} | |||
|
|||
apiEvent.Object = toAPI(schema, event.Object) | |||
apiEvent.Object = toAPI(schema, event.Object, nil) |
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.
In the first version of this, the toAPIEvent
function accepted warnings, are they not needed any more for events?
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 don't think it's needed/useful in our case. I'll keep exploring though. It might be back.
7f3e90d
to
001b3e4
Compare
Updated to reflect new apiserver version after that change merged |
go.mod
Outdated
github.com/urfave/cli v1.22.10 | ||
github.com/urfave/cli/v2 v2.23.7 | ||
golang.org/x/sync v0.1.0 | ||
k8s.io/api v0.26.0 |
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.
Are we ready to use the 0.26 versions of the K8s modules?
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.
Hmm, good question. It slipped in with my mod updating. I can pull it back for now if we're not 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.
Changed to only bump rancher/apiserver
9a88cbe
to
a04cbb6
Compare
pkg/stores/proxy/proxy_store.go
Outdated
TableAdminClientForWatch(ctx *types.APIRequest, schema *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error) | ||
} | ||
|
||
type WarningBuffer struct { |
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.
Does this type need to be exported?
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.
Nope. Updated accordingly
pkg/stores/proxy/proxy_store.go
Outdated
Warnings []types.Warning | ||
} | ||
|
||
func (w *WarningBuffer) HandleWarningHeader(code int, agent string, text string) { |
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 this method called anywhere?
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.
Yeah...just not in our code. It's what gets called when the actual client sees a warning header
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, just to be sure, if it's called by someone else (who and how?), then does the type need to be exported? I am not finding any calls of this method anywhere across the org.
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.
When we create a client, we create a &warningBuffer to be used for that client. That warningBuffer has the HandleWarningHeader function that gets called down in client-go at runtime. I've witnessed this miracle in the debugger.
https://github.com/kubernetes/client-go/blob/master/rest/warnings.go#L137
Attempts to pass through warning headers which k8s returns. Requires an update to rancher/apiserver.
a04cbb6
to
956b735
Compare
Pass through warning headers which k8s returns.
Issue: rancher/rancher#39413