Skip to content
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

Proof-of-concept draft for teleport-update binary implementation #46357

Closed
wants to merge 13 commits into from
16 changes: 16 additions & 0 deletions api/client/webclient/webclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ type Config struct {
Timeout time.Duration
// TraceProvider is used to retrieve a Tracer for creating spans
TraceProvider oteltrace.TracerProvider
// Group is an optional agent group identifier that modulates
// the returned desired agent version update information.
Group string
}

// CheckAndSetDefaults checks and sets defaults
Expand Down Expand Up @@ -171,6 +174,10 @@ func Find(cfg *Config) (*PingResponse, error) {

endpoint := fmt.Sprintf("https://%s/webapi/find", cfg.ProxyAddr)

if cfg.Group != "" {
endpoint = fmt.Sprintf("%s?group=%s", endpoint, cfg.Group)
}

Comment on lines 175 to +180
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The group content is not urlencoded and the query building is fragile. The url lib allows to do this safely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, totally agree, was just using this to test

req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
if err != nil {
return nil, trace.Wrap(err)
Expand Down Expand Up @@ -295,6 +302,8 @@ type PingResponse struct {
Proxy ProxySettings `json:"proxy"`
// ServerVersion is the version of Teleport that is running.
ServerVersion string `json:"server_version"`
// ServerVersion is the version of Teleport that is running.
ServerEdition string `json:"server_edition"`
// MinClientVersion is the minimum client version required by the server.
MinClientVersion string `json:"min_client_version"`
// ClusterName contains the name of the Teleport cluster.
Expand All @@ -303,6 +312,13 @@ type PingResponse struct {
// reserved: license_warnings ([]string)
// AutomaticUpgrades describes whether agents should automatically upgrade.
AutomaticUpgrades bool `json:"automatic_upgrades"`

// AgentAutoupdate specifies whether an agent should update now (not implemented).
AgentAutoupdate bool `json:"agent_autoupdate"`
// AgentVersion contains the target agent version (not implemented).
AgentVersion string `json:"agent_version"`
// AgentUpdateJitterSeconds specifies the amount of jitter to wait before updating (not implemented).
AgentUpdateJitterSeconds int `json:"agent_update_jitter_seconds"`
}

// PingErrorResponse contains the error from /webapi/ping.
Expand Down
3 changes: 3 additions & 0 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ const (
// ComponentProxySecureGRPC represents a secure gRPC server running on Proxy (used for Kube).
ComponentProxySecureGRPC = "proxy:secure-grpc"

// ComponentUpdater represents the agent updater.
ComponentUpdater = "updater"

// VerboseLogsEnvVar forces all logs to be verbose (down to DEBUG level)
VerboseLogsEnvVar = "TELEPORT_DEBUG"

Expand Down
Loading
Loading