Skip to content

feat: Improved Refresh() Varlink method - #634

Merged
jirihnidek merged 1 commit into
mainfrom
jhnidek/varlink_improved_refresh_method
Nov 10, 2026
Merged

jirihnidek merged 1 commit into
mainfrom
jhnidek/varlink_improved_refresh_method

Conversation

@jirihnidek

@jirihnidek jirihnidek commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor
  • Card ID: CCT-1865
  • Method com.redhat.rhsm.testing.content.Refresh() returns information about updated entitlement certificate and key. The returned object could look like this now:
{
  "result" : {
    "certificate_path" : "/etc/pki/entitlement/8892792528256186296.pem",
    "key_path" : "/etc/pki/entitlement/8892792528256186296-key.pem"
  }
}
  • It is more useful than return always: "success": true
  • It also returns specific error: com.redhat.rhsm.testing.content.CertificateUpToDate, when certificate is up-to-date. There is nothing wrong about this approach. E.g. many systemd Varlink methods return custom errors to signal various normal states. This approach is IMHO more elegant than returning object with some boolean attribute signaling some state or returning object with result and some boolean attribute signaling some state.
  • Modified .varlink definition file accordingly
  • When redhat.repo file is not possible to write, then return appropriate error
  • The redhat.repo file is regenerated by Refresh() method, when something or somebody deleted this file
  • Modified and improved integration tests; added a new JSON schema for object returned by Refresh()
  • Found one issue in rhc-server and added commented integration test for this case. It will be fixed in rhsm2

Assisted by: Claude Opus 5.5

@jirihnidek
jirihnidek requested review from a team as code owners November 4, 2026 15:18
@jirihnidek
jirihnidek force-pushed the jhnidek/varlink_improved_refresh_method branch 2 times, most recently from e0dd96f to ae42b0f Compare November 6, 2026 14:16
@DuckBoss
DuckBoss self-requested a review November 6, 2026 15:50

@DuckBoss DuckBoss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have some small requests, but overall it looks good.

Comment thread features/steps/test_content.py Resolved
Comment thread features/steps/test_content.py Resolved
Comment thread go.sum Resolved
Comment thread cmd/rhc-server/rhc-server.go Resolved
@jirihnidek

Copy link
Copy Markdown
Contributor Author

This PR is blocking another PR for our libdnf5 plugin: candlepin/rhsm-dnf5-plugins#31

Comment thread cmd/rhc-server/rhc-server.go Resolved

@Peto-RH Peto-RH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR looks already good to me. I have just one nit comment.

Comment thread cmd/rhc-server/rhc-server.go Resolved
* Card ID: CCT-1865
* Method com.redhat.rhsm.testing.content.Refresh() returns
  information about updated entitlement certificate and key.
  The returned object could look like this:
```json
{
  "result" : {
    "certificate_path" : "/etc/pki/entitlement/8892792528256186296.pem",
    "key_path" : "/etc/pki/entitlement/8892792528256186296-key.pem"
  }
}
```
* It also returns specific error:
    `com.redhat.rhsm.testing.content.CertificateUpToDate`,
  when certificate is up-to-date. There is nothing wrong
  about this approach. Many systemd Varlink methods return
  custom errors to signal various normal states.
* Modified .varlink definition file accordingly
* When redhat.repo file is not possible to write, then
  return appropriate error
* The `redhat.repo` file is regenerated by Refresh() method,
  when something or somebody deleted this file
* Modified and improved integration tests; added a new JSON schema
  for object returned by Refresh()
* Found one issue in rhc-server and added commented integration
  test for this case. It will be fixed in rhsm2
* Updated go.mod

Assisted by: Claude Opus 5.5

Signed-off-by: Jiri Hnidek <jhnidek@redhat.com>
@jirihnidek
jirihnidek force-pushed the jhnidek/varlink_improved_refresh_method branch from 9b1587a to c9326d5 Compare November 10, 2026 13:47
@jirihnidek
jirihnidek requested a review from Peto-RH November 10, 2026 13:49

@Peto-RH Peto-RH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@stephenbourke stephenbourke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@DuckBoss DuckBoss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

@jirihnidek
jirihnidek merged commit cd28c3c into main Nov 10, 2026
29 checks passed
@jirihnidek
jirihnidek deleted the jhnidek/varlink_improved_refresh_method branch November 10, 2026 15:28
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.

4 participants