Add webapi v2 endpoints for creating discovery token and enrolling eks with labels#50472
Add webapi v2 endpoints for creating discovery token and enrolling eks with labels#50472
Conversation
b51dded to
0a6aebc
Compare
|
|
|
I'm not sure pulling the version from the HTML document makes sense here. If a user runs into this error, it's because they have a newer web UI that knows how to use the new V2 endpoint with labels, but they ended up hitting an older proxy that doesn't know how to handle the request. If you show them the version from the HTML document, you're going to show them the newer web UI version, which is actually new enough. If we want this error message to make sense, we need to show the version of the proxy that is too old. (This means we probably need the backend to surface this information) |
4db33f1 to
15a7e75
Compare
15a7e75 to
0729ad9
Compare
410b710 to
538b042
Compare
| func NewWebClient(url string, opts ...roundtrip.ClientParam) (*WebClient, error) { | ||
| opts = append(opts, roundtrip.SanitizerEnabled(true)) | ||
| clt, err := roundtrip.NewClient(url, teleport.WebAPIVersion, opts...) | ||
| clt, err := roundtrip.NewClient(url, "", opts...) |
There was a problem hiding this comment.
The version parameter refers to this field, and from what i can tell, its only purpose is to just append the version prefix when calling this function (which we use a lot in our tests, and in auth here)
I didn't think it was necessary to define the version, since we are just going to strip it off anyways, and it wouldn't work with v2 endpoints
There was a problem hiding this comment.
If we are sure that we wont be using the version anymore, I think creating a v2 roundtrip.NewClientV2 function and then deprecating current one would be better here.
There was a problem hiding this comment.
hrm, i could, but I am not sure I see a benefit of keeping the deprecated one?
There was a problem hiding this comment.
The benefit of introducing v2 is that you wont have to refactor existing usage of roundtrip.NewClient in this PR.
Edit: I am not aware about current usage of roundtrip.NewClient so you might actually get away with that change without introducing v2 in this PR if that will be minimal, up to you.
538b042 to
c6d7694
Compare
fb39fee to
bc43b78
Compare
| } | ||
|
|
||
| clt, err := roundtrip.NewClient(proxyAddr.String(), teleport.WebAPIVersion, opts...) | ||
| clt, err := roundtrip.NewClient(proxyAddr.String(), "", opts...) |
There was a problem hiding this comment.
Umm based on discussion here #50472 (comment), I thought we are going to either add a roundtrip.NewClientV2 or update its current signature since we no longer use version field?
There was a problem hiding this comment.
recording slack discussion: agreed to not change signature since using client.go/NewWebClient introduced cyclic imports in tests, instead put comment explaining why version is empty
| require.True(t, trace.IsNotFound(err)) | ||
|
|
||
| var rawObjMap map[string]*json.RawMessage | ||
| require.NoError(t, json.Unmarshal(re.Bytes(), &rawObjMap)) |
There was a problem hiding this comment.
nit: unmarshal it once, check for error and then reuse the unmarshalled object in test below in line 3519, 3523.
There was a problem hiding this comment.
i think this is what you meant below, and then access the fields?
var traceErr trace.TraceError
require.NoError(t, json.Unmarshal(re.Bytes(), &traceErr))
if so, I couldn't do it this way because the returned JSON error didn't conform exactly to TraceError type (I ran into errors unmarshaling), so I had to manually unmarshal per field I wanted to test
98edc7c to
9ec4fbd
Compare
9ec4fbd to
3f04271
Compare
|
|
||
| // NewDebugFileSystem returns the HTTP file system implementation | ||
| func newDebugFileSystem() (http.FileSystem, error) { | ||
| func NewDebugFileSystem(isEnterprise bool) (http.FileSystem, error) { |
There was a problem hiding this comment.
Does it need to be exported?
There was a problem hiding this comment.
i forgot to push the branch that required this change in enterprise: https://github.com/gravitational/teleport.e/pull/5818, i added a enterprise not found handler test there (just in case...)
| Allow: types.RoleConditions{ | ||
| Rules: []types.Rule{ | ||
| types.NewRule(types.KindToken, | ||
| []string{types.VerbCreate, types.VerbRead}), |
There was a problem hiding this comment.
is types.VerbRead needed? comment above only says "Allow user to create tokens."
852387b to
7518029
Compare
7518029 to
ef0eb7c
Compare
* Create v2 web api endpoints and required related changes (#50472) * Pass join token suggestedLabels to app server labels during install.sh (#50720) * Allow adding app server labels from join token for install.sh * Address CRs * Reduce label yaml space, improve test * Set user provided labels for aws app access create (#50975) * Fix undefined slog
part of #46976
suggested_labels(this PR)extraLabels(Discover EKS: allow custom labels for Kube Server #49420)Both scenarios if a user tries to create token/resource and provides labels, if requests goes to an older proxy, it'll look like the request succeeded but the labels will not have been set. So this PR defines
v2endpoints, so that if request goes to an older proxy, a 404 error will return, which we will assume it's because of version mismatch.This PR also returns the version number of proxy when a route wasn't matched.
Rendered example of route not matched 404 error:
if
proxyVersionis returned:if
proxyVersionis not returned: