-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat: add preferred channel slug #4742
Conversation
cmd/kots/cli/install.go
Outdated
@@ -163,6 +163,11 @@ func InstallCmd() *cobra.Command { | |||
|
|||
upstream := pull.RewriteUpstream(args[0]) | |||
|
|||
preferredChannelSlug := "" | |||
if len(args) > 1 { | |||
preferredChannelSlug = args[1] |
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.
This should be in the same arg as app slug, as shown in the docs: https://docs.replicated.com/reference/kots-cli-install#examples
kubectl kots install kots-sentry/stable
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.
+1
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.
@divolgin @sgalsaleh Just confirming. Right now this would result in having a whole new arg that would be redundant (e.g. kubectl kots install kots-sentry/stable stable
) . But we can just pluck the channel out of the upstreamURI - created right above on line 164 (maybe with ParseReplicatedURL) ?
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.
yes, and it's optional. should default to "stable"
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.
ah cool 👍 will send along one more update to use the default.
pkg/replicatedapp/api.go
Outdated
@@ -40,8 +44,37 @@ type LicenseData struct { | |||
License *kotsv1beta1.License | |||
} | |||
|
|||
func GetPreferredChannelSlug() (string, error) { |
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 would suggest using the existing GetInstallationParams
function:
Line 1144 in 2dae2bf
func GetInstallationParams(configMapName string) (InstallationParams, error) { |
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.
Example usage:
kots/pkg/automation/automation.go
Lines 238 to 241 in 2dae2bf
instParams, err := kotsutil.GetInstallationParams(kotsadmtypes.KotsadmConfigMap) | |
if err != nil { | |
return errors.Wrap(err, "failed to get existing kotsadm config map") | |
} |
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.
Also, if you don't mind, can you just have that GetInstallationParams
always use kotsadmtypes.KotsadmConfigMap
and not have to accept it as a parameter?
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.
@sgalsaleh safe for me to update RemoveAppVersionLabelFromInstallationParams
while im at it?
Line 1313 in 2dae2bf
func RemoveAppVersionLabelFromInstallationParams(configMapName string) error { |
Has the same func sig and inline use of configMapName
as GetInstallationParams
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.
fyi - went ahead updated RemoveAppVersionLabelFromInstallationParams
too (but easy to undo if I shouldn't have).
pkg/replicatedapp/api.go
Outdated
url := fmt.Sprintf("%s/license/%s", license.Spec.Endpoint, license.Spec.AppSlug) | ||
if channelSlug != "" { | ||
url = fmt.Sprintf("%s/%s", url, channelSlug) |
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.
just to confirm, is the idea that this decision will be recorded by replicated.app and this channel will be used automatically by replicated.app for subsequent requests?
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.
@sgalsaleh i think the answer is yes. At least for requests to this endpoint, I'm not sure how this plays out in other areas. But hoping @marccampbell or maybe @divolgin can confirm.
Over on the pending replicated.app pr from Siva he mentioned:
We now check for the existence of a row in the license_instance table. If it exists, we use the channelId from that table to generate the license in L245. This prevents the downstream from switching channels once initialized and recorded on the license_instance table.
And does look like it actually does that. If there was a licenseInstance entry it will use that channel id instead:
license = await stores.licenseStore.getLicenseFromIdAndChannelSlugId(licenseInstance.licenseId, licenseInstance.downstreamChannelId);
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.
Hard to comment on code that has been removed 😄 :
- Handler still has channel slug in it while client does not?:
@Get("/:appSlug/:channelSlug")
- Instance data is recoded asynchronously and may be delayed.
- When channel on a license changes, instance can make any number of requests before reporting new channel
- There is also a distinction between what channel license is assigned to and what channel is currently deployed
- This should be tested e2e with a channel other than "stable" with a brand new instance
closing in favor of (wip) #4767 |
Allows KOTS to bootstrap with a preferred channel slug to support multi-channel licenses.
When you
kubectl kots install my-app beta
, KOTS will now store the preferred channel slugbeta
in a ConfigMap.This will allow KOTS to hit a new upstream endpoint in
replicated-app
-/license/:appSlug/:channelSlug
to download the definitive channel specific licenseWhat this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Steps to reproduce
Does this PR introduce a user-facing change?
Does this PR require documentation?