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

Support for pushing notifications to the Ubuntu ISO Tracker #81

Merged
merged 6 commits into from Mar 18, 2022

Conversation

sil2100
Copy link
Collaborator

@sil2100 sil2100 commented Jan 17, 2022

Sending this out for an initial review. The goal of this PR is to send out notifications to the Ubuntu ISO Tracker about any new WSL builds that are completed, notifying the respective per-series products. This way we'd have Ubuntu WSL images appearing on the tracker automatically. It also plays in nicely with another feature of this related to the ability to re-trigger builds via the tracker.

http://iso.qa.ubuntu.com/

This is the first time I deal with github actions, so that part is mostly written blindly by just looking at other sections and reading documentation. There's also some open questions here.

Open questions:

  1. Version of the resulting WSL build. Right now I went with the simple route of just using build_id, but from what I see it's like a small number right now. Ideas I had was things like DATESTAMP.build_id or something, or does build_id suffice?
  2. Not sure if the ISO Tracker API will work over HTTPS (which we need as it's outside of Canonical network)
  3. I have no idea how github actions are triggered and how long the environment survives, but in the code I used /tmp/all-releases.csv in case that it might 'stick around' from previous job runs. I can switch to just doing it via LP directly, but if it's persistent for long enough I thought it might save a few LP API calls.

Other than that I think it's good enough. I only tested it in dry-run mode on my local machine. I'm open to suggestions!

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.

I think this is a nice first version, especially from someone not familiar with Github Action. Nice work!

I have suggested some improvements and changes I consider needed for this. Also, to answer your questions:

Version of the resulting WSL build. Right now I went with the simple route of just using build_id, but from what I see it's like a small number right now. Ideas I had was things like DATESTAMP.build_id or something, or does build_id suffice?
You should use the complete version after our replacement during the build. This one takes into account which image we are pushing to (like 2004.4.<build_id>.0) for instance. Note that we don’t have control over the last .0 which is internal to the Microsoft Store. This whole version will be. after the first builds, something like 2204.0.1.0 for instance.

Not sure if the ISO Tracker API will work over HTTPS (which we need as it's outside of Canonical network)*
Yeah, can you give it some tries with curl directly from your machine without the VPN connected?

I have no idea how github actions are triggered and how long the environment survives, but in the code I used /tmp/all-releases.csv in case that it might 'stick around' from previous job runs. I can switch to just doing it via LP directly, but if it's persistent for long enough I thought it might save a few LP API calls.
Those are sticking per job. So, if one step of a job stick a file somewhere, it will be available for every other steps in the job. However, we can also upload/download artefacts to share things between jobs (you have some examples in the build process here). However, I think you should really take in general the version we build in the XML file and use that as a reference to avoid any discrepancies between the 2.

.github/workflows/build-wsl.yaml Outdated Show resolved Hide resolved
.github/workflows/build-wsl.yaml Outdated Show resolved Hide resolved
ISOTRACKER_USERNAME: ${{ secrets.ISOTrackerUsername }}
ISOTRACKER_PASSWORD: ${{ secrets.ISOTrackerPassword }}
run: |
perl -pe 's/@([A-Z_]+)@/$ENV{$1}/eg' isotracker.conf.in >~/isotracker.conf
Copy link
Member

Choose a reason for hiding this comment

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

Can’t we do that with sed? Because perl will make it harder to maintain :p
I would like the configuration to be store somewhere not in workdir if possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can look into doing it with sed ;p The perl version was straightforward as it could be written in one line, in case there's more credentials at some point. But that's rather unlikely!
As for the placement of the config file - I think this would require some changes to the isotracker module as by default it hard-codes this path for the config file. But I think this should be configurable, so I'll make the required modifications!

.github/workflows/build-wsl.yaml Outdated Show resolved Hide resolved
@@ -252,6 +266,15 @@ jobs:
name: build-artifacts-${{ matrix.WslID }}
path: ${{ env.workDir }}/${{ env.buildInfoPath }}/${{ matrix.WslID }}-*

- name: Notify ISO Tracker
Copy link
Member

Choose a reason for hiding this comment

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

Same, I would do that after updating the build artefacts.

Actually, thinking about it, we are only interested when we store the version in the "db" (yes, the wiki). So maybe another approach would be to do it in update-build-artifacts job rather, for all new application packages (==images) we uploaded to the store.

url=https://iso.qa.ubuntu.com/xmlrpc.php
username=@ISOTRACKER_USERNAME@
password=@ISOTRACKER_PASSWORD@
default_milestone=Jammy Daily
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be reworked. We avoided hardcoding anything (version, name…) in our repo, so that if a new release opened, we just receive an automated PR from our detect-update-releases workflow and we can review + merge.

This makes opening/tracking new releases painless compared to 60 places we need to update the name (and of course, forgot some in the wiki).
Can we retrieve the information from launchpad, or update maybe the release.csv file and add + " Daily" to it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hm, you're right. Maybe we could actually make this super dynamic. A few ideas is: either generating the isotracker.conf file automatically in notify-tracker before creating the ISOTracker object or, maybe even better: tweaking ISOTracker in ubuntu-archive-tools to offer some functionality to pass the credentials and config data without the need of a file on the filesystem.

Anyway, good idea! I'll get that going.

Copy link
Collaborator Author

@sil2100 sil2100 left a comment

Choose a reason for hiding this comment

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

Thank you for your review Didier! I'll be taking care of those issues as soon as I have a moment.

ISOTRACKER_USERNAME: ${{ secrets.ISOTrackerUsername }}
ISOTRACKER_PASSWORD: ${{ secrets.ISOTrackerPassword }}
run: |
perl -pe 's/@([A-Z_]+)@/$ENV{$1}/eg' isotracker.conf.in >~/isotracker.conf
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can look into doing it with sed ;p The perl version was straightforward as it could be written in one line, in case there's more credentials at some point. But that's rather unlikely!
As for the placement of the config file - I think this would require some changes to the isotracker module as by default it hard-codes this path for the config file. But I think this should be configurable, so I'll make the required modifications!

url=https://iso.qa.ubuntu.com/xmlrpc.php
username=@ISOTRACKER_USERNAME@
password=@ISOTRACKER_PASSWORD@
default_milestone=Jammy Daily
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hm, you're right. Maybe we could actually make this super dynamic. A few ideas is: either generating the isotracker.conf file automatically in notify-tracker before creating the ISOTracker object or, maybe even better: tweaking ISOTracker in ubuntu-archive-tools to offer some functionality to pass the credentials and config data without the need of a file on the filesystem.

Anyway, good idea! I'll get that going.

@sil2100
Copy link
Collaborator Author

sil2100 commented Jan 31, 2022

Pushed a new version, ready for review.

In this version, as per discussion, I have switched to the approach of generating the ISOTracker config on the fly dynamically without actually creating a configuration file (pushed support for that to lp:ubuntu-archive-tools). I reorganized some of the github actions to have a better order too.

I tried a bit to move the notification logic to update-build-artifacts as you suggested and even had an idea how to do it (calling git-tree for HEAD to get the list of changed files to determine which projects got updated), but in the end decided to go with how it was before as I am not as confident in github actions logic. Since this then requires having the WSL repository available, and from the looks of it the update-build-artifacts job was working in the wiki repository directory. And I was like, eh, I don't feel comfortable enough to twiddle with things like these without having any way of testing this.

So yeah, I'd say we can switch to the other approach, but it feels like more invasive then?

@sil2100 sil2100 requested a review from didrocks February 7, 2022 11:03
@didrocks
Copy link
Member

didrocks commented Feb 8, 2022

Thanks for the changes here and not relying on the hardcoded ISO tracker configuration anymore. It looks good to me :) However, it seems you didn’t remove the hardcoded version from your branch.

On the other big comment, I’m still convinced that the best approach is to do in update-build-artifacts workflow:

  • there are some use cases for manual builds, without uploading to the store. In that case, the iso tracker should not be notified.
  • this whole logic of notifying the iso tracker is the same than "should we update our version database"? So, it means that if this job is running and we have a diff here, we had the corresponding desired upload done to the store for that version already. This way, we are sure our logics are aligned.
  • I think this can be easily done by calling git status in a job just after "Copy modified artifacts to base wiki", determining which file in which folder have been changed, and using this to know what to notify. If you need any additional metadata, I’m happy to give some hands here :)

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.

