mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Update generation when SELinuxMount is changed
This commit is contained in:
parent
3efeeef346
commit
189f19a698
@ -86,15 +86,17 @@ func (csiDriverStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.
|
||||
newCSIDriver.Spec.VolumeLifecycleModes = nil
|
||||
}
|
||||
|
||||
// Any changes to the mutable fields increment the generation number.
|
||||
if !apiequality.Semantic.DeepEqual(oldCSIDriver.Spec.TokenRequests, newCSIDriver.Spec.TokenRequests) || !apiequality.Semantic.DeepEqual(oldCSIDriver.Spec.RequiresRepublish, newCSIDriver.Spec.RequiresRepublish) {
|
||||
newCSIDriver.Generation = oldCSIDriver.Generation + 1
|
||||
}
|
||||
|
||||
if oldCSIDriver.Spec.SELinuxMount == nil &&
|
||||
!utilfeature.DefaultFeatureGate.Enabled(features.SELinuxMountReadWriteOncePod) {
|
||||
newCSIDriver.Spec.SELinuxMount = nil
|
||||
}
|
||||
|
||||
// Any changes to the mutable fields increment the generation number.
|
||||
if !apiequality.Semantic.DeepEqual(oldCSIDriver.Spec.TokenRequests, newCSIDriver.Spec.TokenRequests) ||
|
||||
!apiequality.Semantic.DeepEqual(oldCSIDriver.Spec.RequiresRepublish, newCSIDriver.Spec.RequiresRepublish) ||
|
||||
!apiequality.Semantic.DeepEqual(oldCSIDriver.Spec.SELinuxMount, newCSIDriver.Spec.SELinuxMount) {
|
||||
newCSIDriver.Generation = oldCSIDriver.Generation + 1
|
||||
}
|
||||
}
|
||||
|
||||
func (csiDriverStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
|
||||
|
@ -287,6 +287,7 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
old: driverWithNothing,
|
||||
update: driverWithSELinuxMountEnabled,
|
||||
wantSELinuxMount: &enabled,
|
||||
wantGeneration: 1,
|
||||
},
|
||||
{
|
||||
name: "SELinux mount support feature enabled, before: off, update: on",
|
||||
@ -294,6 +295,7 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
old: driverWithSELinuxMountDisabled,
|
||||
update: driverWithSELinuxMountEnabled,
|
||||
wantSELinuxMount: &enabled,
|
||||
wantGeneration: 1,
|
||||
},
|
||||
{
|
||||
name: "SELinux mount support feature enabled, before: on, update: off",
|
||||
@ -301,6 +303,7 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
old: driverWithSELinuxMountEnabled,
|
||||
update: driverWithSELinuxMountDisabled,
|
||||
wantSELinuxMount: &disabled,
|
||||
wantGeneration: 1,
|
||||
},
|
||||
{
|
||||
name: "SELinux mount support feature disabled, before: nil, update: on",
|
||||
@ -308,6 +311,7 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
old: driverWithNothing,
|
||||
update: driverWithSELinuxMountEnabled,
|
||||
wantSELinuxMount: nil,
|
||||
wantGeneration: 0,
|
||||
},
|
||||
{
|
||||
name: "SELinux mount support feature disabled, before: off, update: on",
|
||||
@ -315,6 +319,7 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
old: driverWithSELinuxMountDisabled,
|
||||
update: driverWithSELinuxMountEnabled,
|
||||
wantSELinuxMount: &enabled,
|
||||
wantGeneration: 1,
|
||||
},
|
||||
{
|
||||
name: "SELinux mount support feature enabled, before: on, update: off",
|
||||
@ -322,6 +327,7 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
old: driverWithSELinuxMountEnabled,
|
||||
update: driverWithSELinuxMountDisabled,
|
||||
wantSELinuxMount: &disabled,
|
||||
wantGeneration: 1,
|
||||
},
|
||||
}
|
||||
|
||||
@ -337,7 +343,7 @@ func TestCSIDriverPrepareForUpdate(t *testing.T) {
|
||||
require.Equal(t, test.wantModes, csiDriver.Spec.VolumeLifecycleModes)
|
||||
require.Equal(t, test.wantTokenRequests, csiDriver.Spec.TokenRequests)
|
||||
require.Equal(t, test.wantRequiresRepublish, csiDriver.Spec.RequiresRepublish)
|
||||
require.Equal(t, test.wantSELinuxMount, csiDriver.Spec.SELinuxMounted)
|
||||
require.Equal(t, test.wantSELinuxMount, csiDriver.Spec.SELinuxMount)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user