@@ -24,8 +24,10 @@ import (
2424 agentcommon "github.com/openshift/installer/pkg/asset/agent"
2525 "github.com/openshift/installer/pkg/asset/agent/agentconfig"
2626 "github.com/openshift/installer/pkg/asset/agent/gencrypto"
27+ "github.com/openshift/installer/pkg/asset/agent/joiner"
2728 "github.com/openshift/installer/pkg/asset/agent/manifests"
2829 "github.com/openshift/installer/pkg/asset/agent/mirror"
30+ "github.com/openshift/installer/pkg/asset/agent/workflow"
2931 "github.com/openshift/installer/pkg/asset/ignition"
3032 "github.com/openshift/installer/pkg/asset/ignition/bootstrap"
3133 "github.com/openshift/installer/pkg/asset/password"
@@ -81,6 +83,9 @@ func (a *Ignition) Name() string {
8183// Dependencies returns the assets on which the Ignition asset depends.
8284func (a * Ignition ) Dependencies () []asset.Asset {
8385 return []asset.Asset {
86+ & workflow.AgentWorkflow {},
87+ & joiner.ClusterInfo {},
88+ & joiner.AddNodesConfig {},
8489 & manifests.AgentManifests {},
8590 & manifests.ExtraManifests {},
8691 & tls.KubeAPIServerLBSignerCertKey {},
@@ -98,12 +103,15 @@ func (a *Ignition) Dependencies() []asset.Asset {
98103
99104// Generate generates the agent installer ignition.
100105func (a * Ignition ) Generate (dependencies asset.Parents ) error {
106+ agentWorkflow := & workflow.AgentWorkflow {}
107+ clusterInfo := & joiner.ClusterInfo {}
108+ addNodesConfig := & joiner.AddNodesConfig {}
101109 agentManifests := & manifests.AgentManifests {}
102110 agentConfigAsset := & agentconfig.AgentConfig {}
103111 agentHostsAsset := & agentconfig.AgentHosts {}
104112 extraManifests := & manifests.ExtraManifests {}
105113 keyPairAsset := & gencrypto.AuthConfig {}
106- dependencies .Get (agentManifests , agentConfigAsset , agentHostsAsset , extraManifests , keyPairAsset )
114+ dependencies .Get (agentManifests , agentConfigAsset , agentHostsAsset , extraManifests , keyPairAsset , agentWorkflow , clusterInfo , addNodesConfig )
107115
108116 pwd := & password.KubeadminPassword {}
109117 dependencies .Get (pwd )
@@ -128,14 +136,42 @@ func (a *Ignition) Generate(dependencies asset.Parents) error {
128136 },
129137 }
130138
131- nodeZeroIP , err := RetrieveRendezvousIP ( agentConfigAsset . Config , agentHostsAsset . Hosts , agentManifests . NMStateConfigs )
132- if err != nil {
133- return err
134- }
139+ clusterName := ""
140+ imageTypeISO := "full-iso"
141+ numMasters := 0
142+ numWorkers := 0
135143
136- logrus .Infof ("The rendezvous host IP (node0 IP) is %s" , nodeZeroIP )
144+ switch agentWorkflow .Workflow {
145+ case workflow .AgentWorkflowTypeInstall :
146+ // Set rendezvous IP.
147+ nodeZeroIP , err := RetrieveRendezvousIP (agentConfigAsset .Config , agentHostsAsset .Hosts , agentManifests .NMStateConfigs )
148+ if err != nil {
149+ return err
150+ }
151+ a .RendezvousIP = nodeZeroIP
152+ logrus .Infof ("The rendezvous host IP (node0 IP) is %s" , a .RendezvousIP )
153+ // Define cluster name and image type.
154+ clusterName = fmt .Sprintf ("%s.%s" , agentManifests .ClusterDeployment .Spec .ClusterName , agentManifests .ClusterDeployment .Spec .BaseDomain )
155+ if agentManifests .AgentClusterInstall .Spec .PlatformType == hiveext .ExternalPlatformType {
156+ imageTypeISO = "minimal-iso"
157+ }
158+ // Fetch the required number of master and worker nodes.
159+ numMasters = agentManifests .AgentClusterInstall .Spec .ProvisionRequirements .ControlPlaneAgents
160+ numWorkers = agentManifests .AgentClusterInstall .Spec .ProvisionRequirements .WorkerAgents
161+
162+ case workflow .AgentWorkflowTypeAddNodes :
163+ // In the add-nodes workflow, every node will act independently from the others.
164+ a .RendezvousIP = "127.0.0.1"
165+ // Reuse the existing cluster name.
166+ clusterName = clusterInfo .ClusterName
167+ // Fetch the required number of master and worker nodes.
168+ numMasters = 0
169+ numWorkers = len (addNodesConfig .Config .Hosts )
170+
171+ default :
172+ return fmt .Errorf ("AgentWorkflowType value not supported: %s" , agentWorkflow .Workflow )
173+ }
137174
138- a .RendezvousIP = nodeZeroIP
139175 // Default to x86_64
140176 archName := arch .RpmArch (types .ArchitectureAMD64 )
141177 if infraEnv .Spec .CpuArchitecture != "" {
@@ -176,16 +212,6 @@ func (a *Ignition) Generate(dependencies asset.Parents) error {
176212 }
177213 a .CPUArch = * osImage .CPUArchitecture
178214
179- clusterName := fmt .Sprintf ("%s.%s" ,
180- agentManifests .ClusterDeployment .Spec .ClusterName ,
181- agentManifests .ClusterDeployment .Spec .BaseDomain )
182-
183- imageTypeISO := "full-iso"
184- platform := agentManifests .AgentClusterInstall .Spec .PlatformType
185- if platform == hiveext .ExternalPlatformType {
186- imageTypeISO = "minimal-iso"
187- }
188-
189215 agentTemplateData := getTemplateData (
190216 clusterName ,
191217 agentManifests .GetPullSecretData (),
@@ -194,7 +220,7 @@ func (a *Ignition) Generate(dependencies asset.Parents) error {
194220 releaseImageMirror ,
195221 len (registriesConfig .MirrorConfig ) > 0 ,
196222 publicContainerRegistries ,
197- agentManifests . AgentClusterInstall ,
223+ numMasters , numWorkers ,
198224 infraEnvID ,
199225 osImage ,
200226 infraEnv .Spec .Proxy ,
@@ -210,7 +236,7 @@ func (a *Ignition) Generate(dependencies asset.Parents) error {
210236
211237 rendezvousHostFile := ignition .FileFromString (rendezvousHostEnvPath ,
212238 "root" , 0644 ,
213- getRendezvousHostEnv (agentTemplateData .ServiceProtocol , nodeZeroIP ))
239+ getRendezvousHostEnv (agentTemplateData .ServiceProtocol , a . RendezvousIP ))
214240 config .Storage .Files = append (config .Storage .Files , rendezvousHostFile )
215241
216242 err = addBootstrapScripts (& config , agentManifests .ClusterImageSet .Spec .ReleaseImage )
@@ -313,16 +339,16 @@ func addBootstrapScripts(config *igntypes.Config, releaseImage string) (err erro
313339
314340func getTemplateData (name , pullSecret , releaseImageList , releaseImage ,
315341 releaseImageMirror string , haveMirrorConfig bool , publicContainerRegistries string ,
316- agentClusterInstall * hiveext. AgentClusterInstall ,
342+ numMasters int , numWorkers int ,
317343 infraEnvID string ,
318344 osImage * models.OsImage ,
319345 proxy * v1beta1.Proxy ,
320346 imageTypeISO , privateKey , publicKey string ) * agentTemplateData {
321347 return & agentTemplateData {
322348 ServiceProtocol : "http" ,
323349 PullSecret : pullSecret ,
324- ControlPlaneAgents : agentClusterInstall . Spec . ProvisionRequirements . ControlPlaneAgents ,
325- WorkerAgents : agentClusterInstall . Spec . ProvisionRequirements . WorkerAgents ,
350+ ControlPlaneAgents : numMasters ,
351+ WorkerAgents : numWorkers ,
326352 ReleaseImages : releaseImageList ,
327353 ReleaseImage : releaseImage ,
328354 ReleaseImageMirror : releaseImageMirror ,
0 commit comments