Skip to content

Commit 77d0125

Browse files
committed
remove FixedFSGroup support
Signed-off-by: Tim Ramlot <[email protected]>
1 parent fec20e4 commit 77d0125

File tree

2 files changed

+10
-51
lines changed

2 files changed

+10
-51
lines changed

storage/filesystem.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,10 @@ type Filesystem struct {
4949
// used by the 'read only' methods
5050
fs fs.StatFS
5151

52-
// FixedFSGroup is an optional field which will set the gid ownership of all
53-
// volume's data directories to this value.
54-
// If this value is set, FSGroupVolumeAttributeKey has no effect.
55-
FixedFSGroup *int64
56-
5752
// FSGroupVolumeAttributeKey is an optional well-known key in the volume
5853
// attributes. If this attribute is present in the context when writing
5954
// files, gid ownership of the volume's data directory will be changed to
6055
// the value. Attribute value must be a valid int64 value.
61-
// If FixedFSGroup is defined, this field has no effect.
6256
FSGroupVolumeAttributeKey string
6357
}
6458

@@ -328,11 +322,6 @@ func makePayload(in map[string][]byte) map[string]util.FileProjection {
328322
// directory should be changed to. Returns nil if ownership should not be
329323
// changed.
330324
func (f *Filesystem) fsGroupForMetadata(meta metadata.Metadata) (*int64, error) {
331-
// FixedFSGroup takes precedence over attribute key.
332-
if f.FixedFSGroup != nil {
333-
return f.FixedFSGroup, nil
334-
}
335-
336325
// The VolumeAttribute takes precedence over the VolumeMountGroup that is
337326
// set using the securityContext.fsGroup field. This way, we can support more
338327
// granular control over the fsGroup per volume.

storage/filesystem_test.go

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -143,56 +143,42 @@ func Test_fsGroupForMetadata(t *testing.T) {
143143
}
144144

145145
tests := map[string]struct {
146-
fixedFSGroup *int64
147146
metaVolumeMountGroup string
148147
fsGroupVolumeAttributeKey string
149148
volumeContext map[string]string
150149

151150
expGID *int64
152151
expErr bool
153152
}{
154-
"FixedFSGroup=nil meta.VolumeMountGroup='' FSGroupVolumeAttributeKey='', should return nil gid": {
155-
fixedFSGroup: nil,
153+
"meta.VolumeMountGroup='' FSGroupVolumeAttributeKey='', should return nil gid": {
156154
metaVolumeMountGroup: "",
157155
fsGroupVolumeAttributeKey: "",
158156
volumeContext: map[string]string{},
159157
expGID: nil,
160158
expErr: false,
161159
},
162-
"FixedFSGroup=10 meta.VolumeMountGroup='' FSGroupVolumeAttributeKey='', should return 10": {
163-
fixedFSGroup: intPtr(10),
164-
metaVolumeMountGroup: "",
165-
fsGroupVolumeAttributeKey: "",
166-
volumeContext: map[string]string{},
167-
expGID: intPtr(10),
168-
expErr: false,
169-
},
170-
"FixedFSGroup=nil meta.VolumeMountGroup='70' FSGroupVolumeAttributeKey='', should return 70": {
171-
fixedFSGroup: nil,
160+
"meta.VolumeMountGroup='70' FSGroupVolumeAttributeKey='', should return 70": {
172161
metaVolumeMountGroup: "70",
173162
fsGroupVolumeAttributeKey: "",
174163
volumeContext: map[string]string{},
175164
expGID: intPtr(70),
176165
expErr: false,
177166
},
178-
"FixedFSGroup=nil meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined but not present in context, should return nil": {
179-
fixedFSGroup: nil,
167+
"meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined but not present in context, should return nil": {
180168
metaVolumeMountGroup: "",
181169
fsGroupVolumeAttributeKey: "fs-gid",
182170
volumeContext: map[string]string{},
183171
expGID: nil,
184172
expErr: false,
185173
},
186-
"FixedFSGroup=nil meta.VolumeMountGroup='70' FSGroupVolumeAttributeKey=defined but not present in context, should return 70": {
187-
fixedFSGroup: nil,
174+
"meta.VolumeMountGroup='70' FSGroupVolumeAttributeKey=defined but not present in context, should return 70": {
188175
metaVolumeMountGroup: "70",
189176
fsGroupVolumeAttributeKey: "fs-gid",
190177
volumeContext: map[string]string{},
191178
expGID: intPtr(70),
192179
expErr: false,
193180
},
194-
"FixedFSGroup=nil meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context, should return 20": {
195-
fixedFSGroup: nil,
181+
"meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context, should return 20": {
196182
metaVolumeMountGroup: "",
197183
fsGroupVolumeAttributeKey: "fs-gid",
198184
volumeContext: map[string]string{
@@ -201,8 +187,7 @@ func Test_fsGroupForMetadata(t *testing.T) {
201187
expGID: intPtr(20),
202188
expErr: false,
203189
},
204-
"FixedFSGroup=nil meta.VolumeMountGroup='10' FSGroupVolumeAttributeKey=defined and present in context, should return 20": {
205-
fixedFSGroup: nil,
190+
"meta.VolumeMountGroup='10' FSGroupVolumeAttributeKey=defined and present in context, should return 20": {
206191
metaVolumeMountGroup: "10",
207192
fsGroupVolumeAttributeKey: "fs-gid",
208193
volumeContext: map[string]string{
@@ -211,8 +196,7 @@ func Test_fsGroupForMetadata(t *testing.T) {
211196
expGID: intPtr(20),
212197
expErr: false,
213198
},
214-
"FixedFSGroup=nil meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context but value of 0, should error": {
215-
fixedFSGroup: nil,
199+
"meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context but value of 0, should error": {
216200
metaVolumeMountGroup: "",
217201
fsGroupVolumeAttributeKey: "fs-gid",
218202
volumeContext: map[string]string{
@@ -221,8 +205,7 @@ func Test_fsGroupForMetadata(t *testing.T) {
221205
expGID: nil,
222206
expErr: true,
223207
},
224-
"FixedFSGroup=nil meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context but value of -1, should error": {
225-
fixedFSGroup: nil,
208+
"meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context but value of -1, should error": {
226209
metaVolumeMountGroup: "",
227210
fsGroupVolumeAttributeKey: "fs-gid",
228211
volumeContext: map[string]string{
@@ -231,8 +214,7 @@ func Test_fsGroupForMetadata(t *testing.T) {
231214
expGID: nil,
232215
expErr: true,
233216
},
234-
"FixedFSGroup=nil meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context but value greater than the max gid, should error": {
235-
fixedFSGroup: nil,
217+
"meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context but value greater than the max gid, should error": {
236218
metaVolumeMountGroup: "",
237219
fsGroupVolumeAttributeKey: "fs-gid",
238220
volumeContext: map[string]string{
@@ -241,8 +223,7 @@ func Test_fsGroupForMetadata(t *testing.T) {
241223
expGID: nil,
242224
expErr: true,
243225
},
244-
"FixedFSGroup=nil meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context but with bad value, should return error": {
245-
fixedFSGroup: nil,
226+
"meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context but with bad value, should return error": {
246227
metaVolumeMountGroup: "",
247228
fsGroupVolumeAttributeKey: "fs-gid",
248229
volumeContext: map[string]string{
@@ -251,22 +232,11 @@ func Test_fsGroupForMetadata(t *testing.T) {
251232
expGID: nil,
252233
expErr: true,
253234
},
254-
"FixedFSGroup=10 meta.VolumeMountGroup='' FSGroupVolumeAttributeKey=defined and present in context, should return superseding FixedFSGroup (10)": {
255-
fixedFSGroup: intPtr(10),
256-
metaVolumeMountGroup: "",
257-
fsGroupVolumeAttributeKey: "fs-gid",
258-
volumeContext: map[string]string{
259-
"fs-gid": "20",
260-
},
261-
expGID: intPtr(10),
262-
expErr: false,
263-
},
264235
}
265236

266237
for name, test := range tests {
267238
t.Run(name, func(t *testing.T) {
268239
f := Filesystem{
269-
FixedFSGroup: test.fixedFSGroup,
270240
FSGroupVolumeAttributeKey: test.fsGroupVolumeAttributeKey,
271241
}
272242

0 commit comments

Comments
 (0)