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

feat: support for multi channel licenses #4767

Merged
merged 42 commits into from
Aug 8, 2024

Conversation

pandemicsyn
Copy link
Member

@pandemicsyn pandemicsyn commented Jul 17, 2024

What this PR does / why we need it:

Add's support for multi channel licenses.

Spec & behaviors

  • kots install:
    • Prevalidates that the requested channel is present in the latest license (if online)
    • If channel slug does not match a channel in the license channel list we fail
    • We use the channel slug to determine what channel is being install. If channel slug is missing, default will be stable.
    • The installed channel will be recorded in the app_version.selected_channel_id , we do this by pulling from a new requested_channel_slug configmap entry during install and resolving that to a channel id
      -kots upgrades:
    • We use app.selected_channel_id field to check for upgrades in those channels by passing that on to the replicated api.
  • kots pull:
    • same basic behaviors as install for pre-validation
  • airgap installs:
    • inherits pre validation from kots install minus the the attempt to get the latest license.
    • If channel slug does not match a channel in the license channel list we fail
  • changing channels
    • online installs don't support changing channel in this iteration
    • airgap does as long as the channel is allowed by the license
  • some kots related replicated api calls now include a query param of selectedChannelId to actually pass on what the selected channel is

Which issue(s) this PR fixes:

Fixes https://app.shortcut.com/replicated/story/108865/multi-channel-license-update-kots-to-support-multi-channels

Special notes for your reviewer:

Steps to reproduce

Online install early checks:

# starting config only access to Stable channel:

➜ replicated customer ls
ID                             NAME             CHANNELS        EXPIRES    TYPE    CUSTOM_ID
2jbffGP8wHSWH1l2mA7dM6ZeloV    multitest         Stable         Never      dev     Not Set
➜ bin/kots install --kotsadm-registry=ttl.sh/pandemicsyn --kotsadm-tag 24h floriandev/stable --license-file ~/Downloads/multichan.yaml
➜ replicated customer download-license --customer=2jbffGP8wHSWH1l2mA7dM6ZeloV -o ~/Downloads/multichan.yaml

Simple case where you ask to install a channel not in the licenses fails:

➜ bin/kots install --kotsadm-registry=ttl.sh/pandemicsyn --kotsadm-tag 24h floriandev/beta --license-file ~/Downloads/multichan.yaml
  • Validating registry information ✓
  • Checking for license update ✓
Error: requested channel not found in latest license

If you pass in an outdated license it will declined if the requested channel is not in the latest license:

# remove access to `Stable`
➜ replicated customer update --customer=2jbffGP8wHSWH1l2mA7dM6ZeloV --channel Beta --channel Unstable --default-channel Unstable --name multitest
ID                             NAME         CHANNELS          EXPIRES    TYPE    CUSTOM_ID
2jbffGP8wHSWH1l2mA7dM6ZeloV    multitest     Beta Unstable    Never      dev     Not Set
➜ bin/kots install --kotsadm-registry=ttl.sh/pandemicsyn --kotsadm-tag 24h floriandev/stable --license-file ~/Downloads/multichan.yaml
  • Validating registry information ✓
  • Checking for license update ✓
Error: requested channel not found in latest license

Install proceeds if your requested channel is present (even when its not the default channel):

# now installing with the Beta slug which should succeed
➜ replicated customer download-license --customer=2jbffGP8wHSWH1l2mA7dM6ZeloV -o ~/Downloads/multichan.yaml
➜ yq '.spec.channels' < ~/Downloads/multichan.yaml
- channelID: 2i9fCY11QaVowQWN1O32XFhUIlE
  channelName: Beta
  channelSlug: beta
  endpoint: https://replicated-app-pandemicsyn.okteto.repldev.com
  isSemverRequired: true
- channelID: 2i9fCYatEJfYChzAsL4bClT6E04
  channelName: Unstable
  channelSlug: unstable
  endpoint: https://replicated-app-pandemicsyn.okteto.repldev.com
  isDefault: true
➜ bin/kots install --kotsadm-registry=ttl.sh/pandemicsyn --kotsadm-tag 24h floriandev/beta --license-file ~/Downloads/multichan.yaml
  • Validating registry information ✓
  • Checking for license update ✓
Enter the namespace to deploy to: floriandev
  • Deploying Admin Console
    • Creating namespace ✓
    • Waiting for datastore to be ready ✓

Same pattern for airgap:

➜ yq '.spec.channels' < ~/Downloads/multitest/multitest.yaml
- channelID: 2i9fCY11QaVowQWN1O32XFhUIlE
  channelName: Beta
  channelSlug: beta
  endpoint: https://replicated-app-pandemicsyn.okteto.repldev.com
  isSemverRequired: true
- channelID: 2i9fCYatEJfYChzAsL4bClT6E04
  channelName: Unstable
  channelSlug: unstable
  endpoint: https://replicated-app-pandemicsyn.okteto.repldev.com
  isDefault: true
➜ bin/kots install --kotsadm-registry=ttl.sh/pandemicsyn --kotsadm-tag 24h floriandev/stable --license-file ~/Downloads/multitest/multitest.yaml --airgap-bundle ~/Downloads/multitest/floriandev-0.1.5.airgap
  • Validating registry information ✓
