Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 27 additions & 19 deletions cmd/agentbasedinstaller/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,25 +165,33 @@ func RegisterInfraEnv(ctx context.Context, log *log.Logger, bmInventory *client.
clusterID = modelsCluster.ID
}
infraEnvParams := controllers.CreateInfraEnvParams(&infraEnv, models.ImageType(imageTypeISO), pullSecret, clusterID, "")

var nmStateConfig aiv1beta1.NMStateConfig

fileInfo, _ := os.Stat(nmStateConfigPath)
if fileInfo != nil {
if nmStateErr := getFileData(nmStateConfigPath, &nmStateConfig); nmStateErr != nil {
return nil, nmStateErr
}

staticNetworkConfig, processErr := processNMStateConfig(log, infraEnv, nmStateConfig)
if processErr != nil {
return nil, processErr
}

if len(staticNetworkConfig) > 0 {
log.Infof("Added %d nmstateconfigs", len(staticNetworkConfig))
infraEnvParams.InfraenvCreateParams.StaticNetworkConfig = staticNetworkConfig
}
}
// In ABI, the --copy-network flag should always be included in the installer args.
// The flag is added if the infraenv is found to have static networking configured.
// See https://github.com/openshift/assisted-service/blob/f026180842bb99cc97d5597fd1bfaa483a55828b/internal/host/hostcommands/install_cmd.go#L368
// Here we add a dummy static network config to force the --copy-network flag
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on our previous discussion, I think that a slightly safer implementation could be the check the presence of any keyfile in the live environment to conditionally decide to set the infraEnvParams.InfraenvCreateParams.StaticNetworkConfig: that should cover both the case when the user defines some static network configuration via install-config/agent-config file, either when it's just added via agent TUI (ignoring instead when it's not set all).

// to be added. The dummy network config is not applied to the hosts.
netYaml := `interfaces:
- ipv4:
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea of a dummy network config, but I'd expect something simpler or more "dummy", ie something like:

- routes:

Right now it's just evaluated later by AS (and in case of ABI never applied), but anyhow I'd prefer to have a really simple definition

address:
- ip: 192.0.2.1
prefix-length: 24
dhcp: false
enabled: true
name: dummy
state: up
type: ethernet`
dummyStaticNetworkConfig := []*models.HostStaticNetworkConfig{
{
NetworkYaml: netYaml,
MacInterfaceMap: []*models.MacInterfaceMapItems0{
{
LogicalNicName: "dummy",
MacAddress: "52:54:00:09:de:93",
},
},
},
}
infraEnvParams.InfraenvCreateParams.StaticNetworkConfig = dummyStaticNetworkConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

In general this solution may work from 4.21+, where we have in plan to enable the infraenv late binding. But I don't think it will work for 4.20, where currently the registerIfnraEnv step is ignored


clientInfraEnvParams := &installer.RegisterInfraEnvParams{
InfraenvCreateParams: infraEnvParams.InfraenvCreateParams,
Expand Down