Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3a2b9721
Commit
3a2b9721
authored
Jan 05, 2017
by
Huamin Chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #38362: create blob vhds container if not exists
Signed-off-by:
Huamin Chen
<
hchen@redhat.com
>
parent
307de207
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
azure_blob.go
pkg/cloudprovider/providers/azure/azure_blob.go
+12
-0
azure_storage.go
pkg/cloudprovider/providers/azure/azure_storage.go
+6
-3
No files found.
pkg/cloudprovider/providers/azure/azure_blob.go
View file @
3a2b9721
...
@@ -19,6 +19,7 @@ package azure
...
@@ -19,6 +19,7 @@ package azure
import
(
import
(
"fmt"
"fmt"
"regexp"
"regexp"
"strings"
azs
"github.com/Azure/azure-sdk-for-go/storage"
azs
"github.com/Azure/azure-sdk-for-go/storage"
)
)
...
@@ -41,8 +42,19 @@ func (az *Cloud) createVhdBlob(accountName, accountKey, name string, sizeGB int6
...
@@ -41,8 +42,19 @@ func (az *Cloud) createVhdBlob(accountName, accountKey, name string, sizeGB int6
name
=
name
+
".vhd"
name
=
name
+
".vhd"
err
=
blobClient
.
PutPageBlob
(
vhdContainerName
,
name
,
vhdSize
,
tags
)
err
=
blobClient
.
PutPageBlob
(
vhdContainerName
,
name
,
vhdSize
,
tags
)
if
err
!=
nil
{
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
)
return
""
,
""
,
fmt
.
Errorf
(
"failed to put page blob: %v"
,
err
)
}
}
// add VHD signature to the blob
// add VHD signature to the blob
h
,
err
:=
createVHDHeader
(
uint64
(
size
))
h
,
err
:=
createVHDHeader
(
uint64
(
size
))
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/cloudprovider/providers/azure/azure_storage.go
View file @
3a2b9721
...
@@ -28,7 +28,10 @@ import (
...
@@ -28,7 +28,10 @@ import (
)
)
const
(
const
(
maxLUN
=
64
// max number of LUNs per VM
maxLUN
=
64
// max number of LUNs per VM
errLeaseFailed
=
"AcquireDiskLeaseFailed"
errLeaseIDMissing
=
"LeaseIdMissing"
errContainerNotFound
=
"ContainerNotFound"
)
)
// AttachDisk attaches a vhd to vm
// AttachDisk attaches a vhd to vm
...
@@ -65,7 +68,7 @@ func (az *Cloud) AttachDisk(diskName, diskURI string, nodeName types.NodeName, l
...
@@ -65,7 +68,7 @@ func (az *Cloud) AttachDisk(diskName, diskURI string, nodeName types.NodeName, l
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Errorf
(
"azure attach failed, err: %v"
,
err
)
glog
.
Errorf
(
"azure attach failed, err: %v"
,
err
)
detail
:=
err
.
Error
()
detail
:=
err
.
Error
()
if
strings
.
Contains
(
detail
,
"Code=
\"
AcquireDiskLeaseFailed
\"
"
)
{
if
strings
.
Contains
(
detail
,
errLeaseFailed
)
{
// if lease cannot be acquired, immediately detach the disk and return the original error
// if lease cannot be acquired, immediately detach the disk and return the original error
glog
.
Infof
(
"failed to acquire disk lease, try detach"
)
glog
.
Infof
(
"failed to acquire disk lease, try detach"
)
az
.
DetachDiskByName
(
diskName
,
diskURI
,
nodeName
)
az
.
DetachDiskByName
(
diskName
,
diskURI
,
nodeName
)
...
@@ -237,7 +240,7 @@ func (az *Cloud) DeleteVolume(name, uri string) error {
...
@@ -237,7 +240,7 @@ func (az *Cloud) DeleteVolume(name, uri string) error {
if
err
!=
nil
{
if
err
!=
nil
{
glog
.
Warningf
(
"failed to delete blob %s err: %v"
,
uri
,
err
)
glog
.
Warningf
(
"failed to delete blob %s err: %v"
,
uri
,
err
)
detail
:=
err
.
Error
()
detail
:=
err
.
Error
()
if
strings
.
Contains
(
detail
,
"LeaseIdMissing"
)
{
if
strings
.
Contains
(
detail
,
errLeaseIDMissing
)
{
// disk is still being used
// disk is still being used
// see https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.blob.protocol.bloberrorcodestrings.leaseidmissing.aspx
// see https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.blob.protocol.bloberrorcodestrings.leaseidmissing.aspx
return
volume
.
NewDeletedVolumeInUseError
(
fmt
.
Sprintf
(
"disk %q is still in use while being deleted"
,
name
))
return
volume
.
NewDeletedVolumeInUseError
(
fmt
.
Sprintf
(
"disk %q is still in use while being deleted"
,
name
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment