Skip to content

Commit a4984a6

Browse files
author
Andi Li
committed
Remove line about future changes to immutability. Add section on how users can check if their cluster is okay to upgrade
1 parent 0f2c017 commit a4984a6

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

keps/sig-storage/177-volume-snapshot/tighten-validation-webhook-crd.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ tags, and then generate with `hack/update-toc.sh`.
114114
- [Authentication](#authentication)
115115
- [Timeout](#timeout)
116116
- [Idempotency/Deadlock](#idempotencydeadlock)
117+
- [Automatic Labelling of Invalid Objects](#automatic-labelling-of-invalid-objects)
117118
- [User Stories (Optional)](#user-stories-optional)
118119
- [Story 1](#story-1)
119120
- [Notes/Constraints/Caveats (Optional)](#notesconstraintscaveats-optional)
@@ -125,6 +126,7 @@ tags, and then generate with `hack/update-toc.sh`.
125126
- [Design Details](#design-details)
126127
- [Deployment](#deployment)
127128
- [Kubernetes API Server Configuration](#kubernetes-api-server-configuration)
129+
- [Webhook Server Deployment](#webhook-server-deployment)
128130
- [Test Plan](#test-plan)
129131
- [Graduation Criteria](#graduation-criteria)
130132
- [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy)
@@ -232,7 +234,7 @@ Tighten the validation on Volume Snapshot objects. Please see the tables below f
232234

233235
Due to backwards compatibility concerns, the tightening will occur in two phases.
234236

235-
1. The first phase is webhook-only, and will use [ratcheting validation](#backwards-compatibility). It will be the user's responsibility to clean up invalid objects which already existed before the webhook was enabled. Invalid objects are those which fail the new, stricter validation. The controller will not be able to automatically fix invalid objects.
237+
1. The first phase is webhook-only, and will use [ratcheting validation](#backwards-compatibility). It will be the user's responsibility to clean up invalid objects which already existed before the webhook was enabled. Invalid objects are those which fail the new, stricter validation. The controller will not be able to automatically fix invalid objects, however it will apply a [label](#automatic-labelling-of-invalid-objects) to invalid objects so that users can easily locate them.
236238
2. The second phase can occur once all invalid objects are cleared from the cluster. It will be the cluster admin's responsibility to check and detect when it is safe to move to the second phase. The CRD schema validation will be tightened and the webhook will stick around to enforce immutability until immutable fields come to CRDs (Custom Resource Definition). This will be accompanied by a version change to make it clear the CRD is using different validation.
237239

238240
The phases come in separate releases to allow users / cluster admin the opportunity to clean their cluster of any invalid objects. More details are in the Risks and Mitigations section.
@@ -249,8 +251,6 @@ All of the validation desired can be achieved by updating the CRDs to take advan
249251

250252
There is a desire for some fields to be immutable, which is not yet supported by CRDs. See the immutable fields [KEP](https://github.com/kubernetes/enhancements/blob/master/keps/sig-api-machinery/20190603-immutable-fields.md) for the latest updates. As of August 2020, the KEP is provisional and has no clear timeline for when immutable fields will come to CRDs.
251253

252-
Note that we may want to consider other fields to be marked as immutable.
253-
254254
#### VolumeSnapshot
255255

256256
| Operation | Field | Reason | HTTP RCode |
@@ -288,6 +288,35 @@ To avoid migration pain it is recommended to start with a `failurePolicy` value
288288

289289
Since only validating webhooks will be introduced in this version, idempotency/deadlock are not relevant.
290290

291+
### Automatic Labelling of Invalid Objects
292+
293+
The controller will apply a label called `snapshot.storage.sigs.k8s.io/invalid-snapshot-resource` to `VolumeSnapshot` and `snapshot.storage.sigs.k8s.io/invalid-snapshot-content-resource` to `VolumeSnapshotContent` objects which fail strict validation. For valid objects the label will not be present, and for invalid objects it will be present. The value of the label does not matter, and is set to the empty string by default. The controller will use the same validation logic in the webhook.
294+
295+
For example here's the yaml for an invalid `VolumeSnapshot`:
296+
297+
```yaml
298+
apiVersion: snapshot.storage.k8s.io/v1beta1
299+
kind: VolumeSnapshot
300+
metadata:
301+
name: snapshot-label-example
302+
labels:
303+
snapshot.storage.sigs.k8s.io/invalid-snapshot-resource: "" # Label applied for invalid VolumeSnapshot objects
304+
...
305+
```
306+
307+
Here's an example for the yaml for an invalid `VolumeSnapshotContent`:
308+
```yaml
309+
apiVersion: snapshot.storage.k8s.io/v1beta1
310+
kind: VolumeSnapshotContent
311+
metadata:
312+
name: snapcontent-72d9a349-aacd-42d2-a240-d775650d2455
313+
labels:
314+
snapshot.storage.sigs.k8s.io/invalid-snapshot-content-resource: "" # Label applied for invalid VolumeSnapshotContent objects
315+
...
316+
```
317+
318+
Users and cluster admins MUST ensure there are NO objects with the labels applied before upgrading to phase 2.
319+
291320
### User Stories (Optional)
292321

293322
<!--
@@ -354,7 +383,7 @@ Begin with validating webhook only enforcement. The webhook will perform the fol
354383
- webhook is strict on create
355384
- webhook is strict on updates where the existing object passes strict validation
356385
- webhook is relaxed on updates where the existing object fails strict validation (allows finalizer removal, status update, deletion, etc)
357-
- The user will need to delete or fix all invalid objects. The webhook and controllers will not take any automatic action to reconcile invalid objects.
386+
- The user will need to delete or fix all invalid objects. The webhook and controllers will not take any automatic action to reconcile invalid objects. However, the controller will add a label.
358387

359388
For `UPDATE` operations, the webhook server will receive the existing object and the new, proposed object. We will use this feature to check when the existing objects passes or fails strict validation.
360389

0 commit comments

Comments
 (0)