Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 7 additions & 9 deletions cmd/node-joiner/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
package main

import (
"os"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/openshift/installer/pkg/nodejoiner"
)

func main() {
wd, err := os.Getwd()
if err != nil {
logrus.Fatal(err)
}

nodesAddCmd := &cobra.Command{
Use: "add-nodes",
Short: "Generates an ISO that could be used to boot the configured nodes to let them join an existing cluster",
Expand All @@ -23,22 +16,27 @@ func main() {
if err != nil {
return err
}
return nodejoiner.NewAddNodesCommand(wd, kubeConfig)
dir, err := cmd.Flags().GetString("dir")
if err != nil {
return err
}
return nodejoiner.NewAddNodesCommand(dir, kubeConfig)
},
}

nodesMonitorCmd := &cobra.Command{
Use: "monitor-add-nodes",
Short: "Monitors the configured nodes while they are joining an existing cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return nodejoiner.NewMonitorAddNodesCommand(wd)
return nodejoiner.NewMonitorAddNodesCommand("")
},
}

rootCmd := &cobra.Command{
Use: "node-joiner",
}
rootCmd.PersistentFlags().String("kubeconfig", "", "Path to the kubeconfig file.")
rootCmd.PersistentFlags().String("dir", ".", "assets directory")

rootCmd.AddCommand(nodesAddCmd)
rootCmd.AddCommand(nodesMonitorCmd)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,25 @@ spec:

-- expected/infraenv.yaml --
metadata:
creationTimestamp: null
name: ostest
namespace: cluster0
spec:
cpuArchitecture: x86_64
ipxeScriptType: ""
Copy link
Contributor

Choose a reason for hiding this comment

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

The usage of ipxeScriptType is unclear to me. The only possible values in assisted are DiscoveryImageAlways and BootOrderControl. How is the agent installer using these values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I re-checked, and the test changes were triggered by the refactoring/changes in infraenv.go

nmStateConfigLabelSelector: {}
pullSecretRef:
name: ostest-pull-secret
sshAuthorizedKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDK6UTEydcEKzuNdPaofn8Z2DwgHqdcionLZBiPf/zIRNco++etLsat7Avv7yt04DINQd5zjxIFgG8jblaUB5E5C9ClUcMwb52GO0ay2Y9v1uBv1a4WhI3peKktAzYNk0EBMQlJtXPjRMrC9ylBPh+DsBHMu+KmDnfk7PIwyN4efC8k5kSRuPWoNdme1rz2+umU8FSmaWTHIajrbspf4GQbsntA5kuKEtDbfoNCU97o2KrRnUbeg3a8hwSjfh3u6MhlnGcg5K2Ij+zivEsWGCLKYUtE1ErqwfIzwWmJ6jnV66XCQGHf4Q1iIxqF7s2a1q24cgG2Z/iDXfqXrCIfy4P7b/Ztak3bdT9jfAdVZtdO5/r7I+O5hYhF86ayFlDWzZWP/ByiSb+q4CQbfVgK3BMmiAv2MqLHdhesmD/SmIcoOWUF6rFmRKZVFFpKpt5ATNTgUJ3JRowoXrrDruVXClUGRiCS6Zabd1rZ3VmTchaPJwtzQMdfIWISXj+Ig+C4UK0=

