From 5497dd0f56c3a1858061504a52719cd110f1817c Mon Sep 17 00:00:00 2001 From: Chin2691 Date: Thu, 21 May 2026 15:10:21 +0530 Subject: [PATCH 1/2] fix: validate agent-config interface names match networkConfig openshift-install agent does not cross-validate that interface names in hosts[].interfaces[] match the names used in hosts[].networkConfig. When names mismatch, the pre-network-manager-config.sh script silently fails to rename .nmconnection files at boot time, causing complete network failure for bond/VLAN/bridge topologies with no diagnostic. Add validateInterfaceNamesMatchNetworkConfig() to validateAgentHosts() that ensures every interfaces[].name exists in the networkConfig interfaces list. The error message lists valid networkConfig names to guide users toward the correct configuration. Only the agent-config.yaml path is affected; install-config.yaml derives interface names from networkConfig automatically, so names always match. Co-authored-by: Cursor --- pkg/asset/agent/agentconfig/agenthosts.go | 45 +++++++ .../agent/agentconfig/agenthosts_test.go | 117 ++++++++++++++++-- 2 files changed, 155 insertions(+), 7 deletions(-) diff --git a/pkg/asset/agent/agentconfig/agenthosts.go b/pkg/asset/agent/agentconfig/agenthosts.go index 272d4900f06..de765053f33 100644 --- a/pkg/asset/agent/agentconfig/agenthosts.go +++ b/pkg/asset/agent/agentconfig/agenthosts.go @@ -125,6 +125,10 @@ func (a *AgentHosts) validateAgentHosts() field.ErrorList { allErrs = append(allErrs, err...) } + if err := a.validateInterfaceNamesMatchNetworkConfig(hostPath, host); err != nil { + allErrs = append(allErrs, err...) + } + if err := a.validateHostRootDeviceHints(hostPath, host); err != nil { allErrs = append(allErrs, err...) } @@ -171,6 +175,47 @@ func (a *AgentHosts) validateHostInterfaces(hostPath *field.Path, host agent.Hos return allErrs } +func (a *AgentHosts) validateInterfaceNamesMatchNetworkConfig(hostPath *field.Path, host agent.Host) field.ErrorList { + if len(host.NetworkConfig.Raw) == 0 || len(host.Interfaces) == 0 { + return nil + } + + var netInterfaces nmStateInterface + if err := yaml.Unmarshal(host.NetworkConfig.Raw, &netInterfaces); err != nil { + return nil + } + + ncNames := make(map[string]bool, len(netInterfaces.Interfaces)) + var ncNameList []string + for _, iface := range netInterfaces.Interfaces { + if iface.Name != "" { + ncNames[iface.Name] = true + ncNameList = append(ncNameList, iface.Name) + } + } + if len(ncNames) == 0 { + return nil + } + + var allErrs field.ErrorList + for j, iface := range host.Interfaces { + if iface.Name == "" { + continue + } + if !ncNames[iface.Name] { + errMsg := "interface name \"" + iface.Name + "\" not found in networkConfig interfaces [" + strings.Join(ncNameList, ", ") + "]; " + + "the interfaces[].name values are logical names that must match the interface names used in networkConfig " + + "so that the MAC-to-interface mapping works correctly at boot time" + allErrs = append(allErrs, field.Invalid( + hostPath.Child("interfaces").Index(j).Child("name"), + iface.Name, + errMsg, + )) + } + } + return allErrs +} + func (a *AgentHosts) validateHostRootDeviceHints(hostPath *field.Path, host agent.Host) field.ErrorList { rdhPath := hostPath.Child("rootDeviceHints") allErrs := validation.ValidateHostRootDeviceHints(&host.RootDeviceHints, rdhPath) diff --git a/pkg/asset/agent/agentconfig/agenthosts_test.go b/pkg/asset/agent/agentconfig/agenthosts_test.go index 3b5a0d2e040..c5b81c37b0a 100644 --- a/pkg/asset/agent/agentconfig/agenthosts_test.go +++ b/pkg/asset/agent/agentconfig/agenthosts_test.go @@ -100,6 +100,30 @@ routes: next-hop-address: 192.168.111.126 next-hop-interface: eth0 table-id: 254 +` + agentNetworkConfigBond = `interfaces: +- name: eth0 + type: ethernet + state: up + mac-address: 28:d2:44:d2:b2:1a +- name: eth1 + type: ethernet + state: up + mac-address: 28:d2:44:d2:b2:1b +- name: bond0 + type: bond + state: up + link-aggregation: + mode: active-backup + port: + - eth0 + - eth1 + ipv4: + enabled: true + dhcp: false + address: + - ip: 192.168.111.80 + prefix-length: 24 ` ) @@ -174,8 +198,8 @@ func TestAgentHosts_Generate(t *testing.T) { getAgentConfigMultiHost("worker"), }, expectedConfig: agentHosts().hosts( - agentHost().name("test").role("master").interfaces(iface("enp3s1", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigOne), - agentHost().name("test-2").role("worker").interfaces(iface("enp3s1", "28:d2:44:d2:b2:1b")).networkConfig(agentNetworkConfigTwo)), + agentHost().name("test").role("master").interfaces(iface("eth0", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigOne), + agentHost().name("test-2").role("worker").interfaces(iface("eth0", "28:d2:44:d2:b2:1b")).networkConfig(agentNetworkConfigTwo)), }, { name: "multi-host-from-install-config", @@ -329,8 +353,8 @@ func TestAgentHosts_Generate(t *testing.T) { getAgentConfigMultiHostEmbeddedRendezvousIP(), }, expectedConfig: agentHosts().hosts( - agentHost().name("test").role("master").interfaces(iface("enp3s1", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigEmbeddedRendezvousIPOne), - agentHost().name("test-2").role("worker").interfaces(iface("enp3s1", "28:d2:44:d2:b2:1b")).networkConfig(agentNetworkConfigEmbeddedRendezvousIPTwo)), + agentHost().name("test").role("master").interfaces(iface("eth0", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigEmbeddedRendezvousIPOne), + agentHost().name("test-2").role("worker").interfaces(iface("eth0", "28:d2:44:d2:b2:1b")).networkConfig(agentNetworkConfigEmbeddedRendezvousIPTwo)), }, { name: "multi-host-from-agent-config-with-arbiter", @@ -341,8 +365,52 @@ func TestAgentHosts_Generate(t *testing.T) { getAgentConfigMultiHost("arbiter"), }, expectedConfig: agentHosts().hosts( - agentHost().name("test").role("master").interfaces(iface("enp3s1", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigOne), - agentHost().name("test-2").role("arbiter").interfaces(iface("enp3s1", "28:d2:44:d2:b2:1b")).networkConfig(agentNetworkConfigTwo)), + agentHost().name("test").role("master").interfaces(iface("eth0", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigOne), + agentHost().name("test-2").role("arbiter").interfaces(iface("eth0", "28:d2:44:d2:b2:1b")).networkConfig(agentNetworkConfigTwo)), + }, + { + name: "interface-name-mismatch-with-networkconfig", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, + &joiner.AddNodesConfig{}, + getInstallConfigSingleHost(), + getAgentConfigMismatchedInterfaceName(), + }, + expectedError: "invalid Hosts configuration: hosts[0].interfaces[0].name: Invalid value: \"enp3s0\": interface name \"enp3s0\" not found in networkConfig interfaces [eth0]; the interfaces[].name values are logical names that must match the interface names used in networkConfig so that the MAC-to-interface mapping works correctly at boot time", + expectedConfig: nil, + }, + { + name: "interface-name-matches-networkconfig", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, + &joiner.AddNodesConfig{}, + getInstallConfigSingleHost(), + getAgentConfigMatchingInterfaceName(), + }, + expectedConfig: agentHosts().hosts( + agentHost().name("test").role("master").interfaces(iface("eth0", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigOne)), + }, + { + name: "bond-networkconfig-with-matching-interfaces", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, + &joiner.AddNodesConfig{}, + getInstallConfigSingleHost(), + getAgentConfigBondMatching(), + }, + expectedConfig: agentHosts().hosts( + agentHost().name("test").role("master").interfaces(iface("eth0", "28:d2:44:d2:b2:1a"), iface("eth1", "28:d2:44:d2:b2:1b")).deviceHint().networkConfig(agentNetworkConfigBond)), + }, + { + name: "bond-networkconfig-with-mismatched-interfaces", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, + &joiner.AddNodesConfig{}, + getInstallConfigSingleHost(), + getAgentConfigBondMismatched(), + }, + expectedError: "invalid Hosts configuration: [hosts[0].interfaces[0].name: Invalid value: \"nic1\": interface name \"nic1\" not found in networkConfig interfaces [eth0, eth1, bond0]; the interfaces[].name values are logical names that must match the interface names used in networkConfig so that the MAC-to-interface mapping works correctly at boot time, hosts[0].interfaces[1].name: Invalid value: \"nic2\": interface name \"nic2\" not found in networkConfig interfaces [eth0, eth1, bond0]; the interfaces[].name values are logical names that must match the interface names used in networkConfig so that the MAC-to-interface mapping works correctly at boot time]", + expectedConfig: nil, }, } for _, tc := range cases { @@ -453,13 +521,14 @@ func getAgentConfigSingleHost() *AgentConfig { func getAgentConfigMultiHost(role string) *AgentConfig { a := getAgentConfigSingleHost() + a.Config.Hosts[0].Interfaces[0].Name = "eth0" a.Config.Hosts[0].NetworkConfig.Raw = []byte(agentNetworkConfigOne) host := agent.Host{ Hostname: "test-2", Role: role, Interfaces: []*aiv1beta1.Interface{ { - Name: "enp3s1", + Name: "eth0", MacAddress: "28:d2:44:d2:b2:1b", }, }, @@ -528,6 +597,26 @@ func getAgentConfigInvalidInterfaces() *AgentConfig { return a } +func getAgentConfigBondMatching() *AgentConfig { + a := getAgentConfigSingleHost() + a.Config.Hosts[0].Interfaces = []*aiv1beta1.Interface{ + {Name: "eth0", MacAddress: "28:d2:44:d2:b2:1a"}, + {Name: "eth1", MacAddress: "28:d2:44:d2:b2:1b"}, + } + a.Config.Hosts[0].NetworkConfig.Raw = unmarshalJSON([]byte(agentNetworkConfigBond)) + return a +} + +func getAgentConfigBondMismatched() *AgentConfig { + a := getAgentConfigSingleHost() + a.Config.Hosts[0].Interfaces = []*aiv1beta1.Interface{ + {Name: "nic1", MacAddress: "28:d2:44:d2:b2:1a"}, + {Name: "nic2", MacAddress: "28:d2:44:d2:b2:1b"}, + } + a.Config.Hosts[0].NetworkConfig.Raw = unmarshalJSON([]byte(agentNetworkConfigBond)) + return a +} + func getAgentConfigMissingInterfaces() *AgentConfig { a := getNoHostsAgentConfig() a.Config.Hosts = []agent.Host{ @@ -547,6 +636,20 @@ func getAgentConfigMissingInterfaces() *AgentConfig { return a } +func getAgentConfigMismatchedInterfaceName() *AgentConfig { + a := getAgentConfigSingleHost() + a.Config.Hosts[0].Interfaces[0].Name = "enp3s0" + a.Config.Hosts[0].NetworkConfig.Raw = []byte(agentNetworkConfigOne) + return a +} + +func getAgentConfigMatchingInterfaceName() *AgentConfig { + a := getAgentConfigSingleHost() + a.Config.Hosts[0].Interfaces[0].Name = "eth0" + a.Config.Hosts[0].NetworkConfig.Raw = []byte(agentNetworkConfigOne) + return a +} + func getAgentConfigInvalidRendezvousIP() *AgentConfig { a := getAgentConfigMultiHost("worker") a.Config.RendezvousIP = "192.168.111.81" From 94d155e4c6d8e90e7c2276df580330c04754aac3 Mon Sep 17 00:00:00 2001 From: Chin2691 Date: Thu, 4 Jun 2026 12:10:32 +0530 Subject: [PATCH 2/2] fix: change interface name validation to warning per reviewer feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses @zaneb's review: the interface name cross-check against networkConfig is now a warning (logrus.Warnf) instead of a hard error, and runs for both agent-config.yaml and nodes-config.yaml (oc adm node-image create) paths — but never for install-config baremetal hosts where getInstallConfigDefaults generates synthetic interface names. This ensures the baremetal IPI fallback path (which generates a bogus "boot" interface name) is never affected, while giving users early visibility into potential name mismatches that could cause connectivity failures at boot time. Test coverage added for: - install-config inert path (no warning fires) - AddNodes workflow mismatch (warns) and match (no warning) - empty interface name (skipped gracefully) - malformed networkConfig YAML (no panic) - bond interfaces matching and mismatching Ref: OCPBUGS-86420 Co-authored-by: Cursor --- pkg/asset/agent/agentconfig/agenthosts.go | 42 +++--- .../agent/agentconfig/agenthosts_test.go | 132 +++++++++++++++++- 2 files changed, 147 insertions(+), 27 deletions(-) diff --git a/pkg/asset/agent/agentconfig/agenthosts.go b/pkg/asset/agent/agentconfig/agenthosts.go index de765053f33..3b6343e7cbf 100644 --- a/pkg/asset/agent/agentconfig/agenthosts.go +++ b/pkg/asset/agent/agentconfig/agenthosts.go @@ -41,8 +41,9 @@ type nmStateInterface struct { // AgentHosts generates the hosts information from the AgentConfig and // OptionalInstallConfig assets. type AgentHosts struct { - Hosts []agent.Host - rendezvousIP string + Hosts []agent.Host + rendezvousIP string + hostsFromAgentConfig bool } // Name returns a human friendly name. @@ -74,7 +75,7 @@ func (a *AgentHosts) Generate(_ context.Context, dependencies asset.Parents) err a.rendezvousIP = agentConfig.Config.RendezvousIP a.Hosts = append(a.Hosts, agentConfig.Config.Hosts...) if len(a.Hosts) > 0 { - // Hosts defined in agent-config take precedence + a.hostsFromAgentConfig = true logrus.Debugf("Using hosts from %s", agentConfigFilename) } } @@ -92,6 +93,11 @@ func (a *AgentHosts) Generate(_ context.Context, dependencies asset.Parents) err case workflow.AgentWorkflowTypeAddNodes: a.Hosts = append(a.Hosts, addNodesConfig.Config.Hosts...) + if len(a.Hosts) > 0 { + // nodes-config.yaml hosts are user-authored like agent-config.yaml hosts, + // unlike install-config hosts which have code-generated interface names. + a.hostsFromAgentConfig = true + } default: return fmt.Errorf("AgentWorkflowType value not supported: %s", agentWorkflow.Workflow) @@ -125,9 +131,7 @@ func (a *AgentHosts) validateAgentHosts() field.ErrorList { allErrs = append(allErrs, err...) } - if err := a.validateInterfaceNamesMatchNetworkConfig(hostPath, host); err != nil { - allErrs = append(allErrs, err...) - } + a.warnInterfaceNamesNotInNetworkConfig(host) if err := a.validateHostRootDeviceHints(hostPath, host); err != nil { allErrs = append(allErrs, err...) @@ -175,14 +179,17 @@ func (a *AgentHosts) validateHostInterfaces(hostPath *field.Path, host agent.Hos return allErrs } -func (a *AgentHosts) validateInterfaceNamesMatchNetworkConfig(hostPath *field.Path, host agent.Host) field.ErrorList { +func (a *AgentHosts) warnInterfaceNamesNotInNetworkConfig(host agent.Host) { + if !a.hostsFromAgentConfig { + return + } if len(host.NetworkConfig.Raw) == 0 || len(host.Interfaces) == 0 { - return nil + return } var netInterfaces nmStateInterface if err := yaml.Unmarshal(host.NetworkConfig.Raw, &netInterfaces); err != nil { - return nil + return } ncNames := make(map[string]bool, len(netInterfaces.Interfaces)) @@ -194,26 +201,19 @@ func (a *AgentHosts) validateInterfaceNamesMatchNetworkConfig(hostPath *field.Pa } } if len(ncNames) == 0 { - return nil + return } - var allErrs field.ErrorList - for j, iface := range host.Interfaces { + for _, iface := range host.Interfaces { if iface.Name == "" { continue } if !ncNames[iface.Name] { - errMsg := "interface name \"" + iface.Name + "\" not found in networkConfig interfaces [" + strings.Join(ncNameList, ", ") + "]; " + - "the interfaces[].name values are logical names that must match the interface names used in networkConfig " + - "so that the MAC-to-interface mapping works correctly at boot time" - allErrs = append(allErrs, field.Invalid( - hostPath.Child("interfaces").Index(j).Child("name"), - iface.Name, - errMsg, - )) + logrus.Warnf("agent-config: interface name %q not found in networkConfig interfaces %v; "+ + "connectivity may fail if interface names do not match at boot time", + iface.Name, ncNameList) } } - return allErrs } func (a *AgentHosts) validateHostRootDeviceHints(hostPath *field.Path, host agent.Host) field.ErrorList { diff --git a/pkg/asset/agent/agentconfig/agenthosts_test.go b/pkg/asset/agent/agentconfig/agenthosts_test.go index c5b81c37b0a..36727af3926 100644 --- a/pkg/asset/agent/agentconfig/agenthosts_test.go +++ b/pkg/asset/agent/agentconfig/agenthosts_test.go @@ -369,15 +369,15 @@ func TestAgentHosts_Generate(t *testing.T) { agentHost().name("test-2").role("arbiter").interfaces(iface("eth0", "28:d2:44:d2:b2:1b")).networkConfig(agentNetworkConfigTwo)), }, { - name: "interface-name-mismatch-with-networkconfig", + name: "interface-name-mismatch-with-networkconfig-warns-only", dependencies: []asset.Asset{ &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, &joiner.AddNodesConfig{}, getInstallConfigSingleHost(), getAgentConfigMismatchedInterfaceName(), }, - expectedError: "invalid Hosts configuration: hosts[0].interfaces[0].name: Invalid value: \"enp3s0\": interface name \"enp3s0\" not found in networkConfig interfaces [eth0]; the interfaces[].name values are logical names that must match the interface names used in networkConfig so that the MAC-to-interface mapping works correctly at boot time", - expectedConfig: nil, + expectedConfig: agentHosts().hosts( + agentHost().name("test").role("master").interfaces(iface("enp3s0", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigOne)), }, { name: "interface-name-matches-networkconfig", @@ -402,15 +402,106 @@ func TestAgentHosts_Generate(t *testing.T) { agentHost().name("test").role("master").interfaces(iface("eth0", "28:d2:44:d2:b2:1a"), iface("eth1", "28:d2:44:d2:b2:1b")).deviceHint().networkConfig(agentNetworkConfigBond)), }, { - name: "bond-networkconfig-with-mismatched-interfaces", + name: "bond-networkconfig-with-mismatched-interfaces-warns-only", dependencies: []asset.Asset{ &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, &joiner.AddNodesConfig{}, getInstallConfigSingleHost(), getAgentConfigBondMismatched(), }, - expectedError: "invalid Hosts configuration: [hosts[0].interfaces[0].name: Invalid value: \"nic1\": interface name \"nic1\" not found in networkConfig interfaces [eth0, eth1, bond0]; the interfaces[].name values are logical names that must match the interface names used in networkConfig so that the MAC-to-interface mapping works correctly at boot time, hosts[0].interfaces[1].name: Invalid value: \"nic2\": interface name \"nic2\" not found in networkConfig interfaces [eth0, eth1, bond0]; the interfaces[].name values are logical names that must match the interface names used in networkConfig so that the MAC-to-interface mapping works correctly at boot time]", - expectedConfig: nil, + expectedConfig: agentHosts().hosts( + agentHost().name("test").role("master").interfaces(iface("nic1", "28:d2:44:d2:b2:1a"), iface("nic2", "28:d2:44:d2:b2:1b")).deviceHint().networkConfig(agentNetworkConfigBond)), + }, + { + name: "install-config-with-networkconfig-no-warning-inert-path", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, + &joiner.AddNodesConfig{}, + getInstallConfigWithMismatchedNetworkConfig(), + getNoHostsAgentConfig(), + }, + expectedConfig: agentHosts().hosts( + agentHost().name("test").role("master").interfaces(iface("eth0", "28:d2:44:b0:bf:01")).deviceHint().networkConfig(installNetworkConfigOne)), + }, + { + name: "add-nodes-interface-mismatch-warns-only", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeAddNodes}, + &joiner.AddNodesConfig{ + Config: joiner.Config{ + Hosts: []agent.Host{ + { + Hostname: "extra-worker-0", + Role: "worker", + Interfaces: []*aiv1beta1.Interface{ + { + Name: "nic0", + MacAddress: "28:d2:44:d2:b2:1a", + }, + }, + NetworkConfig: aiv1beta1.NetConfig{ + Raw: []byte(agentNetworkConfigOne), + }, + }, + }, + }, + }, + getNoHostsInstallConfig(), + getNoHostsAgentConfig(), + }, + expectedConfig: agentHosts().hosts( + agentHost().name("extra-worker-0").role("worker").interfaces(iface("nic0", "28:d2:44:d2:b2:1a")).networkConfig(agentNetworkConfigOne)), + }, + { + name: "add-nodes-interface-matches-no-warning", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeAddNodes}, + &joiner.AddNodesConfig{ + Config: joiner.Config{ + Hosts: []agent.Host{ + { + Hostname: "extra-worker-0", + Role: "worker", + Interfaces: []*aiv1beta1.Interface{ + { + Name: "eth0", + MacAddress: "28:d2:44:d2:b2:1a", + }, + }, + NetworkConfig: aiv1beta1.NetConfig{ + Raw: []byte(agentNetworkConfigOne), + }, + }, + }, + }, + }, + getNoHostsInstallConfig(), + getNoHostsAgentConfig(), + }, + expectedConfig: agentHosts().hosts( + agentHost().name("extra-worker-0").role("worker").interfaces(iface("eth0", "28:d2:44:d2:b2:1a")).networkConfig(agentNetworkConfigOne)), + }, + { + name: "agent-config-empty-interface-name-skipped", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, + &joiner.AddNodesConfig{}, + getInstallConfigSingleHost(), + getAgentConfigEmptyInterfaceName(), + }, + expectedConfig: agentHosts().hosts( + agentHost().name("test").role("master").interfaces(iface("", "28:d2:44:d2:b2:1a")).deviceHint().networkConfig(agentNetworkConfigOne)), + }, + { + name: "agent-config-malformed-networkconfig-no-panic", + dependencies: []asset.Asset{ + &workflow.AgentWorkflow{Workflow: workflow.AgentWorkflowTypeInstall}, + &joiner.AddNodesConfig{}, + getInstallConfigSingleHost(), + getAgentConfigMalformedNetworkConfig(), + }, + expectedConfig: agentHosts().hosts( + agentHost().name("test").role("master").interfaces(iface("eth0", "28:d2:44:d2:b2:1a")).deviceHint().rawNetworkConfig("not: valid: yaml: [[")), }, } for _, tc := range cases { @@ -831,6 +922,13 @@ func (hb *HostBuilder) networkConfig(raw string) *HostBuilder { return hb } +func (hb *HostBuilder) rawNetworkConfig(raw string) *HostBuilder { + hb.Host.NetworkConfig = aiv1beta1.NetConfig{ + Raw: []byte(raw), + } + return hb +} + func (hb *HostBuilder) deviceHint() *HostBuilder { hb.Host.RootDeviceHints = baremetal.RootDeviceHints{ DeviceName: "/dev/sda", @@ -856,3 +954,25 @@ func iface(name string, mac string) *InterfacetBuilder { func (ib *InterfacetBuilder) build() *aiv1beta1.Interface { return &ib.Interface } + +func getInstallConfigWithMismatchedNetworkConfig() *agentAsset.OptionalInstallConfig { + a := getInstallConfigSingleHost() + a.Config.Platform.BareMetal.Hosts[0].NetworkConfig = &apiextv1.JSON{ + Raw: []byte(installNetworkConfigOne), + } + return a +} + +func getAgentConfigEmptyInterfaceName() *AgentConfig { + a := getAgentConfigSingleHost() + a.Config.Hosts[0].Interfaces[0].Name = "" + a.Config.Hosts[0].NetworkConfig.Raw = []byte(agentNetworkConfigOne) + return a +} + +func getAgentConfigMalformedNetworkConfig() *AgentConfig { + a := getAgentConfigSingleHost() + a.Config.Hosts[0].Interfaces[0].Name = "eth0" + a.Config.Hosts[0].NetworkConfig.Raw = []byte("not: valid: yaml: [[") + return a +}