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

AGENT-972, AGENT-973: Agent minimal ISO support for all platforms #9056

Merged
merged 1 commit into from
Oct 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ metadata:
# All fields are optional
rendezvousIP: your-node0-ip
bootArtifactsBaseURL: http://user-specified-infra.com
minimalISO: false
bfournie marked this conversation as resolved.
Show resolved Hide resolved
additionalNTPSources:
- 0.rhel.pool.ntp.org
- 1.rhel.pool.ntp.org
Expand Down
1 change: 1 addition & 0 deletions pkg/asset/agent/agentconfig/agent_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ metadata:
# All fields are optional
rendezvousIP: your-node0-ip
bootArtifactsBaseURL: http://user-specified-infra.com
minimalISO: false
additionalNTPSources:
- 0.rhel.pool.ntp.org
- 1.rhel.pool.ntp.org
Expand Down
11 changes: 11 additions & 0 deletions pkg/asset/agent/image/agentartifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import (
"path/filepath"
"strings"

"github.com/sirupsen/logrus"

"github.com/openshift/assisted-image-service/pkg/isoeditor"
hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent"
config "github.com/openshift/installer/pkg/asset/agent/agentconfig"
Expand All @@ -33,6 +36,7 @@ type AgentArtifacts struct {
Kargs string
ISOPath string
BootArtifactsBaseURL string
MinimalISO bool
}

// Dependencies returns the assets on which the AgentArtifacts asset depends.
Expand Down Expand Up @@ -73,6 +77,13 @@ func (a *AgentArtifacts) Generate(_ context.Context, dependencies asset.Parents)

if agentconfig.Config != nil {
a.BootArtifactsBaseURL = strings.Trim(agentconfig.Config.BootArtifactsBaseURL, "/")
// External platform will always create a minimal ISO
a.MinimalISO = agentconfig.Config.MinimalISO || agentManifests.AgentClusterInstall.Spec.PlatformType == hiveext.ExternalPlatformType
bfournie marked this conversation as resolved.
Show resolved Hide resolved
if agentconfig.Config.MinimalISO {
logrus.Infof("Minimal ISO will be created based on configuration")
} else if agentManifests.AgentClusterInstall.Spec.PlatformType == hiveext.ExternalPlatformType {
logrus.Infof("Minimal ISO will be created for External platform")
}
}

var agentTuiFiles []string
Expand Down
12 changes: 7 additions & 5 deletions pkg/asset/agent/image/agentimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ type AgentImage struct {
platform hiveext.PlatformType
isoFilename string
imageExpiresAt string
minimalISO bool
}

var _ asset.WritableAsset = (*AgentImage)(nil)

// Dependencies returns the assets on which the Bootstrap asset depends.
// Dependencies returns the assets on which the AgentImage asset depends.
func (a *AgentImage) Dependencies() []asset.Asset {
return []asset.Asset{
&workflow.AgentWorkflow{},
Expand All @@ -54,7 +55,7 @@ func (a *AgentImage) Dependencies() []asset.Asset {
}
}

// Generate generates the image file for to ISO asset.
// Generate generates the image file for an AgentImage asset.
func (a *AgentImage) Generate(ctx context.Context, dependencies asset.Parents) error {
agentWorkflow := &workflow.AgentWorkflow{}
clusterInfo := &joiner.ClusterInfo{}
Expand Down Expand Up @@ -85,14 +86,15 @@ func (a *AgentImage) Generate(ctx context.Context, dependencies asset.Parents) e
a.tmpPath = agentArtifacts.TmpPath
a.isoPath = agentArtifacts.ISOPath
a.bootArtifactsBaseURL = agentArtifacts.BootArtifactsBaseURL
a.minimalISO = agentArtifacts.MinimalISO

volumeID, err := isoeditor.VolumeIdentifier(a.isoPath)
if err != nil {
return err
}
a.volumeID = volumeID

if a.platform == hiveext.ExternalPlatformType {
if a.minimalISO {
// when the bootArtifactsBaseURL is specified, construct the custom rootfs URL
if a.bootArtifactsBaseURL != "" {
a.rootFSURL = fmt.Sprintf("%s/%s", a.bootArtifactsBaseURL, fmt.Sprintf("agent.%s-rootfs.img", a.cpuArch))
Expand Down Expand Up @@ -226,9 +228,9 @@ func (a *AgentImage) PersistToFile(directory string) error {
}

var msg string
// For external platform when the bootArtifactsBaseURL is specified,
// For minimal ISO, when the bootArtifactsBaseURL is specified,
// output the rootfs file alongside the minimal ISO
if a.platform == hiveext.ExternalPlatformType {
if a.minimalISO {
if a.bootArtifactsBaseURL != "" {
bootArtifactsFullPath := filepath.Join(directory, bootArtifactsPath)
err := createDir(bootArtifactsFullPath)
Expand Down
5 changes: 3 additions & 2 deletions pkg/asset/agent/image/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ func (a *Ignition) Generate(_ context.Context, dependencies asset.Parents) error
}
a.RendezvousIP = nodeZeroIP
logrus.Infof("The rendezvous host IP (node0 IP) is %s", a.RendezvousIP)
// Define cluster name and image type.
// Define cluster name
clusterName = fmt.Sprintf("%s.%s", agentManifests.ClusterDeployment.Spec.ClusterName, agentManifests.ClusterDeployment.Spec.BaseDomain)
if agentManifests.AgentClusterInstall.Spec.PlatformType == hiveext.ExternalPlatformType {
if (agentConfigAsset.Config != nil && agentConfigAsset.Config.MinimalISO) ||
(agentManifests.AgentClusterInstall.Spec.PlatformType == hiveext.ExternalPlatformType) {
imageTypeISO = "minimal-iso"
}
// Fetch the required number of master and worker nodes.
Expand Down
3 changes: 3 additions & 0 deletions pkg/types/agent/agent_config_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type Config struct {
RendezvousIP string `json:"rendezvousIP,omitempty"`
BootArtifactsBaseURL string `json:"bootArtifactsBaseURL,omitempty"`
Hosts []Host `json:"hosts,omitempty"`
// When MinimalISO is set to true, a minimal ISO that does not contain the rootfs will be generated.
// By default a full ISO will be created, unless the platform is External, which generates a minimal ISO.
MinimalISO bool `json:"minimalISO,omitempty"`
}

// Host defines per host configurations
Expand Down