`ops.testing` expands framework extensions with the pre-26.04 metadata for 26.04 charms
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Start by reading _FrameworkFactory in Charmcraft's charmcraft/extensions/app.py to see how the base selects V1 vs V2, then look at _apply_extensions in testing/src/scenario/state.py (~line 2247) and the V1-only data in testing/src/scenario/_charmcraft_extensions.py. The data comes from .github/generate_charmcraft_extensions.py, which runs charmcraft init plus expand-extensions, so it needs a 26.04 project added. Reproduce with a charmcraft.yaml using base: [email protected] and extensions: [django-framework]; done means _charm_spec shows the V2 app container and app-secret-key option, with a test covering both base versions.
Written by the indexing model from the issue text.
Description
When ops.testing expands a Charmcraft framework extension (added in #2367), it always uses the version of the extension that Charmcraft applies on Ubuntu 22.04 and 24.04. For a charm on [email protected], Charmcraft uses a V2 version of each of the six framework extensions, so the metadata ops.testing builds doesn't match the packed charm. For example, the V2 Django extension has an app container and a peers peer relation rather than django-app and secret-storage, and a single app-secret-key option in place of django-secret-key and django-secret-key-id.
With a charmcraft.yaml that has base: [email protected] and extensions: [django-framework]:
spec = testing.Context(DemoCharm)._charm_spec
print(sorted(spec.meta['containers']), sorted(spec.meta['peers']))
print(sorted(o for o in spec.config['options'] if 'secret' in o))
['django-app'] ['secret-storage']
['django-secret-key', 'django-secret-key-id']
Charmcraft picks the version in _FrameworkFactory: V1 if any of the charm's bases is one that V1 supports, otherwise V2:
https://github.com/canonical/charmcraft/blob/9bc9e5860895461db3ce8830fd2f1d3bce15d658/charmcraft/extensions/app.py#L145-L155
Our generated data only has V1 in it:
https://github.com/canonical/operator/blob/cec6b6468de2cb93a35647c200d7bab21b4657f3/testing/src/scenario/_charmcraft_extensions.py#L25-L28
and _apply_extensions doesn't look at the base:
https://github.com/canonical/operator/blob/cec6b6468de2cb93a35647c200d7bab21b4657f3/testing/src/scenario/state.py#L2247
We should generate both versions and choose between them by the charm's base, the way Charmcraft does.
- Charmcraft gets the bases from
base, theplatformslabels andbuild-for, and the legacybases(get_project_basesincharmcraft/extensions/extension.py). With no base at all, it uses V2, which is the opposite of what we do now. - The generator (
.github/generate_charmcraft_extensions.py) runscharmcraft init --profile ...andexpand-extensions, so it'll need to produce a 26.04 project as well. - netbox-k8s-operator is a 26.04 Django charm that works around this in its unit tests, by loading its
charmcraft.yaml, adding the V2 container and relations by hand, and passing that asmeta. #2965 would break that workaround, and the obvious fix (deleting it) won't work until this is fixed.
- Dominant language
- Python
- Stars
- 267
- Forks
- 159
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 39
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from canonical/operator
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 3 days
-
docs: reorder interface definition before fetch-libs and link PostgreSQL/library docs in tutorialPossibly taken @mayank145 claimed this 2 days ago. Opendocs rainy day
Difficulty 1/5 Under an hour Newbie friendliness 90/100
canonical/operator#2957 · 3 comments ·
Maintainers usually reply within 3 days
-
test_pull_path_non_ascii_or_trailing_whitespace fails with XPASS(strict)Possibly taken @tonyandrewmeyer claimed this 6 days ago. Opentests
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
canonical/operator#2953 · 2 comments · 1 assignee ·
Maintainers usually reply within 3 days
-
Testing Pebble keeps a check `threshold` of 0 rather than defaulting it to 3Possibly taken @rahulsjha claimed this 4 days ago. Openrainy day small item
Difficulty 2/5 1-3 hours Newbie friendliness 71/100
canonical/operator#2924 · 2 comments ·
Maintainers usually reply within 3 days
-
Cleaning up inconsistencies in the Manage relations how-to pagePossibly taken @tromai claimed this 8 days ago. Opendocs roadmap
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
canonical/operator#2688 · 3 comments · 1 assignee ·
Maintainers usually reply within 3 days
All issues in canonical/operator
Similar issues
-
Bundles Documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pyrevitlabs/pyRevit#4285 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
521xueweihan/HelloGitHub#4574 ·
-
Adopt pr-gate v3.3.0Openarea: ci enhancement perceived difficulty: 1
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Nitjsefnie-Harness-Commons/daedalus#1859 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
meetecho/juturna_nodes#43 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
TigreGotico/text2spoken#726 ·
Maintainers usually reply within 1 day