forked from gluster/glusterd2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mounting auto provisioned bricks on glusterd2 start
On `glusterd2` restart, it checks the list of auto provisioned bricks and mounts if not mounted already. Updates: gluster#851 Signed-off-by: Aravinda VK <avishwan@redhat.com>
- Loading branch information
1 parent
5bf8c09
commit 4f9dde7
Showing
9 changed files
with
160 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package utils | ||
|
||
import ( | ||
"github.com/gluster/glusterd2/glusterd2/volume" | ||
"github.com/gluster/glusterd2/pkg/utils" | ||
|
||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// MountLocalBricks mounts bricks of auto provisioned volumes | ||
func MountLocalBricks() error { | ||
volumes, err := volume.GetVolumes() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// TODO: Get Snapshot Volumes as well | ||
|
||
if len(volumes) == 0 { | ||
return nil | ||
} | ||
|
||
// Get list of mounted dirs | ||
mtabEntries, err := volume.GetMounts() | ||
if err != nil { | ||
log.WithError(err).Error("failed to get list of mounts") | ||
return err | ||
} | ||
|
||
mounts := make(map[string]struct{}) | ||
|
||
for _, entry := range mtabEntries { | ||
mounts[entry.MntDir] = struct{}{} | ||
} | ||
|
||
for _, v := range volumes { | ||
for _, b := range v.GetLocalBricks() { | ||
// Mount all local Bricks if they are auto provisioned | ||
if b.MountInfo.DevicePath != "" { | ||
if _, exists := mounts[b.MountInfo.Mountdir]; exists { | ||
continue | ||
} | ||
|
||
err := utils.ExecuteCommandRun("mount", "-o", b.MountInfo.MntOpts, b.MountInfo.DevicePath, b.MountInfo.Mountdir) | ||
if err != nil { | ||
log.WithFields(log.Fields{ | ||
"error": err, | ||
"volume": v.Name, | ||
"dev": b.MountInfo.DevicePath, | ||
"path": b.MountInfo.Mountdir, | ||
}).Error("brick mount failed") | ||
} | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.