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

[release-4.18] OCPBUGS-46391: node-joiner PXE artifacts should be prefixed "node" #9316

Open
wants to merge 1 commit into
base: release-4.18
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions cmd/node-joiner/testdata/add-nodes-pxe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

exec node-joiner add-nodes --pxe --kubeconfig=$WORK/kubeconfig --log-level=debug --dir=$WORK

exists $WORK/boot-artifacts/agent.x86_64-initrd.img
exists $WORK/boot-artifacts/agent.x86_64-rootfs.img
exists $WORK/boot-artifacts/agent.x86_64-vmlinuz
exists $WORK/boot-artifacts/agent.x86_64.ipxe
exists $WORK/boot-artifacts/node.x86_64-initrd.img
exists $WORK/boot-artifacts/node.x86_64-rootfs.img
exists $WORK/boot-artifacts/node.x86_64-vmlinuz
exists $WORK/boot-artifacts/node.x86_64.ipxe

grep 'initrd --name initrd http://user-specified-pxe-infra.com/agent.x86_64-initrd.img' $WORK/boot-artifacts/agent.x86_64.ipxe
grep 'kernel http://user-specified-pxe-infra.com/agent.x86_64-vmlinuz initrd=initrd coreos.live.rootfs_url=http://user-specified-pxe-infra.com/agent.x86_64-rootfs.img fips=1' $WORK/boot-artifacts/agent.x86_64.ipxe
! grep 'coreos.liveiso=' $WORK/boot-artifacts/agent.x86_64.ipxe
grep 'initrd --name initrd http://user-specified-pxe-infra.com/node.x86_64-initrd.img' $WORK/boot-artifacts/node.x86_64.ipxe
grep 'kernel http://user-specified-pxe-infra.com/node.x86_64-vmlinuz initrd=initrd coreos.live.rootfs_url=http://user-specified-pxe-infra.com/node.x86_64-rootfs.img fips=1' $WORK/boot-artifacts/node.x86_64.ipxe
! grep 'coreos.liveiso=' $WORK/boot-artifacts/node.x86_64.ipxe

-- nodes-config.yaml --
bootArtifactsBaseURL: http://user-specified-pxe-infra.com
Expand Down
8 changes: 6 additions & 2 deletions pkg/asset/agent/image/agentartifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const (
// bootArtifactsPath is the path where boot files are created.
// e.g. initrd, kernel and rootfs.
bootArtifactsPath = "boot-artifacts"
// agentFilePrefix is the prefix used for day 1 images.
agentFilePrefix = "agent"
// nodeFilePrefix is the prefix used for day 2 images.
nodeFilePrefix = "node"
)

// AgentArtifacts is an asset that generates all the artifacts that could be used
Expand Down Expand Up @@ -241,8 +245,8 @@ func createDir(bootArtifactsFullPath string) error {
return nil
}

func extractRootFS(bootArtifactsFullPath, agentISOPath, arch string) error {
agentRootfsimgFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("agent.%s-rootfs.img", arch))
func extractRootFS(bootArtifactsFullPath, agentISOPath, filePrefix, arch string) error {
agentRootfsimgFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("%s.%s-rootfs.img", filePrefix, arch))
rootfsReader, err := os.Open(filepath.Join(agentISOPath, "images", "pxeboot", "rootfs.img"))
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/asset/agent/image/agentimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (a *AgentImage) PersistToFile(directory string) error {
if err != nil {
return err
}
err = extractRootFS(bootArtifactsFullPath, a.tmpPath, a.cpuArch)
err = extractRootFS(bootArtifactsFullPath, a.tmpPath, agentFilePrefix, a.cpuArch)
if err != nil {
return err
}
Expand Down
33 changes: 23 additions & 10 deletions pkg/asset/agent/image/agentpxefiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

"github.com/openshift/assisted-image-service/pkg/isoeditor"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent/workflow"
"github.com/openshift/installer/pkg/types"
)

Expand All @@ -26,6 +27,7 @@ type AgentPXEFiles struct {
tmpPath string
bootArtifactsBaseURL string
kernelArgs string
filePrefix string
}

