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

Switch repo to use native AzDO container support #14541

Merged
merged 4 commits into from
Sep 27, 2022

Conversation

mmitche
Copy link
Member

@mmitche mmitche commented Sep 16, 2022

This is a major refactor of the YAML used by the installer repo. The goal is to utilize the native container support that AzDO provides, rather than building containers on the fly and issuing commands using custom infrastructure. To do this, the YAML requires a bit of a refactor. The matrix strategy approach used by the repo to build a ton of different OS's does not work with containers, because a matrix strategy only changes the variables available to each build command. It cannot change the AzDO host environment. In order to resolve this, I refactored build.yml to take and use optional container names. In the process of doing this, I discovered a number of other things about the old YAML that just happened to 'accidentally' work and fixed them or did general cleanup. Including:

  • This construct, used in build.yml, does not work as you might expect. If the parameter is not declared as a boolean (or not declared at all), this evaluates to "does this parameter exist", not "is it true":

    ${{ if parameters.pgoInstrument }}:
    
  • I fully specified all the parameters and their types to avoid issues in the future.

  • Build pool selection was moved to build.yml

  • Removed some unused parameters.

  • There was a very subtle indentation change here:

    installer/.vsts-ci.yml

    Lines 275 to 281 in 762d296

    Build_LinuxPortable_Release_x64:
    _BuildConfig: Release
    _DockerParameter: ''
    _LinuxPortable: '--linux-portable'
    _RuntimeIdentifier: ''
    _BuildArchitecture: 'x64'
    _TestArg: $(_NonWindowsTestArg)
    . This meant that this leg ran in both PR and official builds. I have no idea whether this was the intention or not, but I kept it this way and reorganized the file.

One change of note: One of the upsides of the original matrix based approach is that job dependencies are simple. The jobs generated by the matrix are referred to in dependsOn lists only by the original job that contains the matrix. That keeps the dependsOn list small even if the number of jobs generated is large. Installer has a large set of independently addressable jobs now. Normally, we would solve this by using the arcade jobs template. The jobs template takes a set of jobs and automatically adds dependsOn for the publishing jobs. BUT, AzDO does not allow templates to be passed as parameters to other templates. This would mean that you couldn't use the build.yml template in conjunction with the jobs template and would have to list all the installer jobs as dependencies. This list would be hard to keep up to date. To avoid this, I used a new feature of publishing (publishAssetsImmediately) which uses the Publish To Build Asset Registry job to do the actual publishing call, and put it in a separate phase, then eliminated the post-build.yml call. This means that the publishing stage depends on all jobs in the build stage, and does not need to address them individually. Eliminating the post-build.yml stage may seem odd, but this is what actually happens when publishAssetsImmediately is set to true anyway.

@mmitche
Copy link
Member Author

mmitche commented Sep 16, 2022

Definitely still a draft. The YAML is getting major surgery now because you can't use a matrix strategy with a changing environment.

@mmitche mmitche force-pushed the native-container-support branch from fd58f85 to a311cda Compare September 20, 2022 15:35
This is a major refactor of the YAML used by the installer repo. The goal is to utilize the native container support that AzDO provides, rather than building containers on the fly and issuing commands using custom infrastructure. To do this, the YAML requires a bit of a refactor. The matrix strategy approach used by the repo to build a ton of different OS's does not work with containers, because a matrix strategy only changes the variables available to each build command. It cannot change the AzDO host environment. In order to resolve this, I refactored build.yml to take and use optional container names. In the process of doing this, I discovered a number of other things about the old YAML that just happened to 'accidentally' work and fixed them or did general cleanup. Including:

- This construct, used in build.yml, does not work as you might expect. If the parameter is not declared as a boolean (or not declared at all), this evaluates to "does this parameter exist", not "is it true":

    ```
    ${{ if parameters.pgoInstrument }}:
    ```
- I fully specified all the parameters and their types to avoid issues in the future.
- Build pool selection was moved to build.yml
- Removed some unused parameters.
- There was a **very** subtle indentation change here: https://github.com/dotnet/installer/blob/762d2966ee649e9f8174747d528aa067eaa7c4f0/.vsts-ci.yml#L275-L281. This meant that this leg ran in both PR and official builds. I have no idea whether this was the intention or not, but I kept it this way and reorganized the file.

**One change of note:** One of the upsides of the original matrix based approach is that job dependencies are simple. The jobs generated by the matrix are referred to in `dependsOn` lists only by the original job that contains the matrix. That keeps the dependsOn list small even if the number of jobs generated is large. Installer has a large set of independently addressable jobs now. Normally, we would solve this by using the arcade jobs template. The jobs template takes a set of jobs and automatically adds dependsOn for the publishing jobs. BUT, AzDO does not allow templates to be passed as parameters to other templates. This would mean that you couldn't use the build.yml template in conjunction with the jobs template and would have to list all the installer jobs as dependencies. This list would be hard to keep up to date. To avoid this, I used a new feature of publishing (`publishAssetsImmediately`) which uses the Publish To Build Asset Registry job to do the actual publishing call, and put it in a separate phase, then eliminated the post-build.yml call. This means that the publishing stage depends on all jobs in the build stage, and does not need to address them individually. Eliminating the post-build.yml stage may seem odd, but this is what actually happens when `publishAssetsImmediately` is set to true anyway.
@mmitche mmitche force-pushed the native-container-support branch from a311cda to 7865d76 Compare September 20, 2022 16:06
@mmitche
Copy link
Member Author

mmitche commented Sep 20, 2022

@marcpopMSFT Getting pretty close here. PR passed last night and official build is close. Still a couple kinks to work around.

Updated the description to accurately reflect the changes.

eng/build.yml Outdated Show resolved Hide resolved
@michellemcdaniel
Copy link

Looks pretty good modulo some little things

@mmitche
Copy link
Member Author

mmitche commented Sep 20, 2022

@mmitche mmitche marked this pull request as ready for review September 20, 2022 21:03
@mmitche
Copy link
Member Author

mmitche commented Sep 27, 2022

g2g on latest build: https://dev.azure.com/dnceng/internal/_build/results?buildId=2005368&view=results

@mmitche mmitche merged commit 8dc4175 into dotnet:main Sep 27, 2022
@mmitche mmitche deleted the native-container-support branch September 27, 2022 18:15
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