Skip to content

Commit

Permalink
Merge pull request #54679 from andyzhangx/automated-cherry-pick-of-#5…
Browse files Browse the repository at this point in the history
…4607-upstream-release-1.8

Automatic merge from submit-queue.

Automated cherry pick of #54607

Cherry pick of #54607 on release-1.8.

#54607: fix azure pv crash due to readOnly nil
  • Loading branch information
Kubernetes Submit Queue committed Oct 30, 2017
2 parents fdbe902 + 5e0f65a commit 4421817
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/volume/azure_dd/azure_mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ var _ volume.Unmounter = &azureDiskUnmounter{}
var _ volume.Mounter = &azureDiskMounter{}

func (m *azureDiskMounter) GetAttributes() volume.Attributes {
volumeSource, _ := getVolumeSource(m.spec)
readOnly := false
volumeSource, err := getVolumeSource(m.spec)
if err != nil && volumeSource.ReadOnly != nil {
readOnly = *volumeSource.ReadOnly
}
return volume.Attributes{
ReadOnly: *volumeSource.ReadOnly,
Managed: !*volumeSource.ReadOnly,
ReadOnly: readOnly,
Managed: !readOnly,
SupportsSELinux: true,
}
}
Expand Down Expand Up @@ -94,7 +98,7 @@ func (m *azureDiskMounter) SetUpAt(dir string, fsGroup *int64) error {

options := []string{"bind"}

if *volumeSource.ReadOnly {
if volumeSource.ReadOnly != nil && *volumeSource.ReadOnly {
options = append(options, "ro")
}

Expand Down Expand Up @@ -138,7 +142,7 @@ func (m *azureDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
return mountErr
}

if !*volumeSource.ReadOnly {
if volumeSource.ReadOnly == nil || !*volumeSource.ReadOnly {
volume.SetVolumeOwnership(m, fsGroup)
}

Expand Down

0 comments on commit 4421817

Please sign in to comment.