Skip to content

Commit

Permalink
chore(validations): add check for BD tag presence (#147)
Browse files Browse the repository at this point in the history
BD can be tagged in order to reserve it to be used later or by other storage
engine. If a tag is found in BD then it should not be used by cstor. This commit
adds a check for this. If a tag is found in BD and is used in CSPC for cStor
pool provisioning then the cStor webhook server will reject the request.

Signed-off-by: Ashutosh Kumar <[email protected]>
  • Loading branch information
Ashutosh Kumar authored Aug 6, 2020
1 parent dd9e47b commit d9023cb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/imdario/mergo v0.3.8 // indirect
github.com/onsi/ginkgo v1.12.0
github.com/onsi/gomega v1.9.0
github.com/openebs/api v1.12.1-0.20200729172328-4b0764aeaaf6
github.com/openebs/api v1.12.1-0.20200805040335-b9bd4809e80c
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ github.com/opencontainers/runtime-spec v1.0.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/
github.com/opencontainers/selinux v1.3.1-0.20190929122143-5215b1806f52/go.mod h1:+BLncwf63G4dgOzykXAxcmnFlUaOlkDdmw/CqsW6pjs=
github.com/openebs/api v1.12.1-0.20200729172328-4b0764aeaaf6 h1:3r1ByPvaWBJpLhGsJT67uNfxSV1/JfqWsr2Ca+zg2fQ=
github.com/openebs/api v1.12.1-0.20200729172328-4b0764aeaaf6/go.mod h1:TASujm6H1LGdx43MN7Dab1xdAqR7MVU8bsS74Ywop5w=
github.com/openebs/api v1.12.1-0.20200805040335-b9bd4809e80c h1:fZmO/A7BnxFAg9y1gjhtN6IG1ZBj0e0bLJTQtOI1Tk4=
github.com/openebs/api v1.12.1-0.20200805040335-b9bd4809e80c/go.mod h1:TASujm6H1LGdx43MN7Dab1xdAqR7MVU8bsS74Ywop5w=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.1.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
Expand Down
9 changes: 9 additions & 0 deletions pkg/webhook/cspc.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,15 @@ func validateBlockDevice(bd *openebsapis.BlockDevice, hostName string) error {
bd.Labels[types.HostNameLabelKey],
)
}

if v, found := bd.Labels[types.BlockDeviceTagLabelKey]; found {
return errors.Errorf(
"block device %s is tagged with a value %s and cannot be used",
bd.Name,
v,
)
}

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions vendor/github.com/openebs/api/pkg/apis/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ github.com/onsi/gomega/matchers/support/goraph/edge
github.com/onsi/gomega/matchers/support/goraph/node
github.com/onsi/gomega/matchers/support/goraph/util
github.com/onsi/gomega/types
# github.com/openebs/api v1.12.1-0.20200729172328-4b0764aeaaf6
# github.com/openebs/api v1.12.1-0.20200805040335-b9bd4809e80c
github.com/openebs/api/pkg/apis/cstor
github.com/openebs/api/pkg/apis/cstor/v1
github.com/openebs/api/pkg/apis/openebs.io
Expand Down

0 comments on commit d9023cb

Please sign in to comment.