Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
92167b5b
Commit
92167b5b
authored
Dec 02, 2016
by
Humble Chirammal
Committed by
Michael Adam
Dec 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
glusterfs: teach provisioner to extract gid-range from storage class
parent
11a5e84a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletion
+48
-1
glusterfs.go
pkg/volume/glusterfs/glusterfs.go
+41
-0
glusterfs_test.go
pkg/volume/glusterfs/glusterfs_test.go
+7
-1
No files found.
pkg/volume/glusterfs/glusterfs.go
View file @
92167b5b
...
@@ -18,9 +18,11 @@ package glusterfs
...
@@ -18,9 +18,11 @@ package glusterfs
import
(
import
(
"fmt"
"fmt"
"math"
"os"
"os"
"path"
"path"
"runtime"
"runtime"
"strconv"
dstrings
"strings"
dstrings
"strings"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -63,6 +65,8 @@ const (
...
@@ -63,6 +65,8 @@ const (
durabilityType
=
"replicate"
durabilityType
=
"replicate"
secretKeyName
=
"key"
// key name used in secret
secretKeyName
=
"key"
// key name used in secret
gciGlusterMountBinariesPath
=
"/sbin/mount.glusterfs"
gciGlusterMountBinariesPath
=
"/sbin/mount.glusterfs"
defaultGidMin
=
2000
defaultGidMax
=
math
.
MaxUint32
)
)
func
(
plugin
*
glusterfsPlugin
)
Init
(
host
volume
.
VolumeHost
)
error
{
func
(
plugin
*
glusterfsPlugin
)
Init
(
host
volume
.
VolumeHost
)
error
{
...
@@ -381,6 +385,8 @@ type provisioningConfig struct {
...
@@ -381,6 +385,8 @@ type provisioningConfig struct {
secretName
string
secretName
string
secretValue
string
secretValue
string
clusterId
string
clusterId
string
gidMin
uint32
gidMax
uint32
}
}
type
glusterfsVolumeProvisioner
struct
{
type
glusterfsVolumeProvisioner
struct
{
...
@@ -389,6 +395,16 @@ type glusterfsVolumeProvisioner struct {
...
@@ -389,6 +395,16 @@ type glusterfsVolumeProvisioner struct {
options
volume
.
VolumeOptions
options
volume
.
VolumeOptions
}
}
func
convertGid
(
inputGid
string
)
(
uint32
,
error
)
{
inputGid32
,
err
:=
strconv
.
ParseUint
(
inputGid
,
10
,
32
);
if
err
!=
nil
{
glog
.
Errorf
(
"glusterfs: failed to parse gid %v "
,
inputGid
)
return
0
,
fmt
.
Errorf
(
"glusterfs: failed to parse gid %v "
,
inputGid
)
}
outputGid
:=
uint32
(
inputGid32
)
return
outputGid
,
nil
}
func
(
plugin
*
glusterfsPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
func
(
plugin
*
glusterfsPlugin
)
NewDeleter
(
spec
*
volume
.
Spec
)
(
volume
.
Deleter
,
error
)
{
return
plugin
.
newDeleterInternal
(
spec
)
return
plugin
.
newDeleterInternal
(
spec
)
}
}
...
@@ -681,6 +697,18 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
...
@@ -681,6 +697,18 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
cfg
.
clusterId
=
v
cfg
.
clusterId
=
v
case
"restauthenabled"
:
case
"restauthenabled"
:
authEnabled
=
dstrings
.
ToLower
(
v
)
==
"true"
authEnabled
=
dstrings
.
ToLower
(
v
)
==
"true"
case
"gidmin"
:
parseGidMin
,
err
:=
convertGid
(
v
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"glusterfs: invalid value %q for volume plugin %s"
,
k
,
glusterfsPluginName
)
}
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
)
}
cfg
.
gidMax
=
parseGidMax
default
:
default
:
return
nil
,
fmt
.
Errorf
(
"glusterfs: invalid option %q for volume plugin %s"
,
k
,
glusterfsPluginName
)
return
nil
,
fmt
.
Errorf
(
"glusterfs: invalid option %q for volume plugin %s"
,
k
,
glusterfsPluginName
)
}
}
...
@@ -711,5 +739,18 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
...
@@ -711,5 +739,18 @@ func parseClassParameters(params map[string]string, kubeClient clientset.Interfa
}
else
{
}
else
{
cfg
.
secretValue
=
cfg
.
userKey
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
)
}
return
&
cfg
,
nil
return
&
cfg
,
nil
}
}
pkg/volume/glusterfs/glusterfs_test.go
View file @
92167b5b
...
@@ -269,6 +269,8 @@ func TestParseClassParameters(t *testing.T) {
...
@@ -269,6 +269,8 @@ func TestParseClassParameters(t *testing.T) {
user
:
"admin"
,
user
:
"admin"
,
userKey
:
"password"
,
userKey
:
"password"
,
secretValue
:
"password"
,
secretValue
:
"password"
,
gidMin
:
2000
,
gidMax
:
4294967295
,
},
},
},
},
{
{
...
@@ -287,6 +289,8 @@ func TestParseClassParameters(t *testing.T) {
...
@@ -287,6 +289,8 @@ func TestParseClassParameters(t *testing.T) {
secretName
:
"mysecret"
,
secretName
:
"mysecret"
,
secretNamespace
:
"default"
,
secretNamespace
:
"default"
,
secretValue
:
"mypassword"
,
secretValue
:
"mypassword"
,
gidMin
:
2000
,
gidMax
:
4294967295
,
},
},
},
},
{
{
...
@@ -298,7 +302,9 @@ func TestParseClassParameters(t *testing.T) {
...
@@ -298,7 +302,9 @@ func TestParseClassParameters(t *testing.T) {
&
secret
,
&
secret
,
false
,
// expect error
false
,
// expect error
&
provisioningConfig
{
&
provisioningConfig
{
url
:
"https://localhost:8080"
,
url
:
"https://localhost:8080"
,
gidMin
:
2000
,
gidMax
:
4294967295
,
},
},
},
},
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment