mirror of https://github.com/k3s-io/k3s
glusterfs: properly check gidMin and gidMax values from SC individually
Don't override explict out-of max-range configuration, but fail with an error message instead. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1402286 Signed-off-by: Michael Adam <obnox@redhat.com>pull/6/head
parent
63044c410e
commit
c84cba0440
|
@ -73,7 +73,12 @@ const (
|
|||
gciGlusterMountBinariesPath = "/sbin/mount.glusterfs"
|
||||
defaultGidMin = 2000
|
||||
defaultGidMax = math.MaxInt32
|
||||
absoluteGidMax = math.MaxInt32
|
||||
// absoluteGidMin/Max are currently the same as the
|
||||
// default values, but they play a different role and
|
||||
// could take a different value. Only thing we need is:
|
||||
// absGidMin <= defGidMin <= defGidMax <= absGidMax
|
||||
absoluteGidMin = 2000
|
||||
absoluteGidMax = math.MaxInt32
|
||||
)
|
||||
|
||||
func (plugin *glusterfsPlugin) Init(host volume.VolumeHost) error {
|
||||
|
@ -849,6 +854,9 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
|
|||
var cfg provisioningConfig
|
||||
var err error
|
||||
|
||||
cfg.gidMin = defaultGidMin
|
||||
cfg.gidMax = defaultGidMax
|
||||
|
||||
authEnabled := true
|
||||
for k, v := range params {
|
||||
switch dstrings.ToLower(k) {
|
||||
|
@ -873,12 +881,24 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("glusterfs: invalid value %q for volume plugin %s", k, glusterfsPluginName)
|
||||
}
|
||||
if parseGidMin < absoluteGidMin {
|
||||
return nil, fmt.Errorf("glusterfs: gidMin must be >= %v", absoluteGidMin)
|
||||
}
|
||||
if parseGidMin > absoluteGidMax {
|
||||
return nil, fmt.Errorf("glusterfs: gidMin must be <= %v", absoluteGidMax)
|
||||
}
|
||||
cfg.gidMin = parseGidMin
|
||||
case "gidmax":
|
||||
parseGidMax, err := convertGid(v)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("glusterfs: invalid value %q for volume plugin %s", k, glusterfsPluginName)
|
||||
}
|
||||
if parseGidMax < absoluteGidMin {
|
||||
return nil, fmt.Errorf("glusterfs: gidMax must be >= %v", absoluteGidMin)
|
||||
}
|
||||
if parseGidMax > absoluteGidMax {
|
||||
return nil, fmt.Errorf("glusterfs: gidMax must be <= %v", absoluteGidMax)
|
||||
}
|
||||
cfg.gidMax = parseGidMax
|
||||
default:
|
||||
return nil, fmt.Errorf("glusterfs: invalid option %q for volume plugin %s", k, glusterfsPluginName)
|
||||
|
@ -911,14 +931,6 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
|
|||
cfg.secretValue = cfg.userKey
|
||||
}
|
||||
|
||||
if cfg.gidMin == 0 {
|
||||
cfg.gidMin = defaultGidMin
|
||||
}
|
||||
|
||||
if cfg.gidMax == 0 {
|
||||
cfg.gidMax = defaultGidMax
|
||||
}
|
||||
|
||||
if cfg.gidMin > cfg.gidMax {
|
||||
return nil, fmt.Errorf("StorageClass for provisioner %q must have gidMax value >= gidMin", glusterfsPluginName)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue