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

Separate CIS and USG in the client #3344

Merged
merged 9 commits into from
Oct 23, 2024
Merged

Separate CIS and USG in the client #3344

merged 9 commits into from
Oct 23, 2024

Conversation

renanrodrigo
Copy link
Member

@renanrodrigo renanrodrigo commented Oct 8, 2024

Why is this needed?

This PR solves all of our problems because it implements the changes needed to turn USG into an actual resource on the client side. This aligns client behaviour with the implementation done for the backend

Test Steps

kept behavior:

  • enabling CIS should work on X, B
  • enabling USG should work on J
  • both should work on F, but USG gets enabled in both cases , with a message telling about the transition

new behavior:

  • upgrading from older versions of pro client where CIS was enabled as USG on F, J should enable the actual USG resource

Integration tests TBD

  • (un)check this to re-run the checklist action

Copy link

github-actions bot commented Oct 8, 2024

PR Checklist

How to use this checklist

How to use this checklist

PR Author

For each section, check a box when it is true.
Uncheck a box if it becomes un-true.
Then check the box at the bottom of the PR description to re-run the action that creates this checklist.
The action that creates and updates this comment will retain your edits.
The action will fail if the checklist is not completed.

PR Reviewer

Check that the PR checklist action did not fail.
Double check that the author filled out the checklist accurately.
If you disagree with a checklist item, start a conversation.
For example, the author may say they don't think integration tests are necessary, but you may disagree.

Bug References

None.

Confirm

  • I've properly referenced all bugs that this PR fixes
How to properly reference fixed bugs
  • If this PR is related to a Jira item, include an SC-1234 reference in the PR title
  • If this PR is fixes a GitHub issue, include a Fixes: #1234 reference in the commit that fixes the issue
  • If this PR is fixes a Launchpad bug, include a LP: #12345678 reference in the commit that fixes the issue

Test Updates

Unit Tests

  • I have updated or added any unit tests accordingly
  • No unit test changes are necessary for this change

Integration Tests

  • I have updated or added any integration tests accordingly
  • No integration test changes are necessary for this change

Documentation

  • Changes here need to be documented and I have referenced the docs PR in the description
  • No documentation updates are necessary for this change

Does this PR require review from someone outside the core ubuntu-pro-client team?

  • Yes, and I have requested those reviews via GitHub
  • No

uaclient/cli/enable.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@orndorffgrant orndorffgrant left a comment

Choose a reason for hiding this comment

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

Looking good! A few little things.
I guess we can't really test yet until the resource is up on the backend

lib/postinst-migrations.sh Outdated Show resolved Hide resolved
uaclient/entitlements/tests/test_base.py Outdated Show resolved Hide resolved
uaclient/cli/enable.py Outdated Show resolved Hide resolved
# On Focal and Jammy, the CIS service transitioned to USG from v35
# This changes the lists and authentication files to represent that
# in case CIS is enabled
if [ "$VERSION_ID" = "20.04" ] || [ "$VERSION_ID" = "22.04" ]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

The only thing missing in this PR now is integration tests. I have manually tested it many times up to the point where we can without the backends, and will have the behave stuff in place asap

Get rid of valid_names, called_name and related functionality, so
entitlements are called only by the name defined for them.

Signed-off-by: Renan Rodrigo <[email protected]>
The entitlement classes list now returns a different value for xenial
and bionic, which includes cis, and for the other releases, which
includes usg

Signed-off-by: Renan Rodrigo <[email protected]>
This way it is easier to test, as the return value is not determined at
import time.

Signed-off-by: Renan Rodrigo <[email protected]>
As Focal is the only series to ever have both of the services in a valid
state at different times, there is a particular path to enable USG
instead of CIS when users call `pro enable cis`. A specific message is
shown on the CLI to tell users that it changed.

Signed-off-by: Renan Rodrigo <[email protected]>
@renanrodrigo
Copy link
Member Author

@orndorffgrant @lucasmoura this is done feature-wise, just missing the beave testing.
If you want to merge this to finalize the release code, I can send a separate PR with just the tests.

The old CIS entitlement will not be recognized on Focal and Jammy after
version 35. This converts the .list file and changes cis/ to usg/ both
in the source and authentication files when running on these series.

Signed-off-by: Renan Rodrigo <[email protected]>
and system.get_release_info().series == "focal"
):
service_to_enable = "usg"
USGEntitlement.cis_version = True
Copy link
Collaborator

Choose a reason for hiding this comment

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

sneaky sneaky heheh

we're going to love hating this
or hate loving this? unclear

but I see the compromises made and I'm happy with it. +1

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm hate hating this for years now I hate this part a little less

Copy link
Collaborator

@orndorffgrant orndorffgrant left a comment

Choose a reason for hiding this comment

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

I'm okay merging this ahead of integration tests, but would like @lucasmoura to approve as well before we do

We are now sorting the entitlements by name which requires
a test change
@orndorffgrant orndorffgrant enabled auto-merge (rebase) October 23, 2024 14:12
@orndorffgrant orndorffgrant merged commit 68b1906 into main Oct 23, 2024
20 of 25 checks passed
@orndorffgrant orndorffgrant deleted the usg-now branch October 23, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants