Skip to content

Commit 4e5fe0d

Browse files
Merge pull request #8009 from andfasano/agent-day2-use-clusterinfo
AGENT-857: Agent day2 use clusterinfo
2 parents ca71358 + 6912900 commit 4e5fe0d

File tree

308 files changed

+31056
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+31056
-215
lines changed

cmd/node-joiner/main.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
package main
22

33
import (
4-
"os"
5-
64
"github.com/sirupsen/logrus"
75
"github.com/spf13/cobra"
86

97
"github.com/openshift/installer/pkg/nodejoiner"
108
)
119

1210
func main() {
13-
wd, err := os.Getwd()
14-
if err != nil {
15-
logrus.Fatal(err)
16-
}
17-
1811
nodesAddCmd := &cobra.Command{
1912
Use: "add-nodes",
2013
Short: "Generates an ISO that could be used to boot the configured nodes to let them join an existing cluster",
@@ -23,22 +16,27 @@ func main() {
2316
if err != nil {
2417
return err
2518
}
26-
return nodejoiner.NewAddNodesCommand(wd, kubeConfig)
19+
dir, err := cmd.Flags().GetString("dir")
20+
if err != nil {
21+
return err
22+
}
23+
return nodejoiner.NewAddNodesCommand(dir, kubeConfig)
2724
},
2825
}
2926

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

3835
rootCmd := &cobra.Command{
3936
Use: "node-joiner",
4037
}
4138
rootCmd.PersistentFlags().String("kubeconfig", "", "Path to the kubeconfig file.")
39+
rootCmd.PersistentFlags().String("dir", ".", "assets directory")
4240

4341
rootCmd.AddCommand(nodesAddCmd)
4442
rootCmd.AddCommand(nodesMonitorCmd)

cmd/openshift-install/testdata/agent/unconfigured-ignition/configurations/from-ztp-manifests.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,25 @@ spec:
5858

5959
-- expected/infraenv.yaml --
6060
metadata:
61+
creationTimestamp: null
6162
name: ostest
6263
namespace: cluster0
6364
spec:
6465
cpuArchitecture: x86_64
66+
ipxeScriptType: ""
67+
nmStateConfigLabelSelector: {}
6568
pullSecretRef:
6669
name: ostest-pull-secret
6770
sshAuthorizedKey: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDK6UTEydcEKzuNdPaofn8Z2DwgHqdcionLZBiPf/zIRNco++etLsat7Avv7yt04DINQd5zjxIFgG8jblaUB5E5C9ClUcMwb52GO0ay2Y9v1uBv1a4WhI3peKktAzYNk0EBMQlJtXPjRMrC9ylBPh+DsBHMu+KmDnfk7PIwyN4efC8k5kSRuPWoNdme1rz2+umU8FSmaWTHIajrbspf4GQbsntA5kuKEtDbfoNCU97o2KrRnUbeg3a8hwSjfh3u6MhlnGcg5K2Ij+zivEsWGCLKYUtE1ErqwfIzwWmJ6jnV66XCQGHf4Q1iIxqF7s2a1q24cgG2Z/iDXfqXrCIfy4P7b/Ztak3bdT9jfAdVZtdO5/r7I+O5hYhF86ayFlDWzZWP/ByiSb+q4CQbfVgK3BMmiAv2MqLHdhesmD/SmIcoOWUF6rFmRKZVFFpKpt5ATNTgUJ3JRowoXrrDruVXClUGRiCS6Zabd1rZ3VmTchaPJwtzQMdfIWISXj+Ig+C4UK0=
68-
71+
status:
72+
agentLabelSelector: {}
73+
bootArtifacts:
74+
initrd: ""
75+
ipxeScript: ""
76+
kernel: ""
77+
rootfs: ""
78+
debugInfo:
79+
eventsURL: ""
6980
-- expected/pull-secret.yaml --
7081
apiVersion: v1
7182
kind: Secret

pkg/asset/agent/agentconfig/agenthosts.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
1414
"github.com/openshift/installer/pkg/asset"
1515
agentAsset "github.com/openshift/installer/pkg/asset/agent"
16+
"github.com/openshift/installer/pkg/asset/agent/workflow"
1617
"github.com/openshift/installer/pkg/types/agent"
1718
"github.com/openshift/installer/pkg/types/baremetal/validation"
1819
"github.com/openshift/installer/pkg/validate"
@@ -49,16 +50,24 @@ func (a *AgentHosts) Name() string {
4950
// Dependencies returns all of the dependencies directly needed the asset.
5051
func (a *AgentHosts) Dependencies() []asset.Asset {
5152
return []asset.Asset{
53+
&workflow.AgentWorkflow{},
5254
&agentAsset.OptionalInstallConfig{},
5355
&AgentConfig{},
5456
}
5557
}
5658

5759
// Generate generates the Hosts data.
5860
func (a *AgentHosts) Generate(dependencies asset.Parents) error {
61+
agentWorkflow := &workflow.AgentWorkflow{}
5962
agentConfig := &AgentConfig{}
6063
installConfig := &agentAsset.OptionalInstallConfig{}
61-
dependencies.Get(agentConfig, installConfig)
64+
dependencies.Get(agentConfig, installConfig, agentWorkflow)
65+
66+
// Temporary skip in case of add nodes workflow. To be addressed
67+
// by AGENT-874
68+
if agentWorkflow.Workflow == workflow.AgentWorkflowTypeAddNodes {
69+
return nil
70+
}
6271

6372
if agentConfig.Config != nil {
6473
a.RendezvousIP = agentConfig.Config.RendezvousIP

pkg/asset/agent/agentconfig/agenthosts_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
1313
"github.com/openshift/installer/pkg/asset"
1414
agentAsset "github.com/openshift/installer/pkg/asset/agent"
15+
"github.com/openshift/installer/pkg/asset/agent/workflow"
1516
"github.com/openshift/installer/pkg/asset/installconfig"
1617
"github.com/openshift/installer/pkg/ipnet"
1718
"github.com/openshift/installer/pkg/types"
@@ -80,6 +81,7 @@ func TestAgentHosts_Generate(t *testing.T) {
8081
{
8182
name: "no-hosts",
8283
dependencies: []asset.Asset{
84+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
8385
getNoHostsInstallConfig(),
8486
getNoHostsAgentConfig(),
8587
},
@@ -88,6 +90,7 @@ func TestAgentHosts_Generate(t *testing.T) {
8890
{
8991
name: "host-from-agent-config",
9092
dependencies: []asset.Asset{
93+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
9194
getInstallConfigSingleHost(),
9295
getAgentConfigSingleHost(),
9396
},
@@ -96,6 +99,7 @@ func TestAgentHosts_Generate(t *testing.T) {
9699
{
97100
name: "host-from-install-config",
98101
dependencies: []asset.Asset{
102+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
99103
getInstallConfigSingleHost(),
100104
getNoHostsAgentConfig(),
101105
},
@@ -104,6 +108,7 @@ func TestAgentHosts_Generate(t *testing.T) {
104108
{
105109
name: "multi-host-from-agent-config",
106110
dependencies: []asset.Asset{
111+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
107112
getInstallConfigSingleHost(),
108113
getAgentConfigMultiHost(),
109114
},
@@ -114,6 +119,7 @@ func TestAgentHosts_Generate(t *testing.T) {
114119
{
115120
name: "multi-host-from-install-config",
116121
dependencies: []asset.Asset{
122+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
117123
getInstallConfigMultiHost(),
118124
getNoHostsAgentConfig(),
119125
},
@@ -124,6 +130,7 @@ func TestAgentHosts_Generate(t *testing.T) {
124130
{
125131
name: "unsupported-device-name-agent-config",
126132
dependencies: []asset.Asset{
133+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
127134
getInstallConfigSingleHost(),
128135
getAgentConfigUnsupportedDeviceName(),
129136
},
@@ -133,6 +140,7 @@ func TestAgentHosts_Generate(t *testing.T) {
133140
{
134141
name: "unsupported-wwn-extension-install-config",
135142
dependencies: []asset.Asset{
143+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
136144
getInstallConfigUnsupportedWWNExtension(),
137145
getNoHostsAgentConfig(),
138146
},
@@ -142,6 +150,7 @@ func TestAgentHosts_Generate(t *testing.T) {
142150
{
143151
name: "unsupported-www-vendor-extension-agent-config",
144152
dependencies: []asset.Asset{
153+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
145154
getInstallConfigSingleHost(),
146155
getAgentConfigUnsupportedWWNVendorExtension(),
147156
},
@@ -151,6 +160,7 @@ func TestAgentHosts_Generate(t *testing.T) {
151160
{
152161
name: "node-hostname-and-role-are-not-required",
153162
dependencies: []asset.Asset{
163+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
154164
getInstallConfigNoHostnameOrRole(),
155165
getNoHostsAgentConfig(),
156166
},
@@ -159,6 +169,7 @@ func TestAgentHosts_Generate(t *testing.T) {
159169
{
160170
name: "host-roles-have-incorrect-values",
161171
dependencies: []asset.Asset{
172+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
162173
getInstallConfigSingleHost(),
163174
getAgentConfigInvalidHostRole(),
164175
},
@@ -168,6 +179,7 @@ func TestAgentHosts_Generate(t *testing.T) {
168179
{
169180
name: "different-hosts-cannot-have-same-mac",
170181
dependencies: []asset.Asset{
182+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
171183
getInstallConfigSameMac(),
172184
getNoHostsAgentConfig(),
173185
},
@@ -177,6 +189,7 @@ func TestAgentHosts_Generate(t *testing.T) {
177189
{
178190
name: "invalid-mac",
179191
dependencies: []asset.Asset{
192+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
180193
getInstallConfigSingleHost(),
181194
getAgentConfigInvalidMac(),
182195
},
@@ -186,6 +199,7 @@ func TestAgentHosts_Generate(t *testing.T) {
186199
{
187200
name: "duplicate-mac-same-host-agent-config",
188201
dependencies: []asset.Asset{
202+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
189203
getInstallConfigSingleHost(),
190204
getAgentConfigInvalidInterfaces(),
191205
},
@@ -195,6 +209,7 @@ func TestAgentHosts_Generate(t *testing.T) {
195209
{
196210
name: "duplicate-mac-same-host-install-config",
197211
dependencies: []asset.Asset{
212+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
198213
getInstallConfigInvalidInterfaces(),
199214
getNoHostsAgentConfig(),
200215
},
@@ -204,6 +219,7 @@ func TestAgentHosts_Generate(t *testing.T) {
204219
{
205220
name: "invalid-rendezvous-agent-config",
206221
dependencies: []asset.Asset{
222+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
207223
getInstallConfigSingleHost(),
208224
getAgentConfigInvalidRendezvousIP(),
209225
},
@@ -213,6 +229,7 @@ func TestAgentHosts_Generate(t *testing.T) {
213229
{
214230
name: "invalid-rendezvous-install-config",
215231
dependencies: []asset.Asset{
232+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
216233
getInstallConfigInvalidRendezvousIP(),
217234
getNoHostsAgentConfig(),
218235
},
@@ -222,6 +239,7 @@ func TestAgentHosts_Generate(t *testing.T) {
222239
{
223240
name: "host-missing-interface-error",
224241
dependencies: []asset.Asset{
242+
&workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall},
225243
getInstallConfigSingleHost(),
226244
getAgentConfigMissingInterfaces(),
227245
},

pkg/asset/agent/image/agentimage.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import (
1414
"github.com/openshift/assisted-image-service/pkg/isoeditor"
1515
hiveext "github.com/openshift/assisted-service/api/hiveextension/v1beta1"
1616
"github.com/openshift/installer/pkg/asset"
17+
"github.com/openshift/installer/pkg/asset/agent/joiner"
1718
"github.com/openshift/installer/pkg/asset/agent/manifests"
19+
"github.com/openshift/installer/pkg/asset/agent/workflow"
1820
)
1921

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

4852
// Generate generates the image file for to ISO asset.
4953
func (a *AgentImage) Generate(dependencies asset.Parents) error {
54+
agentWorkflow := &workflow.AgentWorkflow{}
55+
clusterInfo := &joiner.ClusterInfo{}
5056
agentArtifacts := &AgentArtifacts{}
5157
agentManifests := &manifests.AgentManifests{}
5258
baseIso := &BaseIso{}
53-
dependencies.Get(agentArtifacts, agentManifests, baseIso)
59+
dependencies.Get(agentArtifacts, agentManifests, baseIso, agentWorkflow, clusterInfo)
60+
61+
switch agentWorkflow.Workflow {
62+
case workflow.AgentWorkflowTypeInstall:
63+
a.platform = agentManifests.AgentClusterInstall.Spec.PlatformType
64+
65+
case workflow.AgentWorkflowTypeAddNodes:
66+
a.platform = clusterInfo.PlatformType
67+
68+
default:
69+
return fmt.Errorf("AgentWorkflowType value not supported: %s", agentWorkflow.Workflow)
70+
}
5471

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

67-
a.platform = agentManifests.AgentClusterInstall.Spec.PlatformType
6884
if a.platform == hiveext.ExternalPlatformType {
6985
// when the bootArtifactsBaseURL is specified, construct the custom rootfs URL
7086
if a.bootArtifactsBaseURL != "" {

pkg/asset/agent/image/kargs.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/openshift/assisted-service/models"
88
"github.com/openshift/installer/pkg/asset"
99
"github.com/openshift/installer/pkg/asset/agent/manifests"
10+
"github.com/openshift/installer/pkg/asset/agent/workflow"
1011
)
1112

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

2527
// Generate generates the kernel args configurations for the agent ISO image and PXE assets.
2628
func (a *Kargs) Generate(dependencies asset.Parents) error {
29+
agentWorkflow := &workflow.AgentWorkflow{}
2730
agentClusterInstall := &manifests.AgentClusterInstall{}
28-
dependencies.Get(agentClusterInstall)
31+
dependencies.Get(agentClusterInstall, agentWorkflow)
32+
33+
// Not required for AddNodes workflow
34+
if agentWorkflow.Workflow == workflow.AgentWorkflowTypeAddNodes {
35+
return nil
36+
}
2937

3038
// Add kernel args for external oci platform
3139
if agentClusterInstall.GetExternalPlatformName() == string(models.PlatformTypeOci) {

pkg/asset/agent/installconfig.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ func (a *OptionalInstallConfig) ClusterName() string {
306306
return "agent-cluster"
307307
}
308308

309+
// ClusterNamespace returns the namespace of the cluster.
310+
func (a *OptionalInstallConfig) ClusterNamespace() string {
311+
if a.Config != nil && a.Config.ObjectMeta.Namespace != "" {
312+
return a.Config.ObjectMeta.Namespace
313+
}
314+
return ""
315+
}
316+
309317
// GetBaremetalHosts gets the hosts defined for a baremetal platform.
310318
func (a *OptionalInstallConfig) GetBaremetalHosts() []*baremetal.Host {
311319
if a.Config != nil && a.Config.Platform.Name() == baremetal.Name {

0 commit comments

Comments
 (0)