Skip to content

Commit ac9b6e1

Browse files
flavianmissiopenshift-cherrypick-robot
authored andcommitted
azurepathfix: skip job creation on Azure Stack Hub
ASH does not support the api version used by the sdk version in move-blobs, so we skip running it there. also consistently use the client options on every instantiation.
1 parent fb6c7a7 commit ac9b6e1

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

cmd/move-blobs/main.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,16 @@ func getClient(cloudConfig cloud.Configuration, opts *configOpts) (*container.Cl
299299
opts.containerName,
300300
)
301301
var client *container.Client
302+
clientOpts := azcore.ClientOptions{
303+
Cloud: cloudConfig,
304+
}
305+
302306
if len(opts.accountKey) > 0 {
303307
cred, err := container.NewSharedKeyCredential(opts.storageAccountName, opts.accountKey)
304308
if err != nil {
305309
return nil, err
306310
}
307-
client, err = container.NewClientWithSharedKeyCredential(containerURL, cred, nil)
311+
client, err = container.NewClientWithSharedKeyCredential(containerURL, cred, &container.ClientOptions{ClientOptions: clientOpts})
308312
if err != nil {
309313
return nil, err
310314
}
@@ -318,7 +322,7 @@ func getClient(cloudConfig cloud.Configuration, opts *configOpts) (*container.Cl
318322
if err != nil {
319323
return nil, err
320324
}
321-
client, err = container.NewClient(containerURL, cred, nil)
325+
client, err = container.NewClient(containerURL, cred, &container.ClientOptions{ClientOptions: clientOpts})
322326
if err != nil {
323327
return nil, err
324328
}
@@ -335,16 +339,21 @@ func getClient(cloudConfig cloud.Configuration, opts *configOpts) (*container.Cl
335339
if err != nil {
336340
return nil, err
337341
}
338-
client, err = container.NewClient(containerURL, cred, nil)
342+
client, err = container.NewClient(containerURL, cred, &container.ClientOptions{ClientOptions: clientOpts})
339343
if err != nil {
340344
return nil, err
341345
}
342346
} else {
343-
cred, err := azidentity.NewDefaultAzureCredential(nil)
347+
options := azidentity.DefaultAzureCredentialOptions{
348+
ClientOptions: azcore.ClientOptions{
349+
Cloud: cloudConfig,
350+
},
351+
}
352+
cred, err := azidentity.NewDefaultAzureCredential(&options)
344353
if err != nil {
345354
return nil, err
346355
}
347-
client, err = container.NewClient(containerURL, cred, nil)
356+
client, err = container.NewClient(containerURL, cred, &container.ClientOptions{ClientOptions: clientOpts})
348357
if err != nil {
349358
return nil, err
350359
}

pkg/operator/azurepathfixcontroller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package operator
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"time"
78

89
batchv1 "k8s.io/api/batch/v1"
@@ -176,6 +177,7 @@ func (c *AzurePathFixController) sync() error {
176177
if err != nil {
177178
return err
178179
}
180+
179181
azureStorage := imageRegistryConfig.Status.Storage.Azure
180182
if azureStorage == nil || len(azureStorage.AccountName) == 0 {
181183
return fmt.Errorf("storage account not yet provisioned")
@@ -184,6 +186,12 @@ func (c *AzurePathFixController) sync() error {
184186
return fmt.Errorf("storage container not yet provisioned")
185187
}
186188

189+
// the move-blobs cmd does not work on Azure Stack Hub. Users on ASH
190+
// will have to copy the blobs on their own using something like az copy.
191+
if strings.EqualFold(azureStorage.CloudName, "AZURESTACKCLOUD") {
192+
return nil
193+
}
194+
187195
gen := resource.NewGeneratorAzurePathFixJob(
188196
c.jobLister,
189197
c.batchClient,

0 commit comments

Comments
 (0)