mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
fix azure pv crash due to readOnly nil
This commit is contained in:
parent
52d87de107
commit
9f2922c15a
@ -43,10 +43,14 @@ var _ volume.Unmounter = &azureDiskUnmounter{}
|
|||||||
var _ volume.Mounter = &azureDiskMounter{}
|
var _ volume.Mounter = &azureDiskMounter{}
|
||||||
|
|
||||||
func (m *azureDiskMounter) GetAttributes() volume.Attributes {
|
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{
|
return volume.Attributes{
|
||||||
ReadOnly: *volumeSource.ReadOnly,
|
ReadOnly: readOnly,
|
||||||
Managed: !*volumeSource.ReadOnly,
|
Managed: !readOnly,
|
||||||
SupportsSELinux: true,
|
SupportsSELinux: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,7 +98,7 @@ func (m *azureDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
|
|||||||
|
|
||||||
options := []string{"bind"}
|
options := []string{"bind"}
|
||||||
|
|
||||||
if *volumeSource.ReadOnly {
|
if volumeSource.ReadOnly != nil && *volumeSource.ReadOnly {
|
||||||
options = append(options, "ro")
|
options = append(options, "ro")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +142,7 @@ func (m *azureDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
|
|||||||
return mountErr
|
return mountErr
|
||||||
}
|
}
|
||||||
|
|
||||||
if !*volumeSource.ReadOnly {
|
if volumeSource.ReadOnly == nil || !*volumeSource.ReadOnly {
|
||||||
volume.SetVolumeOwnership(m, fsGroup)
|
volume.SetVolumeOwnership(m, fsGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user