feat(feature): Use preference cache for 'connect' #416
Conversation
This patch adds a warning icon the UI can display. Some situations cannot be expressed with only Ok, Info and Error: a feature level being skipped during 'connect' because its dependency failed fits none of those categories. Signed-off-by: mhorky <mhorky@redhat.com> Assisted-by: Claude Code <noreply@anthropic.com>
|
/packit build |
pkoprda
left a comment
There was a problem hiding this comment.
Thanks for the PR, I have left some comments below.
94c0d45 to
c76a2a7
Compare
c76a2a7 to
4d82569
Compare
pkoprda
left a comment
There was a problem hiding this comment.
Thanks for the updates.
I see some test failures:
FAILED integration-tests/test_connect.py::test_connect_with_single_feature_disabled[content]
FAILED integration-tests/test_connect.py::test_connect_with_feature_enabled_disabled_combinations[enabled_features6-disabled_features6-None-True]
FAILED integration-tests/test_connect.py::test_connect_with_nonexistent_feature[--enable-feature]
FAILED integration-tests/test_connect.py::test_connect_with_nonexistent_feature[--disable-feature]
Also I've noticed that after using rhc disconnect, the preference status is changed from disabled to enable for every feature. Is that expected?
# rhc configure features status
Not connected to Red Hat.
FEATURE PREFERENCE DESCRIPTION
content enable Red Hat content management
analytics enable Red Hat Lightspeed data collection
remote-management enable Red Hat Lightspeed remote management
# rhc configure features disable analytics
During registration, 'remote-management' will not be enabled (depends on 'analytics').
During registration, 'analytics' will not be enabled.
# rhc configure features status
Not connected to Red Hat.
FEATURE PREFERENCE DESCRIPTION
content enable Red Hat content management
analytics skip Red Hat Lightspeed data collection
remote-management skip Red Hat Lightspeed remote management
# rhc connect
Connecting kvm-03-guest10.lab.eng.rdu2.dc.redhat.com to Red Hat. Enabled features: content.
This might take some time.
Username: pkoprda_ethel
Password:
[✓] Connected to Red Hat Subscription Management
[✓] Content ... Red Hat repository file generated
[●] Analytics ... Skipped
[●] Remote Management ... Skipped
Successfully connected to Red Hat!
Manage your connected systems: https://red.ht/connector
# rhc configure features status
Connected to Red Hat.
FEATURE STATE DESCRIPTION
content enabled Red Hat content management
analytics disabled Red Hat Lightspeed data collection
remote-management disabled Red Hat Lightspeed remote management
# rhc disconnect
Disconnecting kvm-03-guest10.lab.eng.rdu2.dc.redhat.com from Red Hat.
This might take a few seconds.
[●] The yggdrasil service is already inactive
[●] Already disconnected from Red Hat Lightspeed (formerly Insights)
[✓] Disconnected from Red Hat Subscription Management
# rhc configure features status
Not connected to Red Hat.
FEATURE PREFERENCE DESCRIPTION
content enable Red Hat content management
analytics enable Red Hat Lightspeed data collection
remote-management enable Red Hat Lightspeed remote management
* Card ID: CCT-2169 Update 'rhc connect' code to use preference feature cache and the new feature resolution logic. When 'rhc configure features' is run on a system that is not registered, a preference cache is written to the filesystem. Later, during 'connect', this cache is loaded and used as if '--enable-feature' or '--disable-feature' have been passed in to the command. If these flags are passed in, the preference cache is ignored and a notice is displayed to the user. Previous commit incorrectly didn't include remote-managemt's reliance on content, that is fixed as well. Signed-off-by: mhorky <mhorky@redhat.com> Assisted-by: Claude Code <noreply@anthropic.com>
- Fix grammar - Add TODOs - Add comments Signed-off-by: mhorky <mhorky@redhat.com> Assisted-by: Claude Code <noreply@anthropic.com>
4d82569 to
8611950
Compare
Good point, fixed.
Yeah, this is part of the design. It might not be obvious this way, but the other would also be complicated: let's say you run 'rhc configure features disable remote-management, 'rhc connect', 'rhc configure features enable remote-management', 'rhc disconnect', 'rhc connect'. Should yggdrasil be enabled or not? We decided to go with the simple-to-document way of "you always have to do the configuration before you connect, no matter the previous state." |
pkoprda
left a comment
There was a problem hiding this comment.
Alright then, looks good to me, approving. However I hope the code will be refactored at some point.
|
The RHEL CI failing on |
First commit adds a warning icon the UI can display. Some situations cannot be expressed with only Ok, Info and Error: a feature level being skipped during 'connect' because its dependency failed fits none of those categories.
Second commit updates 'rhc connect' code to use preference feature cache and the new feature resolution logic. When 'rhc configure features' is run on a system that is not registered, a preference cache is written to the filesystem. Later, during 'connect', this cache is loaded and used as if '--enable-feature' or '--disable-feature' have been passed in to the command. If these flags are passed in, the preference cache is ignored and a notice is displayed to the user.
Third commit does clean-up and adds TODOs and comments.
To test this PR, perform various combinations of 'rhc configure features' followed by 'rhc connect'. Whatever 'rhc configure features status' shows before registration should be applied during registration. If
--enable|disable-featureflag is passed during registration, anything defined with 'rhc configure' is ignored.I'm aware of the size and amount of individual changes in the second commit, but I did not find a better way to split it up even more. I think the best way to review the functionality is to look at it as a black-box, without trying to mentally parse the differences in behavior.