Add phase 1 of validation tightening.
https://github.com/kubernetes/enhancements/blob/master/keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md 1. Ratcheting validation webhook server image 2. Controller labels invalid objects 3. Unit tests for webhook 4. Deployment README and example deployment method with certs 5. Update top-level README Racheting validation: 1. webhook is strict on create 2. webhook is strict on updates where the existing object passes strict validation 3. webhook is relaxed on updates where the existing object fails strict validation (allows finalizer removal, status update, deletion, etc) Additionally the validating wehook server will perform immutability checks on scenario 2 above.
This commit is contained in:
@@ -811,6 +811,15 @@ func newContent(contentName, boundToSnapshotUID, boundToSnapshotName, snapshotHa
|
||||
return &content
|
||||
}
|
||||
|
||||
func withSnapshotContentInvalidLabel(contents []*crdv1.VolumeSnapshotContent) []*crdv1.VolumeSnapshotContent {
|
||||
for i := range contents {
|
||||
if contents[i].ObjectMeta.Labels == nil {
|
||||
contents[i].ObjectMeta.Labels = make(map[string]string)
|
||||
}
|
||||
contents[i].ObjectMeta.Labels[utils.VolumeSnapshotContentInvalidLabel] = ""
|
||||
}
|
||||
return contents
|
||||
}
|
||||
func withContentAnnotations(contents []*crdv1.VolumeSnapshotContent, annotations map[string]string) []*crdv1.VolumeSnapshotContent {
|
||||
for i := range contents {
|
||||
if contents[i].ObjectMeta.Annotations == nil {
|
||||
@@ -939,6 +948,16 @@ func newSnapshotArray(
|
||||
}
|
||||
}
|
||||
|
||||
func withSnapshotInvalidLabel(snapshots []*crdv1.VolumeSnapshot) []*crdv1.VolumeSnapshot {
|
||||
for i := range snapshots {
|
||||
if snapshots[i].ObjectMeta.Labels == nil {
|
||||
snapshots[i].ObjectMeta.Labels = make(map[string]string)
|
||||
}
|
||||
snapshots[i].ObjectMeta.Labels[utils.VolumeSnapshotInvalidLabel] = ""
|
||||
}
|
||||
return snapshots
|
||||
}
|
||||
|
||||
func newSnapshotClass(snapshotClassName, snapshotClassUID, driverName string, isDefaultClass bool) *crdv1.VolumeSnapshotClass {
|
||||
sc := &crdv1.VolumeSnapshotClass{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
Reference in New Issue
Block a user