type coreOSKargs struct {
Expand All @@ -38,13 +40,15 @@ var _ asset.WritableAsset = (*AgentPXEFiles)(nil)
func (a *AgentPXEFiles) Dependencies() []asset.Asset {
return []asset.Asset{
&AgentArtifacts{},
&workflow.AgentWorkflow{},
}
}

// Generate generates the image files for PXE asset.
func (a *AgentPXEFiles) Generate(_ context.Context, dependencies asset.Parents) error {
agentArtifacts := &AgentArtifacts{}
dependencies.Get(agentArtifacts)
agentWorkflow := &workflow.AgentWorkflow{}
dependencies.Get(agentArtifacts, agentWorkflow)

a.tmpPath = agentArtifacts.TmpPath

Expand All @@ -64,6 +68,15 @@ func (a *AgentPXEFiles) Generate(_ context.Context, dependencies asset.Parents)
return err
}
a.kernelArgs = kernelArgs + string(agentArtifacts.Kargs)

switch agentWorkflow.Workflow {
case workflow.AgentWorkflowTypeInstall:
a.filePrefix = agentFilePrefix
case workflow.AgentWorkflowTypeAddNodes:
a.filePrefix = nodeFilePrefix
default:
return fmt.Errorf("AgentWorkflowType value not supported: %s", agentWorkflow.Workflow)
}
return nil
}

Expand All @@ -84,12 +97,12 @@ func (a *AgentPXEFiles) PersistToFile(directory string) error {
return err
}

err = extractRootFS(bootArtifactsFullPath, a.tmpPath, a.cpuArch)
err = extractRootFS(bootArtifactsFullPath, a.tmpPath, a.filePrefix, a.cpuArch)
if err != nil {
return err
}

agentInitrdFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("agent.%s-initrd.img", a.cpuArch))
agentInitrdFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("%s.%s-initrd.img", a.filePrefix, a.cpuArch))
err = copyfile(agentInitrdFile, a.imageReader)
if err != nil {
return err
Expand All @@ -108,7 +121,7 @@ func (a *AgentPXEFiles) PersistToFile(directory string) error {
kernelFileType = "vmlinuz"
}

agentVmlinuzFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("agent.%s-%s", a.cpuArch, kernelFileType))
agentVmlinuzFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("%s.%s-%s", a.filePrefix, a.cpuArch, kernelFileType))
kernelReader, err := os.Open(filepath.Join(a.tmpPath, "images", "pxeboot", kernelFileType))
if err != nil {
return err
Expand Down Expand Up @@ -186,11 +199,11 @@ boot
`

iPXEScript := fmt.Sprintf(iPXEScriptTemplate, a.bootArtifactsBaseURL,
fmt.Sprintf("agent.%s-initrd.img", a.cpuArch), a.bootArtifactsBaseURL,
fmt.Sprintf("agent.%s-vmlinuz", a.cpuArch), a.bootArtifactsBaseURL,
fmt.Sprintf("agent.%s-rootfs.img", a.cpuArch), a.kernelArgs)
fmt.Sprintf("%s.%s-initrd.img", a.filePrefix, a.cpuArch), a.bootArtifactsBaseURL,
fmt.Sprintf("%s.%s-vmlinuz", a.filePrefix, a.cpuArch), a.bootArtifactsBaseURL,
fmt.Sprintf("%s.%s-rootfs.img", a.filePrefix, a.cpuArch), a.kernelArgs)

iPXEFile := fmt.Sprintf("agent.%s.ipxe", a.cpuArch)
iPXEFile := fmt.Sprintf("%s.%s.ipxe", a.filePrefix, a.cpuArch)

err := os.WriteFile(filepath.Join(pxeAssetsFullPath, iPXEFile), []byte(iPXEScript), 0600)
if err != nil {
Expand Down Expand Up @@ -238,13 +251,13 @@ func (a *AgentPXEFiles) handleAdditionals390xArtifacts(bootArtifactsFullPath str
return err
}

agentInitrdAddrFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("agent.%s-initrd.addrsize", a.cpuArch))
agentInitrdAddrFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("%s.%s-initrd.addrsize", a.filePrefix, a.cpuArch))
err = copyfile(agentInitrdAddrFile, addrsizeFile)
if err != nil {
return err
}

agentINSFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("agent.%s-generic.ins", a.cpuArch))
agentINSFile := filepath.Join(bootArtifactsFullPath, fmt.Sprintf("%s.%s-generic.ins", a.filePrefix, a.cpuArch))
genericReader, err := os.Open(filepath.Join(a.tmpPath, "generic.ins"))
if err != nil {
return err
Expand Down