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

Legacy (?) builds may result in inconsistent version being set #4316

Open
cmatsuoka opened this issue Aug 14, 2023 · 5 comments
Open

Legacy (?) builds may result in inconsistent version being set #4316

cmatsuoka opened this issue Aug 14, 2023 · 5 comments
Assignees
Labels
bug Actual bad behavior that don't fall into maintenance or documentation Needs Information

Comments

@cmatsuoka
Copy link
Contributor

cmatsuoka commented Aug 14, 2023

Bug Description

Parts that dynamically set version in the build or stage steps may forget it in the prime step.

To Reproduce

  • have part which sets version
  • build snap
  • change version in the part
  • rebuild the part
  • run snapcraft to complete the build
  • version will be old one

Environment

This was reported by @kubiko, running snapcraft edge (7.5.2.post59+git8758571f) to build a core20 snap.

snapcraft.yaml

adopt-info: part-1
parts:
  part-1:
    override-build: |
      craftctl default
      craftctl set version=123
  part-2:
    after:
      - part-1

Relevant log output

N/A

Additional context

This has similar effects, but it's not caused by the same issues addressed in #4305 (legacy builds don't use the lifecycle implemented in Craft Parts). Note however that the supplied reproducer is core22 so clarification is needed on the base where the problem happens.

@cmatsuoka cmatsuoka added the bug Actual bad behavior that don't fall into maintenance or documentation label Aug 14, 2023
@cmatsuoka
Copy link
Contributor Author

cmatsuoka commented Aug 16, 2023

The supplied reproducer uses core22 syntax. The results of testing it are:

With snapcraft 7.5.2 (stable)

Launching instance...
Executed: pull part-1
Executed: pull part-2
Executed: build part-1
Executed: skip pull part-1 (already ran)
Executed: skip build part-1 (already ran)
Executed: stage part-1 (required to build 'part-2')
Executed: build part-2
Executed: skip stage part-1 (already ran)
Executed: stage part-2
Executed: prime part-1
Executed: prime part-2
Executed parts lifecycle
Generated snap metadata
Created snap package my-snap-name_123_amd64.snap

Rebuild part 1 after editing part-1 and changing the version to 456:

Launching instance...
Executed: skip pull part-1 (already ran)
Executed: rebuild part-1 (requested step)
Executed parts lifecycle

Run snapcraft to complete the build:

Launching instance...
Executed: skip pull part-1 (already ran)
Executed: skip pull part-2 (already ran)
Executed: skip build part-1 (already ran)
Executed: skip pull part-1 (already ran)
Executed: skip build part-1 (already ran)
Executed: stage part-1 (required to build 'part-2')
Executed: rebuild part-2 (stage for part 'part-1' changed)
Executed: skip stage part-1 (already ran)
Executed: stage part-2
Executed: prime part-1
Executed: prime part-2
Executed parts lifecycle
Generated snap metadata
Created snap package my-snap-name_456_amd64.snap

With snapcraft 7.5.2.post62+git5ec65724 (edge)

Executed: pull part-1
Executed: pull part-2
Executed: build part-1
Executed: skip pull part-1 (already ran)
Executed: skip build part-1 (already ran)
Executed: stage part-1 (required to build 'part-2')
Executed: build part-2
Executed: skip stage part-1 (already ran)
Executed: stage part-2
Executed: prime part-1
Executed: prime part-2
Executed parts lifecycle
Generated snap metadata
Created snap package my-snap-name_123_amd64.snap

Build part 1 after changing version to 456:

Executed: skip pull part-1 (already ran)
Executed: rebuild part-1 (requested step)
Executed parts lifecycle

Complete the build:

Executed: skip pull part-1 (already ran)
Executed: skip pull part-2 (already ran)
Executed: skip build part-1 (already ran)
Executed: skip pull part-1 (already ran)
Executed: skip build part-1 (already ran)
Executed: stage part-1 (required to build 'part-2')
Executed: rebuild part-2 (stage for part 'part-1' changed)
Executed: skip stage part-1 (already ran)
Executed: stage part-2
Executed: prime part-1
Executed: prime part-2
Executed parts lifecycle
Generated snap metadata
Created snap package my-snap-name_456_amd64.snap

@cmatsuoka cmatsuoka changed the title Legacy builds may result in inconsistent version being set ~~Legacy~~ builds may result in inconsistent version being set Aug 16, 2023
@cmatsuoka cmatsuoka changed the title ~~Legacy~~ builds may result in inconsistent version being set Legacy (?) builds may result in inconsistent version being set Aug 16, 2023
@sergiusens
Copy link
Collaborator

@kubiko we will close this issue tomorrow if there is no reply by then as non reproduceable

@sergiusens
Copy link
Collaborator

Closing, feel free to reopen with a reproducer if you see this again

@kubiko
Copy link
Contributor

kubiko commented Aug 31, 2023

Hi @sergiusens
sorry for the delay, I have narrowed it down to a simple use case

name: snap-version
base: core22
adopt-info: part-2
summary: Test snap version
description: |
  Test snap version

grade: stable
confinement: strict

parts:
  part-1:
    plugin: nil
  part-2:
    after:
      - part-1
    plugin: nil
    override-build: |
      craftctl set version="1.1"

run:

  • $ snapcraft
  • edit version in snapcraft.yaml
  • $ snapcraft
  • The version is still the old one

Used snapcraft version 7.5.2

@sergiusens sergiusens reopened this Sep 1, 2023
@kubiko
Copy link
Contributor

kubiko commented Sep 1, 2023

@sergiusens, we ran some tests with @cmatsuoka and it seems this has been fixed as a byproduct of the following change
https://github.com/snapcore/snapcraft/pull/4305/files

So while you can still reproduce it with 7.5.2 @cmatsuoka confirmed that hotfix/7.5 and 7.5.3 have this fixed.
Maybe just adding relevant tests for this use case, but otherwise, you can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Actual bad behavior that don't fall into maintenance or documentation Needs Information
Projects
None yet
Development

No branches or pull requests

3 participants