From e1d7d1c6c706d7622bb5ef9ddff99eb49746d0a6 Mon Sep 17 00:00:00 2001 From: Benny Zlotnik Date: Tue, 12 Sep 2023 12:01:26 +0300 Subject: [PATCH] openstack: do not use region when application credential is used Signed-off-by: Benny Zlotnik --- pkg/controller/provider/container/openstack/model.go | 9 +++++++++ pkg/lib/client/openstack/client.go | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/pkg/controller/provider/container/openstack/model.go b/pkg/controller/provider/container/openstack/model.go index 920ba18fd..4083db9dc 100644 --- a/pkg/controller/provider/container/openstack/model.go +++ b/pkg/controller/provider/container/openstack/model.go @@ -77,6 +77,10 @@ func (r *RegionAdapter) List(ctx *Context) (itr fb.Iterator, err error) { regionList := []libclient.Region{} region := &libclient.Region{} err = ctx.client.GetClientRegion(region) + if ctx.client.IsApplicationCredentialAuth() { + ctx.log.Info("Application credential auth, skipping region list") + return fb.NewList().Iter(), nil + } if err != nil { return } @@ -103,6 +107,11 @@ func (r *RegionAdapter) GetUpdates(ctx *Context) (updates []Updater, err error) regionList := []libclient.Region{} region := &libclient.Region{} err = ctx.client.GetClientRegion(region) + if ctx.client.IsApplicationCredentialAuth() { + ctx.log.Info("Application credential auth, skipping region update") + return []Updater{}, nil + } + if err != nil { return } diff --git a/pkg/lib/client/openstack/client.go b/pkg/lib/client/openstack/client.go index 1b903394d..2494bc029 100644 --- a/pkg/lib/client/openstack/client.go +++ b/pkg/lib/client/openstack/client.go @@ -72,6 +72,7 @@ type Client struct { URL string Options map[string]string Log logging.LevelLogger + authTypeValue *clientconfig.AuthType provider *gophercloud.ProviderClient identityService *gophercloud.ServiceClient computeService *gophercloud.ServiceClient @@ -80,6 +81,10 @@ type Client struct { blockStorageService *gophercloud.ServiceClient } +func (c *Client) IsApplicationCredentialAuth() bool { + return *c.authTypeValue == clientconfig.AuthV3ApplicationCredential +} + func (c *Client) LoadOptionsFromSecret(secret *core.Secret) { c.Options = make(map[string]string) for key, value := range secret.Data { @@ -216,6 +221,7 @@ func (c *Client) authType() (authType clientconfig.AuthType, err error) { } else { err = liberr.New("unsupported authentication type", "authType", configuredAuthType) } + c.authTypeValue = &authType return }