mirror of
https://github.com/openshift/installer.git
synced 2026-02-05 06:46:36 +01:00
This PR improves cross-platform compatibility. It solves two main issues: 1. inconsistent line endings 2. inconsistent path separators Path separators, in installer, needs to target two different environments: 1. the OS where the installer runs 2. the OS where the injected files been used This PR unified path separators used in 2 to be UNIX path separators, while in 1 to be platform-dependant. Ref: https://forum.golangbridge.org/t/filepath-join-or-path-join/13479 Known issues: The spawn processes, including etcd.exe, kube-apiserver.exe, and openshift-installer.exe, will not exit once installation aborted or completed. Users need to manually terminate those processes in task manager.
79 lines
2.1 KiB
Go
79 lines
2.1 KiB
Go
package manifests
|
|
|
|
import (
|
|
"path"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/openshift/installer/pkg/asset"
|
|
"github.com/openshift/installer/pkg/types"
|
|
"github.com/openshift/installer/pkg/types/aws"
|
|
"github.com/openshift/installer/pkg/types/gcp"
|
|
)
|
|
|
|
func generateMCOManifest(installConfig *types.InstallConfig, template []*asset.File) []*asset.File {
|
|
_, customWImg := customBootImages(installConfig)
|
|
|
|
// If there are no custom images, skip creating the manifest
|
|
// to defer to the MCO's default behavior.
|
|
if !customWImg {
|
|
return nil
|
|
}
|
|
|
|
tmplData := mcoTemplateData{DisableMachinesetBootMgmt: customWImg}
|
|
|
|
mcoCfg := applyTemplateData(template[0].Data, tmplData)
|
|
return []*asset.File{
|
|
{
|
|
Filename: path.Join(manifestDir, strings.TrimSuffix(filepath.Base(template[0].Filename), ".template")),
|
|
Data: mcoCfg,
|
|
},
|
|
}
|
|
}
|
|
|
|
func customBootImages(ic *types.InstallConfig) (customCPImg, customWImg bool) {
|
|
switch ic.Platform.Name() {
|
|
case aws.Name:
|
|
customCPImg, customWImg = awsBootImages(ic)
|
|
case gcp.Name:
|
|
customCPImg, customWImg = gcpBootImages(ic)
|
|
default:
|
|
// We do not need to consider other platforms, because default boot image management has not been enabled yet.
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func awsBootImages(ic *types.InstallConfig) (cpImg bool, wImg bool) {
|
|
if dmp := ic.AWS.DefaultMachinePlatform; dmp != nil && dmp.AMIID != "" {
|
|
return true, true
|
|
}
|
|
|
|
if cp := ic.ControlPlane; cp != nil && cp.Platform.AWS != nil && cp.Platform.AWS.AMIID != "" {
|
|
cpImg = true
|
|
}
|
|
|
|
// On AWS, we need to check both compute and edge compute machine pool.
|
|
for _, computeMP := range ic.Compute {
|
|
if awsPlatform := computeMP.Platform.AWS; awsPlatform != nil && awsPlatform.AMIID != "" {
|
|
wImg = true
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func gcpBootImages(ic *types.InstallConfig) (cpImg bool, wImg bool) {
|
|
if dmp := ic.GCP.DefaultMachinePlatform; dmp != nil && dmp.OSImage != nil {
|
|
return true, true
|
|
}
|
|
|
|
if cp := ic.ControlPlane; cp != nil && cp.Platform.GCP != nil && cp.Platform.GCP.OSImage != nil {
|
|
cpImg = true
|
|
}
|
|
|
|
if w := ic.Compute; len(w) > 0 && w[0].Platform.GCP != nil && w[0].Platform.GCP.OSImage != nil {
|
|
wImg = true
|
|
}
|
|
return
|
|
}
|