Skip to content

Commit

Permalink
WIP AGENT-972, AGENT-973: Agent minimal ISO support for all platforms
Browse files Browse the repository at this point in the history
Add the ability to enable minimal ISO support for all platform types,
not just External. Adds a new flag to the 'agent create image' command.

Still WIP as dev-scripts testing needs to be done and integration tests
added.
  • Loading branch information
bfournie committed Sep 26, 2024
1 parent 30ba9c5 commit 305db9a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
7 changes: 7 additions & 0 deletions cmd/openshift-install/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (
"github.com/openshift/installer/pkg/asset/password"
)

var (
agentImageMinimalISO = false
)

func newAgentCmd(ctx context.Context) *cobra.Command {
agentCmd := &cobra.Command{
Use: "agent",
Expand Down Expand Up @@ -129,6 +133,9 @@ func newAgentCreateCmd(ctx context.Context) *cobra.Command {
for _, t := range agentTargets {
t.command.Args = cobra.ExactArgs(0)
t.command.Run = runTargetCmd(ctx, t.assets...)
if t.name == "Agent ISO Image" {
t.command.PersistentFlags().BoolVar(&agentImageMinimalISO, "minimal-iso", false, "generates a minimal ISO image, by default a full ISO will be generated.")
}
cmd.AddCommand(t.command)
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/openshift-install/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"github.com/openshift/installer/cmd/openshift-install/command"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent/agentconfig"
agentimage "github.com/openshift/installer/pkg/asset/agent/image"
"github.com/openshift/installer/pkg/asset/cluster"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/asset/kubeconfig"
Expand Down Expand Up @@ -317,6 +318,10 @@ func runTargetCmd(ctx context.Context, targets ...asset.WritableAsset) func(cmd

cluster.InstallDir = command.RootOpts.Dir

if cmd.Name() == "image" && agentImageMinimalISO {
agentimage.MinimalISOConfigured = true
}

err := runner(command.RootOpts.Dir)
if err != nil {
if strings.Contains(err.Error(), asset.InstallConfigError) {
Expand Down
18 changes: 13 additions & 5 deletions pkg/asset/agent/image/agentimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const (
iso9660Level1ExtLen = 3
)

var (
MinimalISOConfigured = false
)

// AgentImage is an asset that generates the bootable image used to install clusters.
type AgentImage struct {
cpuArch string
Expand All @@ -38,11 +42,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 +59,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 @@ -92,7 +97,10 @@ func (a *AgentImage) Generate(ctx context.Context, dependencies asset.Parents) e
}
a.volumeID = volumeID

if a.platform == hiveext.ExternalPlatformType {
// External platform will always create a minimal ISO
a.minimalISO = MinimalISOConfigured || 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 +234,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
2 changes: 1 addition & 1 deletion pkg/asset/agent/image/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (a *Ignition) Generate(_ context.Context, dependencies asset.Parents) error
logrus.Infof("The rendezvous host IP (node0 IP) is %s", a.RendezvousIP)
// Define cluster name and image type.
clusterName = fmt.Sprintf("%s.%s", agentManifests.ClusterDeployment.Spec.ClusterName, agentManifests.ClusterDeployment.Spec.BaseDomain)
if agentManifests.AgentClusterInstall.Spec.PlatformType == hiveext.ExternalPlatformType {
if MinimalISOConfigured || (agentManifests.AgentClusterInstall.Spec.PlatformType == hiveext.ExternalPlatformType) {
imageTypeISO = "minimal-iso"
}
// Fetch the required number of master and worker nodes.
Expand Down

0 comments on commit 305db9a

Please sign in to comment.