Refactor MountPoint Setup function in volume.go
| ... | ... |
@@ -153,20 +153,18 @@ func (m *MountPoint) Cleanup() error {
|
| 153 | 153 |
// before creating the source directory on the host. |
| 154 | 154 |
func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.IDPair, checkFun func(m *MountPoint) error) (path string, err error) {
|
| 155 | 155 |
defer func() {
|
| 156 |
- if err == nil {
|
|
| 157 |
- if label.RelabelNeeded(m.Mode) {
|
|
| 158 |
- if err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)); err != nil {
|
|
| 159 |
- if err == syscall.ENOTSUP {
|
|
| 160 |
- err = nil |
|
| 161 |
- return |
|
| 162 |
- } |
|
| 163 |
- path = "" |
|
| 164 |
- err = errors.Wrapf(err, "error setting label on mount source '%s'", m.Source) |
|
| 165 |
- return |
|
| 166 |
- } |
|
| 167 |
- } |
|
| 156 |
+ if err != nil || !label.RelabelNeeded(m.Mode) {
|
|
| 157 |
+ return |
|
| 158 |
+ } |
|
| 159 |
+ |
|
| 160 |
+ err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)) |
|
| 161 |
+ if err == syscall.ENOTSUP {
|
|
| 162 |
+ err = nil |
|
| 163 |
+ } |
|
| 164 |
+ if err != nil {
|
|
| 165 |
+ path = "" |
|
| 166 |
+ err = errors.Wrapf(err, "error setting label on mount source '%s'", m.Source) |
|
| 168 | 167 |
} |
| 169 |
- return |
|
| 170 | 168 |
}() |
| 171 | 169 |
|
| 172 | 170 |
if m.Volume != nil {
|