From bcd59fad00dfde521123dfb2f3d00628d6b72a49 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Thu, 27 Feb 2020 14:07:30 +0100 Subject: [PATCH] nfs-shares: skip snapmirror targets --- internal/plugins/nfs-shares.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/plugins/nfs-shares.go b/internal/plugins/nfs-shares.go index da6cff2c..c61f8b5c 100644 --- a/internal/plugins/nfs-shares.go +++ b/internal/plugins/nfs-shares.go @@ -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) @@ -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 @@ -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.`)