mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
fix #38362: create blob vhds container if not exists
Signed-off-by: Huamin Chen <hchen@redhat.com>
This commit is contained in:
@@ -19,6 +19,7 @@ package azure
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
azs "github.com/Azure/azure-sdk-for-go/storage"
|
||||
)
|
||||
@@ -40,9 +41,20 @@ func (az *Cloud) createVhdBlob(accountName, accountKey, name string, sizeGB int6
|
||||
// Blob name in URL must end with '.vhd' extension.
|
||||
name = name + ".vhd"
|
||||
err = blobClient.PutPageBlob(vhdContainerName, name, vhdSize, tags)
|
||||
if err != nil {
|
||||
// if container doesn't exist, create one and retry PutPageBlob
|
||||
detail := err.Error()
|
||||
if strings.Contains(detail, errContainerNotFound) {
|
||||
err = blobClient.CreateContainer(vhdContainerName, azs.ContainerAccessTypeContainer)
|
||||
if err == nil {
|
||||
err = blobClient.PutPageBlob(vhdContainerName, name, vhdSize, tags)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("failed to put page blob: %v", err)
|
||||
}
|
||||
|
||||
// add VHD signature to the blob
|
||||
h, err := createVHDHeader(uint64(size))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user