Skip to content

feat(feature): Use preference cache for 'connect' #416

Merged
m-horky merged 3 commits into
mainfrom
mhorky/cct-2169/connect
Apr 23, 2026
Merged

feat(feature): Use preference cache for 'connect' #416
m-horky merged 3 commits into
mainfrom
mhorky/cct-2169/connect

Conversation

@m-horky
Copy link
Copy Markdown
Collaborator

@m-horky m-horky commented Apr 20, 2026

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-feature flag 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.

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>
@m-horky
Copy link
Copy Markdown
Collaborator Author

m-horky commented Apr 21, 2026

/packit build

@m-horky m-horky marked this pull request as ready for review April 21, 2026 10:02
@m-horky m-horky requested a review from mjcr99 April 21, 2026 10:02
Copy link
Copy Markdown
Contributor

@pkoprda pkoprda left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I have left some comments below.

Comment thread cmd/rhc/connect_cmd.go Outdated
Comment thread cmd/rhc/connect_cmd.go
Comment thread cmd/rhc/connect_cmd.go
@m-horky m-horky marked this pull request as draft April 21, 2026 16:02
@m-horky m-horky force-pushed the mhorky/cct-2169/connect branch from 94c0d45 to c76a2a7 Compare April 22, 2026 10:12
@m-horky m-horky requested a review from pkoprda April 22, 2026 10:15
@m-horky m-horky marked this pull request as ready for review April 22, 2026 10:15
@m-horky m-horky force-pushed the mhorky/cct-2169/connect branch from c76a2a7 to 4d82569 Compare April 22, 2026 10:22
Copy link
Copy Markdown
Contributor

@pkoprda pkoprda left a comment

Choose a reason for hiding this comment

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

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

m-horky added 2 commits April 23, 2026 12:38
* 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>
@m-horky m-horky force-pushed the mhorky/cct-2169/connect branch from 4d82569 to 8611950 Compare April 23, 2026 10:39
@m-horky
Copy link
Copy Markdown
Collaborator Author

m-horky commented Apr 23, 2026

I see some test failures

Good point, fixed.

I've noticed that after using rhc disconnect, the preference status is changed from disabled to enable for every feature.

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."

@m-horky m-horky requested a review from pkoprda April 23, 2026 10:46
Copy link
Copy Markdown
Contributor

@pkoprda pkoprda left a comment

Choose a reason for hiding this comment

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

Alright then, looks good to me, approving. However I hope the code will be refactored at some point.

@m-horky
Copy link
Copy Markdown
Collaborator Author

m-horky commented Apr 23, 2026

The RHEL CI failing on test_logging.py::test_log_connect_with_disabled_feature is being addressed in RedHatInsights/pytest-client-tools#50. Merging.

@m-horky m-horky merged commit 84ef857 into main Apr 23, 2026
22 of 24 checks passed
@m-horky m-horky deleted the mhorky/cct-2169/connect branch April 23, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants