mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
phase42: expand lifecycle owner admission checks
This commit is contained in:
1 parent
f61309251e
commit
eaab26c213
6 files changed
+268
-26
No files matched your search
@@ -1,6 +1,6 @@
|
||||
# Current Plan: Phase 42 - Lifecycle Owner API / Admission Gate
|
||||
|
||||
Status: open, 21% complete. Started on 2026-06-14.
|
||||
Status: open, 36% complete. Started on 2026-06-14.
|
||||
|
||||
Branch: `phase41-lifecycle-owner-foundation`
|
||||
|
||||
@@ -99,7 +99,7 @@ Acceptance:
|
||||
[ ] admission policy propagation is proven before positive/negative assertions
|
||||
[ ] repeated add/remove is idempotent
|
||||
[ ] spec, labels, annotations, ownerReferences, and status are preserved
|
||||
[ ] audit evidence records request, decision, reason, and object diff
|
||||
[ ] audit evidence records request, decision, reason, and observed object diff
|
||||
```
|
||||
|
||||
## D3: Forbidden Main-Object Patches
|
||||
@@ -125,6 +125,8 @@ Acceptance:
|
||||
[ ] every forbidden patch is rejected by real API/admission
|
||||
[ ] rejection reason is stable enough for QA evidence
|
||||
[ ] object is unchanged after every rejected patch
|
||||
[ ] status cannot be mutated by lifecycle-owner through main-object no-op or
|
||||
`/status` subresource paths
|
||||
```
|
||||
|
||||
## D4: Forbidden Resource Mutations
|
||||
@@ -222,6 +224,16 @@ Phase 42 can close only if:
|
||||
absent, and the gate had no VAP propagation wait. The harness now guards
|
||||
optional fields with `has()` and waits until a known-bad lifecycle-owner patch
|
||||
is denied before running assertions. This is pending QA rerun on m02.
|
||||
- 28%: D1 QA re-run passed on m02 (`k3s v1.34.4`) at `116d381`. The
|
||||
lifecycle-owner finalizer add/remove is allowed, forbidden main-object patches
|
||||
are denied, forbidden resource patch checks are denied, object integrity is
|
||||
preserved, and cleanup leaves no admission/RBAC residue.
|
||||
- 36%: D2/D3/D4 breadth dev-complete. The same live gate now also checks
|
||||
idempotent add/remove, annotation/ownerReferences/deletionTimestamp and mixed
|
||||
metadata rejection, `/status` denial plus no main-object status mutation,
|
||||
object-integrity preservation after rejected patches, and
|
||||
create/update/patch/delete denial for forbidden Kubernetes resources. Pending
|
||||
QA rerun.
|
||||
|
||||
## Prerequisites / Risks
|
||||
|
||||
@@ -235,15 +247,18 @@ Phase 42 can close only if:
|
||||
|
||||
## Next Step
|
||||
|
||||
Re-run D1 on m02 or another `ValidatingAdmissionPolicy`-capable cluster. The
|
||||
rerun must show:
|
||||
Re-run the expanded Phase 42 admission gate on m02 or another
|
||||
`ValidatingAdmissionPolicy`-capable cluster. The rerun must show:
|
||||
|
||||
```text
|
||||
phase42_lifecycle_owner_admission_status=ok
|
||||
admission_policy_propagated=true
|
||||
lifecycle_owner_finalizer_add_allowed=true
|
||||
lifecycle_owner_finalizer_remove_allowed=true
|
||||
all forbidden patch checks=false
|
||||
lifecycle_owner_finalizer_add_idempotent=true
|
||||
lifecycle_owner_finalizer_remove_idempotent=true
|
||||
object_integrity_preserved=true
|
||||
all forbidden main-object and resource mutation checks=false
|
||||
```
|
||||
|
||||
QA assignment:
|
||||
|
||||
+54
-1
@@ -1,6 +1,59 @@
|
||||
# QA Sign-off — Phase 42 D1 Lifecycle Owner Admission Gate
|
||||
|
||||
Verdict: **FAIL (blocking product defect in the VAP policy).** On a real
|
||||
Verdict: **PASS (re-validated on `116d381`).** First filed FAIL on `bc5ffc0`
|
||||
(VAP CEL errored on absent optional fields). The dev's fix `116d381` resolves it;
|
||||
the gate now passes G1–G4 on a real VAP-capable cluster. See the Re-validation
|
||||
section immediately below; the original FAIL analysis is kept beneath it for the
|
||||
record.
|
||||
|
||||
## Re-validation — 2026-06-15, commit `116d381 phase42: fix lifecycle owner admission gate`
|
||||
|
||||
The fix: (a) the VAP CEL now `has()`-guards the optional fields (status, labels,
|
||||
annotations, ownerReferences, finalizers) so absent-key eval errors no longer
|
||||
deny legitimate patches; (b) a probe object drives an admission-propagation wait
|
||||
before the real assertions, with `admission_policy_propagated=true` added to the
|
||||
pass criteria.
|
||||
|
||||
Re-ran `bash scripts/run-phase42-lifecycle-owner-admission-gate.sh` on m02
|
||||
(k3s v1.34.4, VAP-capable), artifacts `/tmp/p42d1c`. `GATE_EXIT=0`, full summary:
|
||||
|
||||
```text
|
||||
phase42_lifecycle_owner_admission_status=ok
|
||||
harness=live_kubernetes_validating_admission_policy
|
||||
admission_policy_propagated=true
|
||||
operator_status_main_patch_allowed=false
|
||||
lifecycle_owner_finalizer_add_allowed=true
|
||||
lifecycle_owner_finalizer_remove_allowed=true
|
||||
lifecycle_owner_spec_patch_allowed=false
|
||||
lifecycle_owner_label_patch_allowed=false
|
||||
lifecycle_owner_foreign_finalizer_allowed=false
|
||||
lifecycle_owner_mixed_patch_allowed=false
|
||||
finalizers_endpoint_allowed=false
|
||||
lifecycle_owner_{pods,deployments,persistentvolumeclaims,persistentvolumes,
|
||||
storageclasses,secrets,nodes,csidrivers,csinodes}_patch_allowed=false
|
||||
```
|
||||
|
||||
- **G1** PASS — `status=ok`, `admission_policy_propagated=true`, legitimate
|
||||
finalizer add/remove allowed, all forbidden main-object patches (spec, label,
|
||||
foreign finalizer, mixed, `/finalizers` subresource) denied; operator-status
|
||||
main patch denied (RBAC).
|
||||
- **G2** PASS — all nine forbidden resource mutations (pods, deployments, pvc,
|
||||
pv, storageclasses, secrets, nodes, csidrivers, csinodes) `=false`.
|
||||
- **G3** PASS — final object integrity: `spec.pvcName=phase42-a`,
|
||||
`metadata.labels.keep=true`, `metadata.annotations.keep=true`, no foreign
|
||||
finalizer remains (the allowed finalizer add/remove changed nothing else).
|
||||
- **G4** PASS — `sw-block-phase42-gate` namespace NotFound; no leftover
|
||||
`sw-block-phase42-*` VAP / VAPBinding / ClusterRole / ClusterRoleBinding.
|
||||
|
||||
The lifecycle-owner main-object patch is now provably confined to the
|
||||
`block.seaweedfs.com/swblockvolume-protection` finalizer against a real
|
||||
Kubernetes admission server. **Phase 42 D1 passes**; lab left clean.
|
||||
|
||||
---
|
||||
|
||||
## Original finding (commit `bc5ffc0`, superseded by the Re-validation above)
|
||||
|
||||
Verdict at filing: **FAIL (blocking product defect in the VAP policy).** On a real
|
||||
VAP-capable cluster the admission gate denies the **legitimate** lifecycle-owner
|
||||
finalizer add — the policy CEL errors on absent optional fields. This is a
|
||||
live-only defect: it is invisible to the Phase 41 schema-aware mock and to the
|
||||
|
||||
+31
-11
@@ -80,28 +80,47 @@ harness=live_kubernetes_validating_admission_policy
|
||||
admission_policy_propagated=true
|
||||
operator_status_main_patch_allowed=false
|
||||
lifecycle_owner_finalizer_add_allowed=true
|
||||
lifecycle_owner_finalizer_add_idempotent=true
|
||||
lifecycle_owner_finalizer_remove_allowed=true
|
||||
lifecycle_owner_finalizer_remove_idempotent=true
|
||||
lifecycle_owner_spec_patch_allowed=false
|
||||
lifecycle_owner_label_patch_allowed=false
|
||||
lifecycle_owner_annotation_patch_allowed=false
|
||||
lifecycle_owner_ownerreferences_patch_allowed=false
|
||||
lifecycle_owner_deletiontimestamp_patch_allowed=false
|
||||
lifecycle_owner_foreign_finalizer_allowed=false
|
||||
lifecycle_owner_mixed_patch_allowed=false
|
||||
lifecycle_owner_mixed_metadata_patch_allowed=false
|
||||
lifecycle_owner_main_status_mutated=false
|
||||
lifecycle_owner_status_subresource_patch_allowed=false
|
||||
finalizers_endpoint_allowed=false
|
||||
object_integrity_preserved=true
|
||||
```
|
||||
|
||||
## G2 - Forbidden Resource Mutations
|
||||
|
||||
The summary must include `false` for all lifecycle-owner patch checks:
|
||||
The summary must include `false` for all lifecycle-owner `create`, `update`,
|
||||
`patch`, and `delete` checks for these resources:
|
||||
|
||||
```text
|
||||
pods
|
||||
deployments
|
||||
persistentvolumeclaims
|
||||
persistentvolumes
|
||||
storageclasses
|
||||
secrets
|
||||
nodes
|
||||
csidrivers
|
||||
csinodes
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```text
|
||||
lifecycle_owner_pods_create_allowed=false
|
||||
lifecycle_owner_pods_update_allowed=false
|
||||
lifecycle_owner_pods_patch_allowed=false
|
||||
lifecycle_owner_deployments_patch_allowed=false
|
||||
lifecycle_owner_persistentvolumeclaims_patch_allowed=false
|
||||
lifecycle_owner_persistentvolumes_patch_allowed=false
|
||||
lifecycle_owner_storageclasses_patch_allowed=false
|
||||
lifecycle_owner_secrets_patch_allowed=false
|
||||
lifecycle_owner_nodes_patch_allowed=false
|
||||
lifecycle_owner_csidrivers_patch_allowed=false
|
||||
lifecycle_owner_csinodes_patch_allowed=false
|
||||
lifecycle_owner_pods_delete_allowed=false
|
||||
```
|
||||
|
||||
Fail if any forbidden resource mutation is allowed.
|
||||
@@ -117,10 +136,11 @@ spec.pvcName remains phase42-a
|
||||
metadata.labels.keep remains true
|
||||
metadata.annotations.keep remains true
|
||||
no foreign finalizer remains
|
||||
object_integrity_preserved=true
|
||||
```
|
||||
|
||||
Fail if an allowed finalizer patch changes spec, labels, annotations, or any
|
||||
unrelated metadata.
|
||||
Fail if an allowed finalizer patch or any rejected patch changes spec, labels,
|
||||
annotations, ownerReferences, status, or any unrelated metadata.
|
||||
|
||||
## G4 - Cleanup
|
||||
|
||||
|
||||
@@ -44,6 +44,28 @@ function Expect-Failure {
|
||||
}
|
||||
}
|
||||
|
||||
function Assert-JsonPathEquals {
|
||||
param([string]$Name, [string]$Path, [string]$Expected)
|
||||
Expect-Success $Name @("get", "swblockvolume", "phase42-a", "-n", $Namespace, "-o", "jsonpath=$Path")
|
||||
$actual = Get-Content (Join-Path $ArtifactDir "$Name.stdout.txt") -Raw -ErrorAction SilentlyContinue
|
||||
if ($null -eq $actual) { $actual = "" }
|
||||
$actual = $actual.TrimEnd("`r", "`n")
|
||||
if ($actual -ne $Expected) {
|
||||
throw "unexpected ${Name}: got '$actual', expected '$Expected'"
|
||||
}
|
||||
}
|
||||
|
||||
function Assert-JsonPathEmpty {
|
||||
param([string]$Name, [string]$Path)
|
||||
Expect-Success $Name @("get", "swblockvolume", "phase42-a", "-n", $Namespace, "-o", "jsonpath=$Path")
|
||||
$actual = Get-Content (Join-Path $ArtifactDir "$Name.stdout.txt") -Raw -ErrorAction SilentlyContinue
|
||||
if ($null -eq $actual) { $actual = "" }
|
||||
$actual = $actual.TrimEnd("`r", "`n")
|
||||
if (-not [string]::IsNullOrEmpty($actual)) {
|
||||
throw "unexpected ${Name}: got '$actual', expected empty"
|
||||
}
|
||||
}
|
||||
|
||||
function Cleanup {
|
||||
try { & $Kubectl delete validatingadmissionpolicybinding sw-block-phase42-finalizer-only --ignore-not-found >$null 2>$null } catch {}
|
||||
try { & $Kubectl delete validatingadmissionpolicy sw-block-phase42-finalizer-only --ignore-not-found >$null 2>$null } catch {}
|
||||
@@ -261,28 +283,61 @@ spec:
|
||||
Add-Summary "operator_status_main_patch_allowed=false"
|
||||
Expect-Success "lifecycle-owner-add-finalizer" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", "{`"metadata`":{`"finalizers`":[`"$Finalizer`"]}}")
|
||||
Add-Summary "lifecycle_owner_finalizer_add_allowed=true"
|
||||
Expect-Success "lifecycle-owner-add-finalizer-idempotent" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", "{`"metadata`":{`"finalizers`":[`"$Finalizer`"]}}")
|
||||
Add-Summary "lifecycle_owner_finalizer_add_idempotent=true"
|
||||
Expect-Success "lifecycle-owner-remove-finalizer" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"metadata":{"finalizers":[]}}')
|
||||
Add-Summary "lifecycle_owner_finalizer_remove_allowed=true"
|
||||
Expect-Success "lifecycle-owner-remove-finalizer-idempotent" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"metadata":{"finalizers":[]}}')
|
||||
Add-Summary "lifecycle_owner_finalizer_remove_idempotent=true"
|
||||
|
||||
Expect-Failure "lifecycle-owner-spec-patch" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"spec":{"pvcName":"changed"}}')
|
||||
Add-Summary "lifecycle_owner_spec_patch_allowed=false"
|
||||
Expect-Failure "lifecycle-owner-label-patch" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"metadata":{"labels":{"changed":"true"}}}')
|
||||
Add-Summary "lifecycle_owner_label_patch_allowed=false"
|
||||
Expect-Failure "lifecycle-owner-annotation-patch" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"metadata":{"annotations":{"changed":"true"}}}')
|
||||
Add-Summary "lifecycle_owner_annotation_patch_allowed=false"
|
||||
Expect-Failure "lifecycle-owner-ownerreferences-patch" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"metadata":{"ownerReferences":[{"apiVersion":"v1","kind":"ConfigMap","name":"foreign-owner","uid":"00000000-0000-0000-0000-000000000000"}]}}')
|
||||
Add-Summary "lifecycle_owner_ownerreferences_patch_allowed=false"
|
||||
Expect-Failure "lifecycle-owner-deletiontimestamp-patch" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"metadata":{"deletionTimestamp":"2026-01-01T00:00:00Z"}}')
|
||||
Add-Summary "lifecycle_owner_deletiontimestamp_patch_allowed=false"
|
||||
Expect-Failure "lifecycle-owner-foreign-finalizer" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"metadata":{"finalizers":["example.com/foreign"]}}')
|
||||
Add-Summary "lifecycle_owner_foreign_finalizer_allowed=false"
|
||||
Expect-Failure "lifecycle-owner-mixed-patch" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", "{`"metadata`":{`"finalizers`":[`"$Finalizer`"]},`"spec`":{`"pvcName`":`"changed`"}}")
|
||||
Add-Summary "lifecycle_owner_mixed_patch_allowed=false"
|
||||
Expect-Failure "lifecycle-owner-mixed-metadata-patch" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", "{`"metadata`":{`"finalizers`":[`"$Finalizer`"],`"annotations`":{`"changed`":`"true`"}}}")
|
||||
Add-Summary "lifecycle_owner_mixed_metadata_patch_allowed=false"
|
||||
|
||||
$code = Invoke-Capture -Name "lifecycle-owner-main-status-patch" -Args @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--type=merge", "-p", '{"status":{"status":"ready","reasonCode":"forbidden"}}')
|
||||
if ($code -eq 0) {
|
||||
Add-Summary "lifecycle_owner_main_status_patch_request_denied=false"
|
||||
} else {
|
||||
Add-Summary "lifecycle_owner_main_status_patch_request_denied=true"
|
||||
}
|
||||
Assert-JsonPathEmpty "final-status-empty" "{.status.status}"
|
||||
Add-Summary "lifecycle_owner_main_status_mutated=false"
|
||||
|
||||
Expect-Failure "lifecycle-owner-status-subresource-patch" @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--subresource=status", "--type=merge", "-p", '{"status":{"status":"ready","reasonCode":"forbidden"}}')
|
||||
Add-Summary "lifecycle_owner_status_subresource_patch_allowed=false"
|
||||
|
||||
$code = Invoke-Capture -Name "finalizers-endpoint" -Args @("patch", "swblockvolume", "phase42-a", "-n", $Namespace, "--as", $ownerAs, "--subresource=finalizers", "--type=merge", "-p", "{`"metadata`":{`"finalizers`":[`"$Finalizer`"]}}")
|
||||
if ($code -eq 0) { throw "unexpected /finalizers subresource success" }
|
||||
Add-Summary "finalizers_endpoint_allowed=false"
|
||||
|
||||
foreach ($resource in @("pods", "deployments", "persistentvolumeclaims", "persistentvolumes", "storageclasses", "secrets", "nodes", "csidrivers", "csinodes")) {
|
||||
$code = Invoke-Capture -Name "can-i-patch-$resource" -Args @("auth", "can-i", "patch", $resource, "--as", $ownerAs, "-n", $Namespace)
|
||||
if ($code -eq 0) { throw "unexpected patch permission for $resource" }
|
||||
Add-Summary "lifecycle_owner_${resource}_patch_allowed=false"
|
||||
foreach ($verb in @("create", "update", "patch", "delete")) {
|
||||
$code = Invoke-Capture -Name "can-i-$verb-$resource" -Args @("auth", "can-i", $verb, $resource, "--as", $ownerAs, "-n", $Namespace)
|
||||
if ($code -eq 0) { throw "unexpected $verb permission for $resource" }
|
||||
Add-Summary "lifecycle_owner_${resource}_${verb}_allowed=false"
|
||||
}
|
||||
}
|
||||
|
||||
Assert-JsonPathEquals "final-spec-pvc" "{.spec.pvcName}" "phase42-a"
|
||||
Assert-JsonPathEquals "final-label-keep" "{.metadata.labels.keep}" "true"
|
||||
Assert-JsonPathEquals "final-annotation-keep" "{.metadata.annotations.keep}" "true"
|
||||
Assert-JsonPathEmpty "final-finalizers-empty" "{range .metadata.finalizers[*]}{.}{'\n'}{end}"
|
||||
Assert-JsonPathEmpty "final-ownerreferences-empty" "{range .metadata.ownerReferences[*]}{.name}{'\n'}{end}"
|
||||
Add-Summary "object_integrity_preserved=true"
|
||||
|
||||
Expect-Success "final-object" @("get", "swblockvolume", "phase42-a", "-n", $Namespace, "-o", "yaml")
|
||||
Add-Summary "phase42_lifecycle_owner_admission_status=ok"
|
||||
}
|
||||
|
||||
@@ -43,6 +43,31 @@ run_expect_failure() {
|
||||
return 0
|
||||
}
|
||||
|
||||
assert_jsonpath_equals() {
|
||||
local name="$1"
|
||||
local path="$2"
|
||||
local expected="$3"
|
||||
run_expect_success "${name}" "${KUBECTL}" get swblockvolume phase42-a -n "${NAMESPACE}" -o "jsonpath=${path}"
|
||||
local actual
|
||||
actual="$(cat "${ARTIFACT_DIR}/${name}.stdout.txt")"
|
||||
if [ "${actual}" != "${expected}" ]; then
|
||||
echo "unexpected ${name}: got '${actual}', expected '${expected}'" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
assert_jsonpath_empty() {
|
||||
local name="$1"
|
||||
local path="$2"
|
||||
run_expect_success "${name}" "${KUBECTL}" get swblockvolume phase42-a -n "${NAMESPACE}" -o "jsonpath=${path}"
|
||||
local actual
|
||||
actual="$(cat "${ARTIFACT_DIR}/${name}.stdout.txt")"
|
||||
if [ -n "${actual}" ]; then
|
||||
echo "unexpected ${name}: got '${actual}', expected empty" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
set +e
|
||||
"${KUBECTL}" delete validatingadmissionpolicybinding sw-block-phase42-finalizer-only --ignore-not-found >/dev/null 2>&1
|
||||
@@ -257,21 +282,50 @@ write_summary "operator_status_main_patch_allowed=false"
|
||||
run_expect_success lifecycle-owner-add-finalizer "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p "{\"metadata\":{\"finalizers\":[\"${FINALIZER}\"]}}"
|
||||
write_summary "lifecycle_owner_finalizer_add_allowed=true"
|
||||
|
||||
run_expect_success lifecycle-owner-add-finalizer-idempotent "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p "{\"metadata\":{\"finalizers\":[\"${FINALIZER}\"]}}"
|
||||
write_summary "lifecycle_owner_finalizer_add_idempotent=true"
|
||||
|
||||
run_expect_success lifecycle-owner-remove-finalizer "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"metadata":{"finalizers":[]}}'
|
||||
write_summary "lifecycle_owner_finalizer_remove_allowed=true"
|
||||
|
||||
run_expect_success lifecycle-owner-remove-finalizer-idempotent "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"metadata":{"finalizers":[]}}'
|
||||
write_summary "lifecycle_owner_finalizer_remove_idempotent=true"
|
||||
|
||||
run_expect_failure lifecycle-owner-spec-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"spec":{"pvcName":"changed"}}'
|
||||
write_summary "lifecycle_owner_spec_patch_allowed=false"
|
||||
|
||||
run_expect_failure lifecycle-owner-label-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"metadata":{"labels":{"changed":"true"}}}'
|
||||
write_summary "lifecycle_owner_label_patch_allowed=false"
|
||||
|
||||
run_expect_failure lifecycle-owner-annotation-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"metadata":{"annotations":{"changed":"true"}}}'
|
||||
write_summary "lifecycle_owner_annotation_patch_allowed=false"
|
||||
|
||||
run_expect_failure lifecycle-owner-ownerreferences-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"metadata":{"ownerReferences":[{"apiVersion":"v1","kind":"ConfigMap","name":"foreign-owner","uid":"00000000-0000-0000-0000-000000000000"}]}}'
|
||||
write_summary "lifecycle_owner_ownerreferences_patch_allowed=false"
|
||||
|
||||
run_expect_failure lifecycle-owner-deletiontimestamp-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"metadata":{"deletionTimestamp":"2026-01-01T00:00:00Z"}}'
|
||||
write_summary "lifecycle_owner_deletiontimestamp_patch_allowed=false"
|
||||
|
||||
run_expect_failure lifecycle-owner-foreign-finalizer "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"metadata":{"finalizers":["example.com/foreign"]}}'
|
||||
write_summary "lifecycle_owner_foreign_finalizer_allowed=false"
|
||||
|
||||
run_expect_failure lifecycle-owner-mixed-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p "{\"metadata\":{\"finalizers\":[\"${FINALIZER}\"]},\"spec\":{\"pvcName\":\"changed\"}}"
|
||||
write_summary "lifecycle_owner_mixed_patch_allowed=false"
|
||||
|
||||
run_expect_failure lifecycle-owner-mixed-metadata-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p "{\"metadata\":{\"finalizers\":[\"${FINALIZER}\"],\"annotations\":{\"changed\":\"true\"}}}"
|
||||
write_summary "lifecycle_owner_mixed_metadata_patch_allowed=false"
|
||||
|
||||
if run_capture lifecycle-owner-main-status-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --type=merge -p '{"status":{"status":"ready","reasonCode":"forbidden"}}'; then
|
||||
write_summary "lifecycle_owner_main_status_patch_request_denied=false"
|
||||
else
|
||||
write_summary "lifecycle_owner_main_status_patch_request_denied=true"
|
||||
fi
|
||||
assert_jsonpath_empty final-status-empty "{.status.status}"
|
||||
write_summary "lifecycle_owner_main_status_mutated=false"
|
||||
|
||||
run_expect_failure lifecycle-owner-status-subresource-patch "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --subresource=status --type=merge -p '{"status":{"status":"ready","reasonCode":"forbidden"}}'
|
||||
write_summary "lifecycle_owner_status_subresource_patch_allowed=false"
|
||||
|
||||
if "${KUBECTL}" patch swblockvolume phase42-a -n "${NAMESPACE}" --as "${OWNER_AS}" --subresource=finalizers --type=merge -p "{\"metadata\":{\"finalizers\":[\"${FINALIZER}\"]}}" >"${ARTIFACT_DIR}/finalizers-endpoint.stdout.txt" 2>"${ARTIFACT_DIR}/finalizers-endpoint.stderr.txt"; then
|
||||
write_summary "finalizers_endpoint_allowed=true"
|
||||
echo "unexpected /finalizers subresource success" >&2
|
||||
@@ -280,14 +334,23 @@ fi
|
||||
write_summary "finalizers_endpoint_allowed=false"
|
||||
|
||||
for resource in pods deployments persistentvolumeclaims persistentvolumes storageclasses secrets nodes csidrivers csinodes; do
|
||||
if "${KUBECTL}" auth can-i patch "${resource}" --as "${OWNER_AS}" -n "${NAMESPACE}" >/dev/null 2>&1; then
|
||||
write_summary "lifecycle_owner_${resource}_patch_allowed=true"
|
||||
echo "unexpected patch permission for ${resource}" >&2
|
||||
exit 1
|
||||
fi
|
||||
write_summary "lifecycle_owner_${resource}_patch_allowed=false"
|
||||
for verb in create update patch delete; do
|
||||
if "${KUBECTL}" auth can-i "${verb}" "${resource}" --as "${OWNER_AS}" -n "${NAMESPACE}" >/dev/null 2>&1; then
|
||||
write_summary "lifecycle_owner_${resource}_${verb}_allowed=true"
|
||||
echo "unexpected ${verb} permission for ${resource}" >&2
|
||||
exit 1
|
||||
fi
|
||||
write_summary "lifecycle_owner_${resource}_${verb}_allowed=false"
|
||||
done
|
||||
done
|
||||
|
||||
assert_jsonpath_equals final-spec-pvc "{.spec.pvcName}" "phase42-a"
|
||||
assert_jsonpath_equals final-label-keep "{.metadata.labels.keep}" "true"
|
||||
assert_jsonpath_equals final-annotation-keep "{.metadata.annotations.keep}" "true"
|
||||
assert_jsonpath_empty final-finalizers-empty "{range .metadata.finalizers[*]}{.}{'\n'}{end}"
|
||||
assert_jsonpath_empty final-ownerreferences-empty "{range .metadata.ownerReferences[*]}{.name}{'\n'}{end}"
|
||||
write_summary "object_integrity_preserved=true"
|
||||
|
||||
run_expect_success final-object "${KUBECTL}" get swblockvolume phase42-a -n "${NAMESPACE}" -o yaml
|
||||
|
||||
write_summary "phase42_lifecycle_owner_admission_status=ok"
|
||||
@@ -35,10 +35,18 @@ phases:
|
||||
name: lifecycle_owner_finalizer_add_allowed
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_finalizer_add_allowed=true$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_finalizer_add_idempotent
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_finalizer_add_idempotent=true$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_finalizer_remove_allowed
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_finalizer_remove_allowed=true$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_finalizer_remove_idempotent
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_finalizer_remove_idempotent=true$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_spec_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
@@ -47,6 +55,18 @@ phases:
|
||||
name: lifecycle_owner_label_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_label_patch_allowed=false$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_annotation_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_annotation_patch_allowed=false$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_ownerreferences_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_ownerreferences_patch_allowed=false$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_deletiontimestamp_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_deletiontimestamp_patch_allowed=false$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_foreign_finalizer_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
@@ -55,7 +75,23 @@ phases:
|
||||
name: lifecycle_owner_mixed_patch_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_mixed_patch_allowed=false$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_mixed_metadata_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_mixed_metadata_patch_allowed=false$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_main_status_not_mutated
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_main_status_mutated=false$"
|
||||
- type: grep_log
|
||||
name: lifecycle_owner_status_subresource_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^lifecycle_owner_status_subresource_patch_allowed=false$"
|
||||
- type: grep_log
|
||||
name: finalizers_endpoint_forbidden
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^finalizers_endpoint_allowed=false$"
|
||||
- type: grep_log
|
||||
name: object_integrity_preserved
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase42-lifecycle-owner-admission-gate/phase42-lifecycle-owner-admission-gate-summary.txt"
|
||||
pattern: "^object_integrity_preserved=true$"
|
||||
Reference in new issue
Block a user