Moving it back as we need some changes, the overall changes looks like it’s going in the right direction though :)

@sil2100
Copy link
Collaborator Author

sil2100 commented Feb 11, 2022

Could you take a look if this is something that would work? Thanks!

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.

Some small change, but it seems we are getting there! Thanks for the discussion :)

WSLId=$(basename $build);
WSLId=${WSLId%-buildid.md};
buildid=$(cat $build)
PYTHONPATH=${{ env.codeDir }}/uat ${{ env.codeDir }}/notify-isotracker $WslID $buildid
Copy link
Member

Choose a reason for hiding this comment

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

Can you move notify-isotracker under wsl-buidler/? This will make buid-related stuff outside of WSL.

@@ -286,3 +288,29 @@ jobs:
git add .
git commit -m "Auto-update build info"
git push origin master

- name: Checkout WSL repo
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add the if: ${{ steps.modified-artifacts.outputs.needs-wiki-update == 'true' }} in there and do the 2 clones in a single step, as both is to get the code to notify the tracker.

@sil2100
Copy link
Collaborator Author

sil2100 commented Feb 11, 2022

Almost there! But ready for re-review once again!

I suppose one final thing to think about (poked JB a while ago about that as well) is actually how we should identify new builds in the ISO Tracker. Right now it's the buildid, but the ISOTracker would have to somehow construct a nice way of offering something to download using that ID.

@didrocks
Copy link
Member

Agreed, do you want that we resolve this next week before merging?

@sil2100
Copy link
Collaborator Author

sil2100 commented Feb 18, 2022

hm, okay, I feel that I'd need help getting a better understanding here. So from what JB told me a while ago, one way of 'accessing' WSL downloads is via pointing to the sideload download urls from build jobs, e.g.:
https://github.com/ubuntu/WSL/actions/runs/1852204709

The ISO Tracker url creations is rather simple and 'stupid'. It basically needs to construct the url using simple substitution only via the build_id, project, arch etc. Nothing complex can be done, just substituting variables in the url. In this case, it feels to me we'd have to send the WSL action run ID to the ISOTracker, then we could at least link to the action url for people to fetch the sideload archives.

Is it possible to get the run ID somehow? Or do we need to move this to some different stage then?

@sil2100
Copy link
Collaborator Author

sil2100 commented Feb 22, 2022

Should now be again good for review. As per our earlier discussion, switched to using the GITHUB_RUN_ID. Hope this is correct! Thank you @didrocks for helping out on all the stages of this PR!

@didrocks
Copy link
Member

That should be it! If you don’t mind, let’s merge that after .4 and the multiple renaming we have to ensure we don’t add another point of failure :) Otherwise, looking good for me, thanks sil2100!

@didrocks
Copy link
Member

Naming transitions are now completed. Let’s merge that. Thanks for working on it!

@didrocks didrocks merged commit b9056ff into ubuntu:main Mar 18, 2022
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.

None yet

2 participants