Skip to content

docs: tidy up the manage resources guide - #2720

Open
tonyandrewmeyer wants to merge 1 commit into
canonical:mainfrom
tonyandrewmeyer:fix/2490-manage-resources
Open

docs: tidy up the manage resources guide#2720
tonyandrewmeyer wants to merge 1 commit into
canonical:mainfrom
tonyandrewmeyer:fix/2490-manage-resources

Conversation

@tonyandrewmeyer

@tonyandrewmeyer tonyandrewmeyer commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

A quality pass over the "How to manage resources" guide, which had collected a few things: the example handler was a module-level function that nonetheless took self, the status message had a misplaced quote (resource 'my-resource; run ... for more info'), there was a comment musing about whether to reraise, logger.error(e) where the rest of the guides use logger.exception, and open(resource_path, 'r') on something fetch() returns as a Path.

I've also swapped the two except blocks so NameError comes first. Resources.fetch checks the name before it calls resource_get, and its docstring lists NameError first, so the guide was reading in the opposite order to the implementation. The sentence after the block now says what each exception actually means, rather than the previous single "does not exist" clause that only covered one of them.

The unit-test example used a foo OCI-image resource while the charmcraft.yaml above it declares a my-resource file resource, so I've made those match. One leftover > See first: blockquote in the integration-tests section is converted too - #2666 swept the file, but #2662 added that section afterwards.

Preview.

Fixes #2490

The example was a module-level function that took self, caught
ModelError before NameError even though fetch checks the name first,
had a misplaced quote in one of the status messages, opened a Path as
though it were a string, and carried a design musing in a comment.

Rewrite it as a charm method, say what each of the two exceptions
actually means, and use my-resource consistently in the unit-test
example so it lines up with the charmcraft.yaml above it.
@tonyandrewmeyer
tonyandrewmeyer marked this pull request as ready for review August 31, 2026 04:08
@tonyandrewmeyer

Copy link
Copy Markdown
Collaborator Author

@dwilding I've fixed the 'bugs' on the page, but I'm not sure this covers the 'quality' that the issue is asking for. Did you have specific things in mind? Should we be talking more about what you use resources for, or would you know that by the time you get to the how-to guide? I think there's a distinct difference between K8s and machine, should this take that into account more strongly? Might be a good one to talk over in our 1-1?

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.

Refresh "Manage resources" how-to guide

1 participant