Skip to content

hwclt: Add cache for requests#562

Draft
sergio-costas wants to merge 8 commits into
canonical:mainfrom
sergio-costas:add-cache-fields
Draft

hwclt: Add cache for requests#562
sergio-costas wants to merge 8 commits into
canonical:mainfrom
sergio-costas:add-cache-fields

Conversation

@sergio-costas

@sergio-costas sergio-costas commented Jun 11, 2026

Copy link
Copy Markdown

This PR adds a cache to preserve the latest state, and defines the cases where the cache has to be invalidated and the Certification Status must be requested again.

By default, the cache is stored at $SNAP_DATA, since the idea is to go full-snap.

  • Unit tests
  • Manual testing steps:

Built it and tested both "as-is" and with "sudo", both without parameters and with a wrong "--server" parameter. The first one returned, as expected, an error because it can't collect the data. The second succeeds. The third fails, as expected, with an error because the server doesn't return the expected data format.

Now it always returns a JSON through STDOUT, but if there is an error, it will also return it through STDERR as before.

Checklist

Still require more unitary tests.

  • I have followed the contribution guidelines.
  • I have signed the Canonical CLA.
  • I have added necessary tests.
  • I have added or updated any relevant documentation (if needed).
  • I have tested the changes.

Additional Notes

@sergio-costas

Copy link
Copy Markdown
Author

@pedro-avalos This is a proposal for adding the cache fields. What do you think?

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.52941% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.68%. Comparing base (aaab7e7) to head (513569a).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #562      +/-   ##
==========================================
- Coverage   89.17%   85.68%   -3.50%     
==========================================
  Files          29       29              
  Lines        1423     1781     +358     
  Branches        5        0       -5     
==========================================
+ Hits         1269     1526     +257     
- Misses        154      255     +101     
Flag Coverage Δ *Carryforward flag
charm 100.00% <ø> (ø) Carriedforward from 72c8247
client 80.62% <ø> (+0.37%) ⬆️ Carriedforward from 72c8247
server 96.97% <ø> (ø) Carriedforward from 72c8247

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
Server 96.85% <ø> (ø)
Charm 100.00% <ø> (+5.33%) ⬆️
Client 77.87% <73.52%> (-2.38%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pedro-avalos pedro-avalos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you once again for the contribution and great ideas you've brought to Hardware API. I really appreciate the thought you've put behind your spec and willingness to contribute. I've laid out some feedback to make these changes in what I think could be a more structured form.

Comment thread client/bin/hwctl.rs
Comment thread client/src/models/response_validators.rs
@sergio-costas sergio-costas force-pushed the add-cache-fields branch 2 times, most recently from f04963d to e0ae82f Compare June 16, 2026 16:23
@sergio-costas

Copy link
Copy Markdown
Author

@pedro-avalos Completed a proposal for the cache. Can you check it when you have some spare time just to ensure that is what you want, please?

@sergio-costas sergio-costas changed the title hwclt: Add cache extra data in JSON hwclt: Add cache for requests Jun 19, 2026
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