-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Expose client tools auto update for find endpoint #46785
Conversation
21709ac
to
61b2b93
Compare
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.
Can you add test coverage?
lib/web/apiserver.go
Outdated
}, nil | ||
} | ||
|
||
autoUpdateConfig, err := h.GetAccessPoint().GetAutoUpdateConfig(r.Context()) |
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.
nit: the auth preference above is retrieved using h.cfg.AccessPoint
, let's pick one and be consistent
api/client/webclient/webclient.go
Outdated
// ToolsVersion defines the version of {tsh, tctl} for client auto update. | ||
ToolsVersion string `json:"tools_version"` | ||
// ToolsAutoupdate enables client auto update feature. | ||
ToolsAutoupdate bool `json:"tools_autoupdate"` |
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.
Should the auto update information all be contained within another struct instead of adding each individual field to the response?
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.
grouping fields to another struct would be better, will change this one
lib/web/apiserver.go
Outdated
} | ||
|
||
autoUpdateConfig, err := h.GetAccessPoint().GetAutoUpdateConfig(r.Context()) | ||
if err != nil && !trace.IsNotFound(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.
I think it may also be possible to get a NotImplemented error back if the Proxy is newer than Auth. Even though this should be reading from the cache most of the time, a cluster admin can disable the cache, in which case this would make an RPC request to the old auth instance that doesn't implement the autoupdate service.
lib/web/apiserver.go
Outdated
return nil, trace.Wrap(err) | ||
} else if err == nil { | ||
response.ToolsAutoupdate = autoUpdateConfig.GetSpec().GetToolsAutoupdate() | ||
} | ||
|
||
autoUpdateVersion, err := h.GetAccessPoint().GetAutoUpdateVersion(r.Context()) | ||
if err != nil && !trace.IsNotFound(err) { | ||
return nil, trace.Wrap(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.
Should failing to retrieve auto update information prevent the response entirely?
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 added logging instead, but we might generate a lot of log messages with this error message in frequent requests to this endpoint
Log error instead returning error Add tests auto update settings in find endpoint Add check for not implemented error
api/client/webclient/webclient.go
Outdated
// ToolsVersion defines the version of {tsh, tctl} for client auto update. | ||
ToolsVersion string `json:"tools_version"` | ||
// ToolsAutoupdate enables client auto update feature. | ||
ToolsAutoupdate bool `json:"tools_autoupdate"` |
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 json tag for the AutoUpdate
field in the PingResponse is auto_update
- we should be consistent with the tag here.
ToolsAutoupdate bool `json:"tools_autoupdate"` | |
ToolsAutoUpdate bool `json:"tools_auto_update"` |
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.
We should decide if we want to treat auto-update as a single hyphenated word (toolsAutoupdate
/tools_autoupdate
) or an abbreviated way of writing "automatic update" (toolAutoUpdate
/tools_auto_update
), and then be consistent about this.
Seems like @rosstimothy is suggesting two words, so maybe we move all of the JSON/YAML to the two-word form, and reserve autoupdate
for the package, resource, and subcommand naming (autoupdate_config
, autoupdate
package, tctl autoupdate client
) exclusively?
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 was just trying to suggest to use consistent naming with https://github.com/gravitational/teleport/pull/46785/files#diff-c8c1c8dcbc610e7c6d2b2af815e65b0016525745ea97cc99791290e3df7e35e2R301.
lib/web/apiserver.go
Outdated
} | ||
|
||
autoUpdateConfig, err := h.cfg.AccessPoint.GetAutoUpdateConfig(r.Context()) | ||
// TODO(vapopov) DELETE IN v18.0.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.
Suggestion: make the deletion note clearer that its only the not found and not implemented checks that should be removed in v18
lib/web/apiserver.go
Outdated
} | ||
|
||
autoUpdateVersion, err := h.cfg.AccessPoint.GetAutoUpdateVersion(r.Context()) | ||
// TODO(vapopov) DELETE IN v18.0.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.
Suggestion: make the deletion note clearer that its only the not found and not implemented checks that should be removed in v18
lib/web/apiserver_ping_test.go
Outdated
assert.True(t, pr.AutoUpdate.ToolsAutoupdate, "tools_autoupdate must be enabled") | ||
assert.Equal(t, teleport.Version, pr.AutoUpdate.ToolsVersion, "tools_version must be equal to current version") |
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.
Suggestion: decouple the json tags from the message
assert.True(t, pr.AutoUpdate.ToolsAutoupdate, "tools_autoupdate must be enabled") | |
assert.Equal(t, teleport.Version, pr.AutoUpdate.ToolsVersion, "tools_version must be equal to current version") | |
assert.True(t, pr.AutoUpdate.ToolsAutoupdate, "tools auto update must be enabled") | |
assert.Equal(t, teleport.Version, pr.AutoUpdate.ToolsVersion, "tools version must be equal to current version") |
_, err = env.server.Auth().UpsertAutoUpdateVersion(ctx, version) | ||
require.NoError(t, err) | ||
|
||
req, err := http.NewRequest(http.MethodGet, proxy.newClient(t).Endpoint("webapi", "find"), 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.
Suggestion: add a test case that covers the default values when none of the auto update configurations are populated or there is an error retrieving the configurations?
* Expose client tools auto update for find endpoint * Group auto update settings in find response Log error instead returning error Add tests auto update settings in find endpoint Add check for not implemented error * Add more test cases
* Expose client tools auto update for find endpoint * Group auto update settings in find response Log error instead returning error Add tests auto update settings in find endpoint Add check for not implemented error * Add more test cases
* Expose client tools auto update for find endpoint * Group auto update settings in find response Log error instead returning error Add tests auto update settings in find endpoint Add check for not implemented error * Add more test cases
* Expose client tools auto update for find endpoint * Group auto update settings in find response Log error instead returning error Add tests auto update settings in find endpoint Add check for not implemented error * Add more test cases
* Expose client tools auto update for find endpoint * Group auto update settings in find response Log error instead returning error Add tests auto update settings in find endpoint Add check for not implemented error * Add more test cases
In this PR added exposing client auto update fields (is enabled, and required client tools version for update)
Related: https://github.com/gravitational/teleport/pull/39805/files#diff-8d3c0408dd826f27e9f13cd15f09f4d7e89202862f0b13ce131a2e3072c2a40dR49-R53