Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charmcraft snap doesn't work with snap parallel installs #1770

Open
samuelallan72 opened this issue Jul 30, 2024 · 6 comments · May be fixed by #1950
Open

charmcraft snap doesn't work with snap parallel installs #1770

samuelallan72 opened this issue Jul 30, 2024 · 6 comments · May be fixed by #1950
Assignees
Labels
blocked Waiting on a third party to finish something before this can be further processed Bug Something isn't working triaged

Comments

@samuelallan72
Copy link

Bug Description

Now that charms are beginning to be upgraded to use charmcraft 3, I want to have charmcraft v2 and v3 installed so I can work with all the charms I need to. I tried to do this for the snap using the "parallel installs" feature:

sudo snap install charmcraft --channel latest/stable --classic
sudo snap install charmcraft_3 --channel 3.x/beta --classic

But this failed (see logs section). It appears that charmcraft is trying to access a hardcoded path that doesn't exist on the parallel install?

To Reproduce

  1. install charmcraft 2 and 3 snaps with the parallel install feature (note the underscore postfix):
sudo snap install charmcraft --channel latest/stable --classic
sudo snap install charmcraft_3 --channel 3.x/beta --classic
  1. try to use charmcraft_3 to build a charm.

Environment

Ubuntu 24.04 LTS

charmcraft.yaml

type: charm

parts:
  charm:
    plugin: dump
    source: .

base: [email protected]
platforms:
  amd64:
    build-on: amd64
    build-for: amd64
  arm64:
    build-on: arm64
    build-for: arm64
  ppc64el:
    build-on: ppc64el
    build-for: ppc64el
  s390x:
    build-on: s390x
    build-for: s390x

Relevant log output

# here I already have charmcraft 2.7 installed:
$ sudo snap install charmcraft --channel latest/stable --classic

---

$ sudo snap install charmcraft_3 --channel 3.x/beta --classic
charmcraft_3 (3.x/candidate) 3.1.1 from Canonical✓ installed
Channel 3.x/beta for charmcraft_3 is closed; temporarily forwarding to 3.x/candidate.

$ charmcraft_3 -v pack
Starting charmcraft, version 3.1.1
Logging execution to '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20240730-111057.635886.log'
Launching managed ubuntu 24.04 instance...
Creating new instance from remote
Creating new base instance from remote
Creating new instance from base instance
Starting instance
Starting charmcraft version 2.7.1
Logging execution to '/tmp/charmcraft.log'
Bad charmcraft.yaml content:
- extra field 'base' not permitted in top-level configuration
- extra field 'platforms' not permitted in top-level configuration
Failed to execute charmcraft in instance.
Full execution log: '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20240730-111057.635886.log'

$ sudo snap remove charmcraft
charmcraft removed

$ charmcraft_3 -v pack
Starting charmcraft, version 3.1.1
Logging execution to '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20240730-112715.840030.log'
Launching managed ubuntu 24.04 instance...
Creating new instance from remote
Creating new base instance from remote
charmcraft internal error: HTTPError('404 Client Error: Not Found for url: http+unix://%2Frun%2Fsnapd.socket/v2/snaps/charmcraft')
Full execution log: '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20240730-112715.840030.log'




$ sudo snap remove charmcraft_3
charmcraft_3 removed

$ sudo snap install charmcraft --channel 3.x/beta --classic
charmcraft (3.x/candidate) 3.1.1 from Canonical✓ installed
Channel 3.x/beta for charmcraft is closed; temporarily forwarding to 3.x/candidate.

$ charmcraft clean

$ charmcraft -v pack
Starting charmcraft, version 3.1.1
Logging execution to '/home/ubuntu/.local/state/charmcraft/log/charmcraft-20240730-114924.278890.log'
Launching managed ubuntu 24.04 instance...
Creating new instance from remote
Creating new base instance from remote
Creating new instance from base instance
Starting instance
Starting charmcraft, version 3.1.1
Logging execution to '/tmp/charmcraft.log'
Starting charmcraft, version 3.1.1
Logging execution to '/tmp/charmcraft.log'
Initialising lifecycle
Installing build-packages
Pulling charm
Building charm
:: + cp --archive --link --no-dereference . /root/parts/charm/install
Staging charm
Priming charm
Packing...
Packing charm ceph-osd_amd64.charm
Packed ceph-osd_amd64.charm
@samuelallan72 samuelallan72 added the Bug Something isn't working label Jul 30, 2024
@lengau
Copy link
Collaborator

lengau commented Aug 7, 2024

Thanks for the report!

@mr-cal I wonder if this could explain some of @NucciTheBoss's issues with parallel-installed snapcrafts?

It appears that requesting /v2/snaps/<snap_name> from snapd.socket doesn't take into account the snap's instance key. I guess that makes sense, as snapd doesn't know where it's getting that call from. So instead it's always installing the un-instanced name. Here @samuelallan72 saw a different error (404) because they didn't have an un-instanced charmcraft installed.

If I'm correct here, would it make sense in craft-providers to check the environment for SNAP_NAME == snap_name and if so, append _{SNAP_INSTANCE_KEY} to the URL if the snap is there? Or is it more appropriate for something higher level (probably craft-application) to adjust the name?

@lengau
Copy link
Collaborator

lengau commented Aug 12, 2024

Thinking more about this, I think craft-application is probably the better place since craft-providers probably shouldn't be aware of the application context.

Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3351.

This message was autogenerated

@lengau lengau self-assigned this Sep 9, 2024
@sergiusens
Copy link
Collaborator

Use SNAP_REVISION and maybe SNAP_INSTANCE to corroborate

@lengau lengau added the blocked Waiting on a third party to finish something before this can be further processed label Sep 16, 2024
@lengau
Copy link
Collaborator

lengau commented Sep 16, 2024

Blocked by canonical/craft-providers#622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Waiting on a third party to finish something before this can be further processed Bug Something isn't working triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants