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

[mic][iso] generate PXE-bootable ISO images. #10595

Open
wants to merge 4 commits into
base: 3.0-dev
Choose a base branch
from

Conversation

gmileka
Copy link
Contributor

@gmileka gmileka commented Oct 1, 2024

Merge Checklist

All boxes should be checked before merging the PR (just tick any boxes which don't apply to this PR)

  • The toolchain has been rebuilt successfully (or no changes were made to it)
  • The toolchain/worker package manifests are up-to-date
  • Any updated packages successfully build (or no packages were changed)
  • Packages depending on static components modified in this PR (Golang, *-static subpackages, etc.) have had their Release tag incremented.
  • Package tests (%check section) have been verified with RUN_CHECK=y for existing SPEC files, or added to new SPEC files
  • All package sources are available
  • cgmanifest files are up-to-date and sorted (./cgmanifest.json, ./toolkit/scripts/toolchain/cgmanifest.json, .github/workflows/cgmanifest.json)
  • LICENSE-MAP files are up-to-date (./LICENSES-AND-NOTICES/SPECS/data/licenses.json, ./LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md, ./LICENSES-AND-NOTICES/SPECS/LICENSE-EXCEPTIONS.PHOTON)
  • All source files have up-to-date hashes in the *.signatures.json files
  • sudo make go-tidy-all and sudo make go-test-coverage pass
  • Documentation has been updated to match any changes to the build system
  • Ready to merge

Summary

This changes updates the Azures Linux Image Customizer to emit iso images that are PXE-ready.
The changes include:

  • interface:
    • configuration: new configuration to specify the download url for the iso.
    • command-line: new parameter to export the iso image contents into a folder for easier deployment unto a pxe server.
  • implementation:
  • implemented the above interface changes.
  • extended the set of parameters that must be saved between runs to include the new pxe parameters.
  • updated the code to emit a pxe grub.cfg and a pxe dracut config.
  • update the dracut package to include an additional download script that will be triggered in the pxe scenario.
Change Log
Does this affect the toolchain?

NO

Associated issues
Links to CVEs
  • n/a
Test Methodology
  • Deploy a PXE server on the network.
  • Create an iso and specify the new --output-pxe-artifacts-dir
  • Deploy the iso to the pxe server and boot a PXE client.
  • Deploy the artifacts folder contents to a the pxe server and boot a PXE client.
  • Tested iso-to-iso customization and ensured kernel parameters are augmented.

@gmileka gmileka force-pushed the gmileka/mic-iso-pxe-official-pr branch from f2825b8 to d6fd3b9 Compare October 2, 2024 00:22
@gmileka gmileka marked this pull request as ready for review October 2, 2024 19:35
@gmileka gmileka requested review from a team as code owners October 2, 2024 19:35
@@ -0,0 +1,147 @@
From 2888695d6e1e03f727fe45d6e38fc71f7b5be123 Mon Sep 17 00:00:00 2001
Copy link
Contributor

Choose a reason for hiding this comment

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

This change should probably be split off into a separate PR so that it can reviewed separately from the MIC PXE feature.

@@ -0,0 +1,147 @@
From 2888695d6e1e03f727fe45d6e38fc71f7b5be123 Mon Sep 17 00:00:00 2001
Copy link
Contributor

Choose a reason for hiding this comment

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

This patch means that the MIC PXE feature will require a minimum version of Azure Linux 3.0 to be able to function. In addition, you will be unlikely to be able to apply this patch to Azure Linux 2.0.

At a minimum, MIC should check for this patch in some way and error out if it isn't available. That will at least avoid the situation where it silently fails for the user.

Though, it might be good to investigate ways we could make MIC PXE feature independent of the Azure Linux version.


Below is a list of the files necessary for PXE booting:

```
Copy link
Contributor

Choose a reason for hiding this comment

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

What file format is this? It isn't something I recognize.

Also, you seem to be using both // and # for comments.

Would it make sense to use a Markdown table instead?


Specifies the PXE-specific configuration for the generated OS artifacts.

<div id="pxe-isoimageurl"></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't add div unless the header is ambiguous. Not all Markdown tools handle div. So, limiting their use is goodness.

fi
copy_file $artifactsRootDir/boot/grub2/grubenv $tftpLocalDir/boot/grub2/grubenv

# replace every '/' with a '\/' to avoid breaking sed search/replace syntax.
Copy link
Contributor

Choose a reason for hiding this comment

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

sed can take any character after the s. It might be goodness to use a character not supported in URLs. e.g. s|<old>|<new>|g

function mount_iso() {
local isoPath=$1
local mountDir=$2
sudo rm -rf $mountDir
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use sudo in scripts. If the script needs root privileges, then the entire script should be run as sudo.


function show_usage() {
echo
echo "$(basename ${BASH_SOURCE[0]}) <source-path>"
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't <source-path> need the -s prefix?

if err != nil {
return fmt.Errorf("failed to create iso image:\n%w", err)
}

err = populatePXEArtifactsDir(isoImagePath, b.workingDirs.isoBuildDir, outputPXEArtifactsDir, outputImageBase)
Copy link
Contributor

Choose a reason for hiding this comment

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

populatePXEArtifactsDir is called at the end of both createLiveOSIsoImage and createImageFromUnchangedOS. Would it make sense to move the populatePXEArtifactsDir call to convertWriteableFormatToOutputImage instead?

}
}

err = b.updateGrubCfg(b.artifacts.savedKernelArgsFilePath, b.artifacts.grubCfgPath, extraCommandLine)
err = b.updateGrubCfg(b.artifacts.savedConfigsFilePath, b.artifacts.isoGrubCfgPath, extraCommandLine, b.artifacts.pxeGrubCfgPath, pxeIsoImageUrl, outputImageBase)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please line wrap at 120.

}

isoGrubCfg := filepath.Join(outputPXEArtifactsDir, "boot/grub2/grub.cfg")
pxeGrubCfg := filepath.Join(outputPXEArtifactsDir, "boot/grub2/grub-pxe.cfg")
Copy link
Contributor

Choose a reason for hiding this comment

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

You should place these 2 file paths in constants.

@@ -810,7 +957,7 @@ func (b *LiveOSIsoBuilder) prepareArtifactsFromFullImage(inputIsoSavedKernelArgs
//
// ouptuts:
// - create a LiveOS ISO.
func (b *LiveOSIsoBuilder) createIsoImage(additionalIsoFiles []safechroot.FileToCopy, isoOutputDir, isoOutputBaseName string) error {
func (b *LiveOSIsoBuilder) createIsoImage(additionalIsoFiles []safechroot.FileToCopy, isoOutputDir, isoOutputBaseName string) (isoRepoDirPath string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be isoImagePath instead of isoRepoDirPath?


<div id="pxe-isoimageurl"></div>

### isoImageUrl [string]
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to have 2 mutually exclusive fields: isoImageBaseUrl (which adds ISO file name) and isoImageFileUrl (which doesn't add the ISO file name). That way, it avoids the behavior changing based on the format of the URL.

create mode 100644 modules.d/90livenet/liveos-artifacts-download.service
create mode 100755 modules.d/90livenet/liveos-artifacts-download.sh

diff --git a/modules.d/90livenet/liveos-artifacts-download.service b/modules.d/90livenet/liveos-artifacts-download.service
Copy link
Contributor

Choose a reason for hiding this comment

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

this file and another may be more maintainable as additional sources instead of baking them into the patch, since they are entirely new files. you would copy them to the appropriate location before the build.

%prep
%autosetup -p1 -n %{name}-ng-%{version}
cp %{SOURCE1} .
cp %{SOURCEX} modules.d/90livenet/liveos-artifacts-download.service
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pending

@gmileka gmileka force-pushed the gmileka/mic-iso-pxe-official-pr branch from e5ee6be to 39eea29 Compare October 23, 2024 00:58
@gmileka gmileka requested a review from a team as a code owner October 23, 2024 00:58
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.

4 participants