Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1589,9 +1589,8 @@ func (h *Handler) installer(w http.ResponseWriter, r *http.Request, p httprouter
// By default, it uses the stable/v<majorVersion> channel.
repoChannel := fmt.Sprintf("stable/%s", version)

// However, when Automatic Upgrades are on and cluster is part of cloud,
// it will use the stable/cloud channel.
if feats.Cloud && feats.AutomaticUpgrades {
// For Teleport Cloud installations, use the `stable/cloud` channel.
if feats.Cloud {
repoChannel = stableCloudChannelRepo
}

Expand Down
9 changes: 3 additions & 6 deletions lib/web/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,7 @@ echo AutomaticUpgrades: {{ .AutomaticUpgrades }}
// Variables must be injected
require.Contains(t, responseString, "echo Teleport-v")
require.Contains(t, responseString, "echo Repository Channel: stable/v")
require.NotContains(t, responseString, "echo Repository Channel: stable/cloud")
require.Contains(t, responseString, "echo AutomaticUpgrades: false")
})
t.Run("cloud with automatic upgrades", func(t *testing.T) {
Expand Down Expand Up @@ -2514,19 +2515,15 @@ echo AutomaticUpgrades: {{ .AutomaticUpgrades }}

responseString := string(re.Bytes())

// The repo's channel to use is stable/v<majorVersion>
require.Contains(t, responseString, "stable/v")
require.NotContains(t, responseString, "stable/cloud")
require.Contains(t, responseString, "stable/cloud")
})
t.Run("default-agentless-installer", func(t *testing.T) {
re, err := wc.Get(s.ctx, wc.Endpoint("webapi", "scripts", "installer", "default-agentless-installer"), url.Values{})
require.NoError(t, err)

responseString := string(re.Bytes())

// The repo's channel to use is stable/v<majorVersion>
require.Contains(t, responseString, "stable/v")
require.NotContains(t, responseString, "stable/cloud")
require.Contains(t, responseString, "stable/cloud")
})
})
}
Expand Down
14 changes: 5 additions & 9 deletions lib/web/join_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,11 @@ func (h *Handler) createTokenHandle(w http.ResponseWriter, r *http.Request, para
func (h *Handler) getNodeJoinScriptHandle(w http.ResponseWriter, r *http.Request, params httprouter.Params) (interface{}, error) {
scripts.SetScriptHeaders(w.Header())

useStableCloudChannelRepo := h.ClusterFeatures.AutomaticUpgrades && h.ClusterFeatures.Cloud

settings := scriptSettings{
token: params.ByName("token"),
appInstallMode: false,
joinMethod: r.URL.Query().Get("method"),
stableCloudChannelRepo: useStableCloudChannelRepo,
stableCloudChannelRepo: h.ClusterFeatures.Cloud,
installUpdater: automaticUpgrades(h.ClusterFeatures),
}

Expand Down Expand Up @@ -253,14 +251,12 @@ func (h *Handler) getAppJoinScriptHandle(w http.ResponseWriter, r *http.Request,
return nil, nil
}

useStableCloudChannelRepo := h.ClusterFeatures.AutomaticUpgrades && h.ClusterFeatures.Cloud

settings := scriptSettings{
token: params.ByName("token"),
appInstallMode: true,
appName: name,
appURI: uri,
stableCloudChannelRepo: useStableCloudChannelRepo,
stableCloudChannelRepo: h.ClusterFeatures.Cloud,
installUpdater: automaticUpgrades(h.ClusterFeatures),
}

Expand All @@ -283,12 +279,10 @@ func (h *Handler) getAppJoinScriptHandle(w http.ResponseWriter, r *http.Request,
func (h *Handler) getDatabaseJoinScriptHandle(w http.ResponseWriter, r *http.Request, params httprouter.Params) (interface{}, error) {
scripts.SetScriptHeaders(w.Header())

useStableCloudChannelRepo := h.ClusterFeatures.AutomaticUpgrades && h.ClusterFeatures.Cloud

settings := scriptSettings{
token: params.ByName("token"),
databaseInstallMode: true,
stableCloudChannelRepo: useStableCloudChannelRepo,
stableCloudChannelRepo: h.ClusterFeatures.Cloud,
installUpdater: automaticUpgrades(h.ClusterFeatures),
}

Expand Down Expand Up @@ -397,6 +391,8 @@ func getJoinScript(ctx context.Context, settings scriptSettings, m nodeAPIGetter

// By default, it will use `stable/v<majorVersion>`, eg stable/v12
repoChannel := ""

// For Teleport Cloud installations, use the `stable/cloud` channel.
if settings.stableCloudChannelRepo {
repoChannel = stableCloudChannelRepo
}
Expand Down
13 changes: 2 additions & 11 deletions lib/web/join_tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,23 +954,14 @@ func TestJoinScript(t *testing.T) {
" fi\n",
)
})
t.Run("cloud and automatic upgrades", func(t *testing.T) {
t.Run("using stable/cloud channel", func(t *testing.T) {
script, err := getJoinScript(context.Background(), scriptSettings{token: validToken, stableCloudChannelRepo: true}, m)
require.NoError(t, err)
// Uses the stable/cloud channel.
require.Contains(t, script, "REPO_CHANNEL='stable/cloud'")
})
t.Run("cloud but automatic upgrades disabled", func(t *testing.T) {
// Using the Enterprise Version, the package name must be teleport-ent
modules.SetTestModules(t, &modules.TestModules{
TestFeatures: modules.Features{
Cloud: true,
AutomaticUpgrades: false,
},
})
t.Run("not hard-coding a particular channel", func(t *testing.T) {
script, err := getJoinScript(context.Background(), scriptSettings{token: validToken, stableCloudChannelRepo: false}, m)
require.NoError(t, err)
// Setting an empty string, means it will use `stable/v<majorVersion>` later on.
require.Contains(t, script, "REPO_CHANNEL=''")
})
})
Expand Down