Skip to content

Commit 90e29fe

Browse files
committed
FIX: fix labels if the user requests on volumes
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1475768 Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent 05f3cfb commit 90e29fe

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

volume/volume.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,19 @@ type MountPoint struct {
106106

107107
// Setup sets up a mount point by either mounting the volume if it is
108108
// configured, or creating the source directory if supplied.
109-
func (m *MountPoint) Setup(mountLabel string) (string, error) {
109+
func (m *MountPoint) Setup(mountLabel string) (path string, err error) {
110+
defer func() {
111+
if err == nil {
112+
if label.RelabelNeeded(m.Mode) {
113+
if err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)); err != nil {
114+
path = ""
115+
err = fmt.Errorf("error setting label on mount source '%s': %v", m.Source, err)
116+
return
117+
}
118+
}
119+
}
120+
return
121+
}()
110122
if m.Volume != nil {
111123
if m.ID == "" {
112124
m.ID = stringid.GenerateNonCryptoID()
@@ -124,11 +136,6 @@ func (m *MountPoint) Setup(mountLabel string) (string, error) {
124136
}
125137
}
126138
}
127-
if label.RelabelNeeded(m.Mode) {
128-
if err := label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)); err != nil {
129-
return "", err
130-
}
131-
}
132139
return m.Source, nil
133140
}
134141

0 commit comments

Comments
 (0)