Skip to content

Commit b53042d

Browse files
committed
Azure: create ignition stub
Patch from Patrick Dillon <[email protected]> (cherry picked from commit dc515d6a86f7f0d6d7ba4c35b0ab64b0e307c3a7)
1 parent 55f73e2 commit b53042d

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

pkg/infrastructure/azure/azure.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
capz "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
2222
"sigs.k8s.io/controller-runtime/pkg/client"
2323

24+
"github.com/openshift/installer/pkg/asset/ignition/bootstrap"
2425
"github.com/openshift/installer/pkg/asset/manifests/capiutils"
2526
"github.com/openshift/installer/pkg/infrastructure/clusterapi"
2627
"github.com/openshift/installer/pkg/rhcos"
@@ -508,7 +509,7 @@ func (p Provider) Ignition(ctx context.Context, in clusterapi.IgnitionInput) ([]
508509
blobIgnitionContainer := createBlobContainerOutput.BlobContainer
509510
logrus.Debugf("BlobIgnitionContainer.ID=%s", *blobIgnitionContainer.ID)
510511

511-
_, err = CreateBlockBlob(ctx, &CreateBlockBlobInput{
512+
sasURL, err := CreateBlockBlob(ctx, &CreateBlockBlobInput{
512513
StorageURL: p.StorageURL,
513514
BlobURL: blobURL,
514515
StorageAccountName: p.StorageAccountName,
@@ -519,8 +520,10 @@ func (p Provider) Ignition(ctx context.Context, in clusterapi.IgnitionInput) ([]
519520
if err != nil {
520521
return nil, err
521522
}
523+
ignShim, err := bootstrap.GenerateIgnitionShimWithCertBundleAndProxy(sasURL, in.InstallConfig.Config.AdditionalTrustBundle, in.InstallConfig.Config.Proxy)
524+
if err != nil {
525+
return nil, fmt.Errorf("failed to create ignition shim: %w", err)
526+
}
522527

523-
// XXX access it as SAS
524-
525-
return []byte{}, nil
528+
return ignShim, nil
526529
}

pkg/infrastructure/azure/bootstrap.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

pkg/infrastructure/azure/storage.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"fmt"
77
"sync"
8+
"time"
89

910
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
1011
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
@@ -17,6 +18,7 @@ import (
1718
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blob"
1819
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/blockblob"
1920
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/pageblob"
21+
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/sas"
2022
"github.com/sirupsen/logrus"
2123

2224
aztypes "github.com/openshift/installer/pkg/types/azure"
@@ -190,7 +192,7 @@ func CreatePageBlob(ctx context.Context, in *CreatePageBlobInput) (*CreatePageBl
190192
// XXX: Should try all of them until one is successful
191193
sharedKeyCredential, err := azblob.NewSharedKeyCredential(in.StorageAccountName, *in.StorageAccountKeys[0].Value)
192194
if err != nil {
193-
return nil, fmt.Errorf("failed to get shared crdentials for storage account: %w", err)
195+
return nil, fmt.Errorf("failed to get shared credentials for storage account: %w", err)
194196
}
195197

196198
logrus.Debugf("Getting page blob client")
@@ -326,11 +328,9 @@ func doUploadPagesFromURL(ctx context.Context, pageBlobClient *pageblob.Client,
326328
// CreateBlockBlobInput containers the input parameters used for creating a
327329
// block blob.
328330
type CreateBlockBlobInput struct {
329-
StorageURL string
330-
BlobURL string
331-
//ImageURL string
331+
StorageURL string
332+
BlobURL string
332333
StorageAccountName string
333-
//ImageLength int64
334334
BootstrapIgnData []byte
335335
StorageAccountKeys []armstorage.AccountKey
336336
CloudConfiguration cloud.Configuration
@@ -344,13 +344,13 @@ type CreateBlockBlobOutput struct {
344344
}
345345

346346
// CreateBlockBlob creates a block blob and uploads a file from a URL to it.
347-
func CreateBlockBlob(ctx context.Context, in *CreateBlockBlobInput) (*CreateBlockBlobOutput, error) {
347+
func CreateBlockBlob(ctx context.Context, in *CreateBlockBlobInput) (string, error) {
348348
logrus.Debugf("Getting block blob credentials")
349349

350350
// XXX: Should try all of them until one is successful
351351
sharedKeyCredential, err := azblob.NewSharedKeyCredential(in.StorageAccountName, *in.StorageAccountKeys[0].Value)
352352
if err != nil {
353-
return nil, fmt.Errorf("failed to get shared crdentials for storage account: %w", err)
353+
return "", fmt.Errorf("failed to get shared crdentials for storage account: %w", err)
354354
}
355355

356356
logrus.Debugf("Getting block blob client")
@@ -364,7 +364,7 @@ func CreateBlockBlob(ctx context.Context, in *CreateBlockBlobInput) (*CreateBloc
364364
},
365365
)
366366
if err != nil {
367-
return nil, fmt.Errorf("failed to get page blob client: %w", err)
367+
return "", fmt.Errorf("failed to get page blob client: %w", err)
368368
}
369369

370370
logrus.Debugf("Creating block blob")
@@ -374,9 +374,13 @@ func CreateBlockBlob(ctx context.Context, in *CreateBlockBlobInput) (*CreateBloc
374374
Tier: &accessTier,
375375
})
376376
if err != nil {
377-
return nil, fmt.Errorf("failed to create block blob: %w", err)
377+
return "", fmt.Errorf("failed to create block blob: %w", err)
378+
}
379+
380+
sasURL, err := blockBlobClient.GetSASURL(sas.BlobPermissions{Read: true}, time.Now().Add(time.Minute*60), &blob.GetSASURLOptions{})
381+
if err != nil {
382+
return "", fmt.Errorf("failed to get SAS URL: %w", err)
378383
}
379384

380-
// XXX what more to do here?
381-
return nil, nil
385+
return sasURL, nil
382386
}

0 commit comments

Comments
 (0)