mirror of
https://github.com/openshift/installer.git
synced 2026-02-05 15:47:14 +01:00
Merge pull request #9901 from openshift-cherrypick-robot/cherry-pick-9877-to-release-4.19
[release-4.19] OCPBUGS-60652: PowerVS: config variables not honored
This commit is contained in:
@@ -3,6 +3,7 @@ package powervs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
icpowervs "github.com/openshift/installer/pkg/asset/installconfig/powervs"
|
||||
"github.com/openshift/installer/pkg/types"
|
||||
@@ -11,8 +12,36 @@ import (
|
||||
|
||||
// Metadata converts an install configuration to PowerVS metadata.
|
||||
func Metadata(config *types.InstallConfig, meta *icpowervs.Metadata) (*powervs.Metadata, error) {
|
||||
cisCRN, _ := meta.CISInstanceCRN(context.TODO())
|
||||
dnsCRN, _ := meta.DNSInstanceCRN(context.TODO())
|
||||
var (
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
err error
|
||||
)
|
||||
|
||||
// Update the saved session storage with the install config since the session
|
||||
// storage is used as the defaults.
|
||||
err = icpowervs.UpdateSessionStoreToAuthFile(&icpowervs.SessionStore{
|
||||
ID: config.PowerVS.UserID,
|
||||
DefaultRegion: config.PowerVS.Region,
|
||||
DefaultZone: config.PowerVS.Zone,
|
||||
PowerVSResourceGroup: config.PowerVS.PowerVSResourceGroup,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx, cancel = context.WithTimeout(context.TODO(), 1*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
cisCRN, err := meta.CISInstanceCRN(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dnsCRN, err := meta.DNSInstanceCRN(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
overrides := config.Platform.PowerVS.ServiceEndpoints
|
||||
if config.Publish == types.InternalPublishingStrategy &&
|
||||
@@ -25,7 +54,7 @@ func Metadata(config *types.InstallConfig, meta *icpowervs.Metadata) (*powervs.M
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
overrides = meta.SetDefaultPrivateServiceEndpoints(context.TODO(), overrides, cosRegion, vpcRegion)
|
||||
overrides = meta.SetDefaultPrivateServiceEndpoints(ctx, overrides, cosRegion, vpcRegion)
|
||||
}
|
||||
|
||||
return &powervs.Metadata{
|
||||
|
||||
@@ -417,6 +417,41 @@ func saveSessionStoreToAuthFile(pss *SessionStore) error {
|
||||
return os.WriteFile(authFilePath, jsonVars, 0o600)
|
||||
}
|
||||
|
||||
// UpdateSessionStoreToAuthFile updates the saved session store structure on the disk.
|
||||
func UpdateSessionStoreToAuthFile(update *SessionStore) error {
|
||||
var (
|
||||
original SessionStore
|
||||
err error
|
||||
)
|
||||
|
||||
if update == nil {
|
||||
return fmt.Errorf("empty session store passed to UpdateSessionStoreToAuthFile")
|
||||
}
|
||||
|
||||
err = getSessionStoreFromAuthFile(&original)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if update.ID != "" {
|
||||
original.ID = update.ID
|
||||
}
|
||||
if update.APIKey != "" {
|
||||
original.APIKey = update.APIKey
|
||||
}
|
||||
if update.DefaultRegion != "" {
|
||||
original.DefaultRegion = update.DefaultRegion
|
||||
}
|
||||
if update.DefaultZone != "" {
|
||||
original.DefaultZone = update.DefaultZone
|
||||
}
|
||||
if update.PowerVSResourceGroup != "" {
|
||||
original.PowerVSResourceGroup = update.PowerVSResourceGroup
|
||||
}
|
||||
|
||||
return saveSessionStoreToAuthFile(&original)
|
||||
}
|
||||
|
||||
func getEnv(envs []string) string {
|
||||
for _, k := range envs {
|
||||
if v := os.Getenv(k); v != "" {
|
||||
|
||||
@@ -191,6 +191,19 @@ func defaultPowerVSMachinePoolPlatform(ic *types.InstallConfig) powervstypes.Mac
|
||||
err error
|
||||
)
|
||||
|
||||
// Update the saved session storage with the install config since the session
|
||||
// storage is used as the defaults.
|
||||
err = powervsconfig.UpdateSessionStoreToAuthFile(&powervsconfig.SessionStore{
|
||||
ID: ic.PowerVS.UserID,
|
||||
DefaultRegion: ic.PowerVS.Region,
|
||||
DefaultZone: ic.PowerVS.Zone,
|
||||
PowerVSResourceGroup: ic.PowerVS.PowerVSResourceGroup,
|
||||
})
|
||||
if err != nil {
|
||||
fallback = true
|
||||
logrus.Warnf("could not UpdateSessionStoreToAuthFile in defaultPowerVSMachinePoolPlatform")
|
||||
}
|
||||
|
||||
client, err = powervsconfig.NewClient()
|
||||
if err != nil {
|
||||
fallback = true
|
||||
|
||||
Reference in New Issue
Block a user