Skip to content

docs: add doc about subordinate charms#2455

Open
dwilding wants to merge 8 commits into
canonical:mainfrom
dwilding:subordinate-doc
Open

docs: add doc about subordinate charms#2455
dwilding wants to merge 8 commits into
canonical:mainfrom
dwilding:subordinate-doc

Conversation

@dwilding
Copy link
Copy Markdown
Contributor

@dwilding dwilding commented Apr 27, 2026

This PR adds an explanation doc about subordinate charms. My intention is to give a summary of what a subordinate charm is, when it's appropriate to write a subordinate charm, and some of the considerations. This isn't meant to be a detailed guide on how to write a subordinate charm.

Preview doc

Co-authored-by: Copilot <copilot@github.com>
Comment thread docs/explanation/subordinate-charms.md Outdated
Comment thread docs/explanation/subordinate-charms.md Outdated
@dwilding dwilding marked this pull request as ready for review April 30, 2026 03:23
@dwilding
Copy link
Copy Markdown
Contributor Author

Draft doc updated per our discussion at daily. Ready for review - thanks

Comment thread docs/explanation/subordinate-charms.md Outdated
Comment thread docs/explanation/subordinate-charms.md Outdated

## Runtime constraints

A subordinate charm can't control the Ubuntu base that its units run on. If the principal charm supports multiple bases, consider publishing a separate revision of the subordinate charm for each base.
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.

Talking about "the" principal charm like this seems wrong, since the subordinate doesn't know what principal it is deployed with.

I'm still not clear why a subordinate charm can't control the base that it runs on. I assume it still has to declare its bases in charmcraft.yaml. Does Juju just ignore it?

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.

I believe it will error if the charm isn't available for the base the principal is delayed on.

Maybe this would be better as encouragement to support as many bases as possible? Something about the base having to match the principal, so it's good to handle as many LTS bases as feasible.

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 believe it will error if the charm isn't available for the base the principal is delayed on.

Like if you try to deploy a regular charm on a machine with the wrong base?

I think what we're getting at here is that with a principal charm, you can pretty easily say you run on only one specific base, and only your direct users care. Whereas a subordinate charm may have interest from users of different principal charms across different bases.

But TBH I don't think this difference is all that substantial -- in either case you have to find out what your users need and what you can afford to support.

Maybe this would be better as encouragement to support as many bases as possible? Something about the base having to match the principal, so it's good to handle as many LTS bases as feasible.

What I want to push back against (until I understand it further, at least) is the idea that subordinate charms need to support arbitrary bases.

Sure, someone might want to deploy you on Ubuntu 20.04 with their principal charm that runs there, and it would be a shame if they couldn't, but the same is true of principal charms. I just don't see the difference between "there's a user who wants to deploy our charm on an old base", and "there's a user who wants to deploy our charm on an old base alongside another charm".

It seems like developers of subordinate charms should be able to be just as clear about their supported bases and support periods as any other charm. But maybe there's something I'm missing here.

Copy link
Copy Markdown
Contributor Author

@dwilding dwilding May 7, 2026

Choose a reason for hiding this comment

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

James and I discussed this today. Our thinking is that for now it's best to focus on the importance of documenting the subordinate charm's support for bases - at least until we work on #2460.

Updated wording:

A subordinate charm can’t control the Ubuntu base that its units run on. When you document which charms your subordinate charm is intended to be used with, mention any differences in supported bases.

Copy link
Copy Markdown
Collaborator

@tonyandrewmeyer tonyandrewmeyer left a comment

Choose a reason for hiding this comment

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

I think we should link to the Juju docs, at least https://documentation.ubuntu.com/juju/latest/reference/charm/#subordinate-charm and maybe https://documentation.ubuntu.com/juju/latest/reference/relation/#subordinate-relation.

I think what we really need is a how-to for writing a subordinate that goes alongside this explanation. But happy to leave that for another cycle.

A few general comments noted as well. I'm approving now so I don't block things while travelling. I assume you and James can narrow down the bits left, including the comments I've left and whether they should be addressed or not.

Comment thread docs/explanation/subordinate-charms.md
Comment thread docs/explanation/subordinate-charms.md Outdated
Comment thread docs/explanation/subordinate-charms.md Outdated

## Runtime constraints

A subordinate charm can't control the Ubuntu base that its units run on. If the principal charm supports multiple bases, consider publishing a separate revision of the subordinate charm for each base.
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.

I believe it will error if the charm isn't available for the base the principal is delayed on.

Maybe this would be better as encouragement to support as many bases as possible? Something about the base having to match the principal, so it's good to handle as many LTS bases as feasible.

Comment thread docs/explanation/subordinate-charms.md Outdated
Comment on lines +32 to +33
<!-- TODO when ref target is available (from https://github.com/juju/juju/pull/22373) -->
<!-- See {external+juju:ref}`Juju | The implicit juju-info relation <the-implicit-juju-info-relation-endpoint>`. -->
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Uncomment this before merging

Copy link
Copy Markdown
Contributor

@james-garner-canonical james-garner-canonical left a comment

Choose a reason for hiding this comment

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

Looks great, thanks @dwilding.

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.

3 participants