status:
agentLabelSelector: {}
bootArtifacts:
initrd: ""
ipxeScript: ""
kernel: ""
rootfs: ""
debugInfo:
eventsURL: ""
-- expected/pull-secret.yaml --
apiVersion: v1
kind: Secret
Expand Down
11 changes: 10 additions & 1 deletion pkg/asset/agent/agentconfig/agenthosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
"github.com/openshift/installer/pkg/asset"
agentAsset "github.com/openshift/installer/pkg/asset/agent"
"github.com/openshift/installer/pkg/asset/agent/workflow"
"github.com/openshift/installer/pkg/types/agent"
"github.com/openshift/installer/pkg/types/baremetal/validation"
"github.com/openshift/installer/pkg/validate"
Expand Down Expand Up @@ -49,16 +50,24 @@ func (a *AgentHosts) Name() string {
// Dependencies returns all of the dependencies directly needed the asset.
func (a *AgentHosts) Dependencies() []asset.Asset {
return []asset.Asset{
&workflow.AgentWorkflow{},
&agentAsset.OptionalInstallConfig{},
&AgentConfig{},
}
}

// Generate generates the Hosts data.
func (a *AgentHosts) Generate(dependencies asset.Parents) error {
agentWorkflow := &workflow.AgentWorkflow{}
agentConfig := &AgentConfig{}
installConfig := &agentAsset.OptionalInstallConfig{}
dependencies.Get(agentConfig, installConfig)
dependencies.Get(agentConfig, installConfig, agentWorkflow)

// Temporary skip in case of add nodes workflow. To be addressed
// by AGENT-874
if agentWorkflow.Workflow == workflow.AgentWorkflowTypeAddNodes {
return nil
}

if agentConfig.Config != nil {
a.RendezvousIP = agentConfig.Config.RendezvousIP
Expand Down
18 changes: 18 additions & 0 deletions pkg/asset/agent/agentconfig/agenthosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
"github.com/openshift/installer/pkg/asset"
agentAsset "github.com/openshift/installer/pkg/asset/agent"
"github.com/openshift/installer/pkg/asset/agent/workflow"
"github.com/openshift/installer/pkg/asset/installconfig"
"github.com/openshift/installer/pkg/ipnet"
"github.com/openshift/installer/pkg/types"
Expand Down Expand Up @@ -80,6 +81,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "no-hosts",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getNoHostsInstallConfig(),
getNoHostsAgentConfig(),
},
Expand All @@ -88,6 +90,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "host-from-agent-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigSingleHost(),
},
Expand All @@ -96,6 +99,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "host-from-install-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getNoHostsAgentConfig(),
},
Expand All @@ -104,6 +108,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "multi-host-from-agent-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigMultiHost(),
},
Expand All @@ -114,6 +119,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "multi-host-from-install-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigMultiHost(),
getNoHostsAgentConfig(),
},
Expand All @@ -124,6 +130,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "unsupported-device-name-agent-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigUnsupportedDeviceName(),
},
Expand All @@ -133,6 +140,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "unsupported-wwn-extension-install-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigUnsupportedWWNExtension(),
getNoHostsAgentConfig(),
},
Expand All @@ -142,6 +150,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "unsupported-www-vendor-extension-agent-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigUnsupportedWWNVendorExtension(),
},
Expand All @@ -151,6 +160,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "node-hostname-and-role-are-not-required",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigNoHostnameOrRole(),
getNoHostsAgentConfig(),
},
Expand All @@ -159,6 +169,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "host-roles-have-incorrect-values",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigInvalidHostRole(),
},
Expand All @@ -168,6 +179,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "different-hosts-cannot-have-same-mac",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSameMac(),
getNoHostsAgentConfig(),
},
Expand All @@ -177,6 +189,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "invalid-mac",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigInvalidMac(),
},
Expand All @@ -186,6 +199,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "duplicate-mac-same-host-agent-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigInvalidInterfaces(),
},
Expand All @@ -195,6 +209,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "duplicate-mac-same-host-install-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigInvalidInterfaces(),
getNoHostsAgentConfig(),
},
Expand All @@ -204,6 +219,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "invalid-rendezvous-agent-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigInvalidRendezvousIP(),
},
Expand All @@ -213,6 +229,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "invalid-rendezvous-install-config",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigInvalidRendezvousIP(),
getNoHostsAgentConfig(),
},
Expand All @@ -222,6 +239,7 @@ func TestAgentHosts_Generate(t *testing.T) {
{
name: "host-missing-interface-error",
dependencies: []asset.Asset{
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
getInstallConfigSingleHost(),
getAgentConfigMissingInterfaces(),
},
Expand Down
20 changes: 18 additions & 2 deletions pkg/asset/agent/image/agentimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"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/joiner"
"github.com/openshift/installer/pkg/asset/agent/manifests"
"github.com/openshift/installer/pkg/asset/agent/workflow"
)

const (
Expand All @@ -39,6 +41,8 @@ var _ asset.WritableAsset = (*AgentImage)(nil)
// Dependencies returns the assets on which the Bootstrap asset depends.
func (a *AgentImage) Dependencies() []asset.Asset {
return []asset.Asset{
&workflow.AgentWorkflow{},
&joiner.ClusterInfo{},
&AgentArtifacts{},
&manifests.AgentManifests{},
&BaseIso{},
Expand All @@ -47,10 +51,23 @@ func (a *AgentImage) Dependencies() []asset.Asset {

// Generate generates the image file for to ISO asset.
func (a *AgentImage) Generate(dependencies asset.Parents) error {
agentWorkflow := &workflow.AgentWorkflow{}
clusterInfo := &joiner.ClusterInfo{}
agentArtifacts := &AgentArtifacts{}
agentManifests := &manifests.AgentManifests{}
baseIso := &BaseIso{}
dependencies.Get(agentArtifacts, agentManifests, baseIso)
dependencies.Get(agentArtifacts, agentManifests, baseIso, agentWorkflow, clusterInfo)

switch agentWorkflow.Workflow {
case workflow.AgentWorkflowTypeInstall:
a.platform = agentManifests.AgentClusterInstall.Spec.PlatformType

case workflow.AgentWorkflowTypeAddNodes:
a.platform = clusterInfo.PlatformType

default:
return fmt.Errorf("AgentWorkflowType value not supported: %s", agentWorkflow.Workflow)
}

a.cpuArch = agentArtifacts.CPUArch
a.rendezvousIP = agentArtifacts.RendezvousIP
Expand All @@ -64,7 +81,6 @@ func (a *AgentImage) Generate(dependencies asset.Parents) error {
}
a.volumeID = volumeID

a.platform = agentManifests.AgentClusterInstall.Spec.PlatformType
if a.platform == hiveext.ExternalPlatformType {
// when the bootArtifactsBaseURL is specified, construct the custom rootfs URL
if a.bootArtifactsBaseURL != "" {
Expand Down
10 changes: 9 additions & 1 deletion pkg/asset/agent/image/kargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/openshift/assisted-service/models"
"github.com/openshift/installer/pkg/asset"
"github.com/openshift/installer/pkg/asset/agent/manifests"
"github.com/openshift/installer/pkg/asset/agent/workflow"
)

// Kargs is an Asset that generates the additional kernel args.
Expand All @@ -18,14 +19,21 @@ type Kargs struct {
// Dependencies returns the assets on which the Kargs asset depends.
func (a *Kargs) Dependencies() []asset.Asset {
return []asset.Asset{
&workflow.AgentWorkflow{},
&manifests.AgentClusterInstall{},
}
}

// Generate generates the kernel args configurations for the agent ISO image and PXE assets.
func (a *Kargs) Generate(dependencies asset.Parents) error {
agentWorkflow := &workflow.AgentWorkflow{}
agentClusterInstall := &manifests.AgentClusterInstall{}
dependencies.Get(agentClusterInstall)
dependencies.Get(agentClusterInstall, agentWorkflow)

// Not required for AddNodes workflow
if agentWorkflow.Workflow == workflow.AgentWorkflowTypeAddNodes {
return nil
}

// Add kernel args for external oci platform
if agentClusterInstall.GetExternalPlatformName() == string(models.PlatformTypeOci) {
Expand Down
8 changes: 8 additions & 0 deletions pkg/asset/agent/installconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ func (a *OptionalInstallConfig) ClusterName() string {
return "agent-cluster"
}

// ClusterNamespace returns the namespace of the cluster.
func (a *OptionalInstallConfig) ClusterNamespace() string {
if a.Config != nil && a.Config.ObjectMeta.Namespace != "" {
return a.Config.ObjectMeta.Namespace
}
return ""
}

// GetBaremetalHosts gets the hosts defined for a baremetal platform.
func (a *OptionalInstallConfig) GetBaremetalHosts() []*baremetal.Host {
if a.Config != nil && a.Config.Platform.Name() == baremetal.Name {
Expand Down
Loading