Error: requested channel not found in supplied license
➜ bin/kots install --kotsadm-registry=ttl.sh/pandemicsyn --kotsadm-tag 24h floriandev/beta --license-file ~/Downloads/multitest/multitest.yaml --airgap-bundle ~/Downloads/multitest/floriandev-0.1.5.airgap
  • Validating registry information ✓
  • Checking for license update ✓
Enter the namespace to deploy to: floriandev
  • Deploying Admin Console
    • Creating namespace ✓
    • Waiting for datastore to be ready ✓
Enter a new password for the admin console (6+ characters): ••••••••
  • Waiting for Admin Console to be ready ✓
  • Uploading app archive
  • Waiting for installation to complete ✓

  • Press Ctrl+C to exit
  • Go to http://localhost:8800 to access the Admin Console

With an airgap update via the ui:

Screenshot 2024-07-23 at 9 43 45 AM

Up to date Loom: https://www.loom.com/share/c82e9174906b427196a03a5d16ac3402?sid=7989633f-4ad7-4b86-9a5a-9c28d3ca8705

Does this PR introduce a user-facing change?


- Add's support for at install time license update checks for online installs
- Add's support for multi-channel licenses 

Does this PR require documentation?

@pandemicsyn pandemicsyn added the type::feature New feature or request label Jul 17, 2024
@pandemicsyn pandemicsyn force-pushed the florian/feat/multichan-licenses branch from da82b40 to 8b2c5e3 Compare July 17, 2024 22:12
@pandemicsyn pandemicsyn force-pushed the florian/feat/multichan-licenses branch from da0c0ea to 1355d88 Compare July 19, 2024 18:02
cmd/kots/cli/install.go Outdated Show resolved Hide resolved
pkg/kotsutil/kots.go Outdated Show resolved Hide resolved
pkg/update/update.go Outdated Show resolved Hide resolved
@pandemicsyn
Copy link
Member Author

The approach I took was basically find all occurrences where we using license.spec.ChannelID or license.spec.IsSemverRequired and update those areas. In most cases we now use app.channel_id and then use it or the associated channels IsSemverRequired setting.

For dealing with the backfill of app.channel_id column , i don't proactively do it - and instead only do it when we go to actually use it. If we see app.channel_id is empty we'll try to back fill it.

@pandemicsyn pandemicsyn marked this pull request as ready for review July 23, 2024 15:04
@divolgin
Copy link
Member

This LGTM. One note about backwards compatibility. Right now I can run kots install app-slug/some-channel and then upload a license from any channel. This would not fail with existing versions of kots, and give me a release from the channel in the license, not the one specified on command line.

With this change, single channel license install will start failing. I think we'll need to allow them to proceed. We can call out this change in behavior in release notes, which is probably acceptable.

@pandemicsyn
Copy link
Member Author

With this change, single channel license install will start failing. I think we'll need to allow them to proceed. We can call out this change in behavior in release notes, which is probably acceptable.

@divolgin Let them proceed with an install for the requested (not in license) channel, or proceed but switch over to the default channel in the supplied license? Guessing the later - the default channel.

@sgalsaleh
Copy link
Member

@pandemicsyn we should add an e2e test.

@sgalsaleh
Copy link
Member

I might've missed it, but where does KOTS send the user-selected channel ID to replicated.app?

@pandemicsyn
Copy link
Member Author

This will need https://github.com/replicatedhq/vandoor/pull/5889 but this commit should cover all the endpoints that now accept it on the replicated app side: f38716c

I did skip updating downloadUpgradeBinary call where embedded cluster calls out to get /clusterconfig/artifact/operator , because I wasn't sure if i should actually be updating this one.

@pandemicsyn
Copy link
Member Author

@sgalsaleh @divolgin i centralized the post license sync update of selected_channel_id in fb6e551. I did it in the UpdateAppLicense because that seemed like to safest place to do it for consistencies sake. Let me know if miss-read this, or if theres a better spot though, happy to switch it.

Also nuked that stray selected channel id update in reconcileDeployment in this commit: ab0f4d7

@pandemicsyn
Copy link
Member Author

Ended up centralizing the backfilling, I moved it into store.GetApp() ...tbh...not sure why I didn't stick it there to begin with.

Also, heres a loom of license channel change working (going from "beta" with a v1.0.2 to "unstable" which was up to v1.0.3): https://www.loom.com/share/5b89a5a3423341f881c7510a2149b2fb?sid=4a072c59-b965-47b0-bb2d-7c5187b511c3

pkg/update/update.go Outdated Show resolved Hide resolved
pkg/update/update_test.go Outdated Show resolved Hide resolved
@pandemicsyn
Copy link
Member Author

@sgalsaleh alrighty - pulled in the e2e test changes as well (3961a04) , batched the other pr feedback into a single commit this time since it was pretty small (3cd0a79)

@pandemicsyn pandemicsyn requested a review from sgalsaleh August 7, 2024 15:06
@sgalsaleh sgalsaleh merged commit f02b6e7 into main Aug 8, 2024
112 checks passed
@sgalsaleh sgalsaleh deleted the florian/feat/multichan-licenses branch August 8, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type::feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants