Skip to content

Commit

Permalink
nfs-shares: skip snapmirror targets
Browse files Browse the repository at this point in the history
  • Loading branch information
majewsky committed Feb 27, 2020
1 parent 2496599 commit bcd59fa
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion internal/plugins/nfs-shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ func (m *assetManagerNFS) ListAssets(res db.Resource) ([]string, error) {

var data struct {
Shares []struct {
ID string `json:"id"`
ID string `json:"id"`
Metadata map[string]interface{} `json:"metadata"`
} `json:"shares"`
}
err = r.ExtractInto(&data)
Expand All @@ -114,6 +115,9 @@ func (m *assetManagerNFS) ListAssets(res db.Resource) ([]string, error) {

if len(data.Shares) > 0 {
for _, share := range data.Shares {
if ignoreShare(share.Metadata) {
continue
}
if !wasSeen[share.ID] {
shareIDs = append(shareIDs, share.ID)
wasSeen[share.ID] = true
Expand All @@ -127,6 +131,17 @@ func (m *assetManagerNFS) ListAssets(res db.Resource) ([]string, error) {
}
}

func ignoreShare(metadata map[string]interface{}) {
//ignore "shares" that are actually snapmirror targets (sapcc-specific extension)
if snapmirrorStr, ok := metadata["snapmirror"].(string); ok {
if snapmirrorStr == "1" {
return true
}
}

return false
}

var sizeInconsistencyErrorRx = regexp.MustCompile(`New size for (?:extend must be greater|shrink must be less) than current size`)
var quotaErrorRx = regexp.MustCompile(`Requested share exceeds allowed project/user or share type \S+ quota.`)

Expand Down

0 comments on commit bcd59fa

Please sign in to comment.