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

tests(e2e): support new Azure image versioning scheme #1039

Merged
merged 8 commits into from
Jul 4, 2024

Conversation

GabrielNagy
Copy link
Contributor

The Canonical CPC team recently changed the versioning scheme for Ubuntu Azure VM images from:

{
    "architecture": "x64",
    "offer": "0001-com-ubuntu-minimal-mantic",
    "publisher": "Canonical",
    "sku": "minimal-23_10-gen2",
    "urn": "Canonical:0001-com-ubuntu-minimal-mantic:minimal-23_10-gen2:23.10.202406260",
    "version": "23.10.202406260"
}

To something like:

{
    "architecture": "x64",
    "offer": "ubuntu-24_04-lts",
    "publisher": "Canonical",
    "sku": "minimal",
    "urn": "Canonical:ubuntu-24_04-lts:minimal:24.04.202404230",
    "version": "24.04.202404230"
}

To make matters worse, previous supported Ubuntu versions (Focal, Jammy, Mantic) still use the old version and there’s no plan to migrate them as well, thus we have to maintain both versioning schemes.

Update the relevant script to differentiate between old and new codenames according to the specification above. We now require an additional version CLI parameter since the new versioning scheme does not use the codename at all. This is a hard requirement just for the sake of consistency, even if the previous versioning scheme does not need a version.

The other main difference is that with the new versioning scheme images are Gen2 by default, while Gen1 images are explicitly noted in the SKU.

Fixes UDENG-3379


The additional commits reverse some codename-specific logic in order to add support for Oracular.
Here's a run on my fork with all cells passing (including Oracular): https://github.com/GabrielNagy/adsys/actions/runs/9766528441

The Canonical CPC team recently changed the versioning scheme for Ubuntu Azure VM images from:

{
    "architecture": "x64",
    "offer": "0001-com-ubuntu-minimal-mantic",
    "publisher": "Canonical",
    "sku": "minimal-23_10-gen2",
    "urn": "Canonical:0001-com-ubuntu-minimal-mantic:minimal-23_10-gen2:23.10.202406260",
    "version": "23.10.202406260"
}

To something like:

{
    "architecture": "x64",
    "offer": "ubuntu-24_04-lts",
    "publisher": "Canonical",
    "sku": "minimal",
    "urn": "Canonical:ubuntu-24_04-lts:minimal:24.04.202404230",
    "version": "24.04.202404230"
}

To make matters worse, previous supported Ubuntu versions (Focal, Jammy,
Mantic) still use the old version and there’s no plan to migrate them as
well, thus we have to maintain both versioning schemes.

Update the relevant script to differentiate between old and new
codenames according to the specification above. We now require an
additional 'version' CLI parameter since the new versioning scheme does
not use the codename at all. This is a hard requirement just for the
sake of consistency, even if the previous versioning scheme does not
need a version.

The other main difference is that with the new versioning scheme images
are Gen2 by default, while Gen1 images are explicitly noted in the SKU.
Now that the Ubuntu version is a hard requirement for the 00_check_image
script, we need access to it in our GitHub Actions workflow.

I've updated the logic to manipulate the output of `distro-info
--fullname` which looks like the following:

Ubuntu 20.04 LTS "Focal Fossa"
Ubuntu 22.04 LTS "Jammy Jellyfish"
Ubuntu 23.10 "Mantic Minotaur"
Ubuntu 24.04 LTS "Noble Numbat"
Ubuntu 24.10 "Oracular Oriole"

It's not particularly suitable for parsing, but it's the only way we can
manipulate distro-info into giving us both the codename and version on
the same line.

We save the version in the job output, and re-use it when executing the
Go script.
Instead of using the Azure CLI we resort to our specialized script which
takes care of the multiple versioning schemes.
Rather than adding new Ubuntu codenames here, add all the ones that need
the PPA to be installed.
@codecov-commenter
Copy link

codecov-commenter commented Jul 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.80%. Comparing base (e097d64) to head (59cbe2b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1039   +/-   ##
=======================================
  Coverage   93.80%   93.80%           
=======================================
  Files          79       79           
  Lines        6881     6881           
=======================================
  Hits         6455     6455           
  Misses        416      416           
  Partials       10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GabrielNagy GabrielNagy marked this pull request as ready for review July 3, 2024 09:11
@GabrielNagy GabrielNagy requested a review from a team as a code owner July 3, 2024 09:11
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Excellent work! but yeah, quite convoluted :/

I only have a couple of small suggestions on it…

.github/workflows/e2e-build-images.yaml Outdated Show resolved Hide resolved
.github/workflows/e2e-build-images.yaml Outdated Show resolved Hide resolved
e2e/internal/az/image.go Show resolved Hide resolved
e2e/scripts/Dockerfile.build Show resolved Hide resolved
Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

Great! This really simplifies it over the long run.

I generally forget about the existence of the paste command too. Too many options :D

Well done!

.github/workflows/e2e-build-images.yaml Show resolved Hide resolved
These versions have had golang-1.22 backported, so we don't need to be
installing our PPA for it.
When creating AD users for testing we use the codename to which we
append a suffix like '-usr' or '-adm'. Due to oracular being quite a
long name added up to the 8 character unique hex, AD fails to create the
user since it ends up being above 20 characters long.

    New-ADUser : The name provided is not a properly formed account name

There's many ways to fix this, but I'm doing it at a template
level (meaning a refresh will be required), essentially halving the
unique part from 8 characters to 4 characters. We don't provision lots
of resources so I'm not expecting clashes due to the unique part being
shorter.
It seems this workaround is also needed on Oracular, as (re)boots are
painfully slow presumably due to a timeout caused by this service.

Again, easiest to reverse the logic and opt in new versions by default.
We can execute distro-info twice, once to get the codenames and once for
the versions, and then combine the outputs using `paste`. This is a bit
eaasier to reason about and understand compared to sed/awk usage.
@GabrielNagy GabrielNagy force-pushed the exclude-codenames-without-vm-images branch from 59cbe2b to 4ff0226 Compare July 4, 2024 08:04
@GabrielNagy
Copy link
Contributor Author

A passing run with the updated implementation (for posterity): https://github.com/ubuntu/adsys/actions/runs/9784527402

@GabrielNagy GabrielNagy merged commit 7f9d68d into main Jul 4, 2024
4 checks passed
@GabrielNagy GabrielNagy deleted the exclude-codenames-without-vm-images branch July 4, 2024 08:04
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