mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
alpha: package Helm lifecycle and read-only operations release
Merge Phase 26-32 Helm lifecycle, read-only operations, restart persistence, cleanup reliability, and v0.3.4 alpha documentation.
This commit is contained in:
1 parent
01d735dad7
commit
8651073e0c
76 files changed
+8909
-324
No files matched your search
+99
-171
@@ -1,11 +1,15 @@
|
||||
# Seaweed Block
|
||||
# Seaweed Block (Alpha)
|
||||
|
||||
<p align="center">
|
||||
<img src="docs/assets/seaweed-block-hero.svg" alt="Seaweed Block alpha architecture: Kubernetes PVC to CSI, blockmaster, blockvolume, iSCSI, and WAL-backed recovery" width="100%">
|
||||
</p>
|
||||
|
||||
Seaweed Block is an experimental Kubernetes block storage service built around
|
||||
normal Kubernetes PVCs, a CSI driver, and SeaweedFS block components.
|
||||
Seaweed Block is an experimental Kubernetes block storage service built around:
|
||||
|
||||
- normal Kubernetes PVC workflow,
|
||||
- a CSI driver,
|
||||
- Seaweed block components,
|
||||
- read-only operations evidence.
|
||||
|
||||
The current alpha is focused on one user-visible loop:
|
||||
|
||||
@@ -18,107 +22,70 @@ install on Kubernetes
|
||||
-> clean up
|
||||
```
|
||||
|
||||
Start with the Kubernetes tutorial:
|
||||
This is an **alpha** product path for supported lab clusters, not production.
|
||||
|
||||
- [First volume on Kubernetes](docs/quickstart-kubernetes.md)
|
||||
- [Release notes](docs/releases/README.md)
|
||||
## Feature & Status
|
||||
|
||||
## Status
|
||||
| Feature | Status | Feature | Status |
|
||||
|---|---|---|---|
|
||||
| Kubernetes PVC provisioning | Available | Helm install path | Available |
|
||||
| First PVC writer/reader verification | Available | Read-only report/dashboard | Available |
|
||||
| Support-bundle replay | Available | Negative-first status reasons | Available |
|
||||
| Multi-volume RF=3 lab path | Gated | CSI reattach recovery | Gated |
|
||||
| iSCSI ALUA/dm-multipath mounted failover | Gated | Restart persistence with hostPath | Gated |
|
||||
| Read-only operator snapshot | Partial | Production operator lifecycle | Planned |
|
||||
| Backup/snapshot/restore | Planned | Returned-replica rebuild/failback | Planned |
|
||||
| NVMe ANA parity | Planned | Production SLO/performance claims | Not claimed |
|
||||
|
||||
Alpha / early beta shape. Not production-ready.
|
||||
## What You Can Do Today
|
||||
|
||||
What has been validated in the current alpha:
|
||||
- Install Seaweed Block through Helm on a supported Kubernetes/k3s lab.
|
||||
- Create and mount PVC-backed block volumes through normal Kubernetes PVCs.
|
||||
- Verify writer/reader persistence with ordinary app pods.
|
||||
- Run multiple RF=3 volumes in the gated lab path.
|
||||
- Validate gated recovery paths:
|
||||
- CSI reattach with pod recreate,
|
||||
- iSCSI ALUA + dm-multipath transparent mounted failover on the proven
|
||||
Stage-2 path,
|
||||
- interleaved multi-volume failover isolation.
|
||||
- Inspect cluster, volume, replica, primary, frontend, timeline, and reason
|
||||
evidence through read-only CLI/report/dashboard surfaces.
|
||||
- Replay support bundles offline.
|
||||
|
||||
- Day-1 install-to-first-volume path: activate stack, create PVC, writer pod
|
||||
verifies data, reader pod verifies persisted data, status report generated,
|
||||
cleanup clean.
|
||||
- dynamic PVC provisioning through CSI.
|
||||
- product-owned generated `blockvolume` lifecycle.
|
||||
- multiple PVCs / volumes visible in inventory.
|
||||
- durable local volume restart/reattach coverage.
|
||||
- RF=3 `sync-quorum` recovery through CSI/pod recreate.
|
||||
- RF=3 Kubernetes node-loss recovery through CSI/pod recreate on a surviving
|
||||
node.
|
||||
- RF=3 iSCSI ALUA + Linux dm-multipath transparent mounted failover on the
|
||||
proven alpha path.
|
||||
- read-only operations evidence through `sw-block ops inventory`,
|
||||
`sw-block ops cluster --master-api ... -o json`, support bundles, and
|
||||
product-owned event timelines.
|
||||
These are narrow alpha claims tied to documented gates. See
|
||||
[release notes](docs/releases/README.md) for exact run evidence.
|
||||
|
||||
These are narrow alpha claims tied to documented gates and support artifacts.
|
||||
Do not treat them as broad production HA or compatibility claims.
|
||||
## What You Should Not Expect Yet
|
||||
|
||||
Known missing pieces:
|
||||
- Production readiness or production SLOs.
|
||||
- A production-grade operator or mutating admin workflow.
|
||||
- Backup, snapshot, or restore.
|
||||
- Returned-replica rebuild, reintegration, or failback.
|
||||
- Transparent Kubernetes node-loss failover without pod recreate.
|
||||
- NVMe ANA parity for the transparent failover path.
|
||||
- Broad distro/kernel/initiator compatibility.
|
||||
- Broad upgrade/rollback safety beyond gated smoke paths.
|
||||
|
||||
- production-grade operator lifecycle,
|
||||
- Helm is the supported v0.3 alpha install path for supported labs; a
|
||||
production-grade Helm lifecycle is not yet claimed,
|
||||
- production hosted dashboard/UI; a local read-only dashboard/report exists,
|
||||
- backup, snapshot, and restore workflow,
|
||||
- returned-replica rebuild, reintegration, and failback,
|
||||
- transparent node-loss failover without pod recreate,
|
||||
- NVMe ANA parity for the transparent failover path,
|
||||
- broad distro/kernel/initiator compatibility matrix,
|
||||
- upgrade/rollback safety,
|
||||
- performance, RTO, or SLO claims,
|
||||
- security/RBAC/audit hardening for mutating admin actions.
|
||||
## Five-Minute Quick Start
|
||||
|
||||
## Why this exists
|
||||
|
||||
Kubernetes storage usually comes down to two options:
|
||||
|
||||
- a full storage stack such as Ceph/Rook
|
||||
- Local PVs with weaker failure handling
|
||||
|
||||
`seaweed-block` explores a smaller block storage design for cases where a full
|
||||
storage platform is too heavy but local storage is not enough. The current
|
||||
goal is to validate the control path, data path, and recovery model before
|
||||
expanding the system.
|
||||
|
||||
## Architecture
|
||||
|
||||
The alpha path:
|
||||
|
||||
- Kubernetes PVC
|
||||
- CSI driver
|
||||
- block master / controller
|
||||
- block volume process
|
||||
- iSCSI target
|
||||
- WAL-backed local write path
|
||||
|
||||
The local write path:
|
||||
|
||||
```text
|
||||
write → WAL → flush/checkpoint → extent
|
||||
```
|
||||
|
||||
The WAL-first design makes writes easier to inspect and recover during
|
||||
development.
|
||||
|
||||
Recovery is split into base transfer and live WAL feeding so normal writes
|
||||
keep flowing while a peer catches up. Only one peer is the source of truth
|
||||
for a recovery stream at any given time.
|
||||
|
||||
## Quick Start
|
||||
|
||||
Use [First volume on Kubernetes](docs/quickstart-kubernetes.md). For v0.3
|
||||
alpha, start with Helm on a supported Kubernetes/k3s lab.
|
||||
|
||||
Fast path:
|
||||
From the repository root:
|
||||
|
||||
```bash
|
||||
go build -o sw-block ./cmd/sw-block
|
||||
export PATH="$PWD:$PATH"
|
||||
|
||||
sw-block ops generate-helm-values \
|
||||
--out values.day1.yaml \
|
||||
--image ghcr.io/seaweedfs/seaweed-block:sha-28a99ce4f644 \
|
||||
--csi-image ghcr.io/seaweedfs/seaweed-block-csi:sha-28a99ce4f644
|
||||
--image ghcr.io/seaweedfs/seaweed-block:sha-6260e46fd3be \
|
||||
--csi-image ghcr.io/seaweedfs/seaweed-block-csi:sha-6260e46fd3be
|
||||
|
||||
helm install sw-block charts/seaweed-block \
|
||||
--namespace kube-system \
|
||||
--create-namespace \
|
||||
-f values.day1.yaml \
|
||||
--wait \
|
||||
--timeout 10m
|
||||
|
||||
SW_BLOCK_INSTALL_MODE=helm \
|
||||
SW_BLOCK_HELM_RELEASE=sw-block \
|
||||
SW_BLOCK_HELM_NAMESPACE=kube-system \
|
||||
@@ -126,12 +93,7 @@ SW_BLOCK_HELM_VALUES_FILE=values.day1.yaml \
|
||||
bash scripts/run-basic-app-example.sh "$PWD"
|
||||
```
|
||||
|
||||
`generate-helm-values` reads the current Kubernetes API through `kubectl`,
|
||||
selects Ready schedulable nodes, and writes chart values. One selected node
|
||||
uses loopback mode. Multiple selected nodes use external iSCSI/status addresses
|
||||
and CHAP by default.
|
||||
|
||||
Expected summary fields:
|
||||
Expected summary in the latest `/tmp/sw-block-basic-app-*/first-volume-summary.txt`:
|
||||
|
||||
```text
|
||||
first_volume_status=ok
|
||||
@@ -142,99 +104,72 @@ status_report=status/report/index.html
|
||||
cleanup_status=ok
|
||||
```
|
||||
|
||||
Use the script path for development, local image testing, or fallback
|
||||
diagnostics when Helm is not the target.
|
||||
|
||||
```bash
|
||||
bash scripts/activate-k8s-alpha.sh "$PWD"
|
||||
bash scripts/run-basic-app-example.sh "$PWD"
|
||||
cat "$(ls -td /tmp/sw-block-basic-app-* | head -1)/first-volume-summary.txt"
|
||||
```
|
||||
|
||||
The `"$PWD"` argument is the repository root. The helper scripts use it to
|
||||
locate chart, manifest, and example files.
|
||||
|
||||
The activation script writes `/tmp/sw-block-activation-*/activation-summary.txt`
|
||||
with the blockmaster, CSI controller, CSI node, StorageClass, protocol, ACK
|
||||
profile, and next inspection commands.
|
||||
|
||||
For QA/PM user-path testing against published images, prefer immutable image
|
||||
tags in Helm values or activation env:
|
||||
|
||||
```bash
|
||||
ghcr.io/seaweedfs/seaweed-block:sha-<commit>
|
||||
ghcr.io/seaweedfs/seaweed-block-csi:sha-<commit>
|
||||
```
|
||||
|
||||
Current validated v0.3 walkthrough image tag: `sha-28a99ce4f644`.
|
||||
Current validated alpha image tag: `sha-6260e46fd3be`.
|
||||
|
||||
Mutable `:alpha` is a smoke/demo tag only; it can drift from the source tree.
|
||||
|
||||
## Operations
|
||||
|
||||
Port-forward blockmaster when reading live cluster state:
|
||||
|
||||
```bash
|
||||
kubectl -n kube-system port-forward deploy/sw-blockmaster 9333:9333
|
||||
sw-block ops cluster --master-api 127.0.0.1:9333 -o json \
|
||||
> /tmp/sw-block-cluster-evidence.json
|
||||
sw-block ops report --master-api 127.0.0.1:9333 --out /tmp/sw-block-report
|
||||
sw-block ops dashboard --master-api 127.0.0.1:9333 --listen 127.0.0.1:9334
|
||||
```
|
||||
|
||||
If `sw-block` is not in `PATH`, run the same commands from this repository as
|
||||
`go run ./cmd/sw-block ops ...`.
|
||||
Common read-only commands:
|
||||
|
||||
`sw-block ops report` writes static read-only artifacts. `sw-block ops
|
||||
dashboard` serves the same evidence as a local read-only dashboard. Neither has
|
||||
mutating admin actions.
|
||||
| Command | Use |
|
||||
|---|---|
|
||||
| `sw-block ops cluster --master-api 127.0.0.1:9333 -o json` | Cluster snapshot. |
|
||||
| `sw-block ops volumes --master-api 127.0.0.1:9333` | List volumes, status, primary, node, frontend. |
|
||||
| `sw-block ops describe volume <id> --namespace default --master 127.0.0.1:9333` | Describe one volume. |
|
||||
| `sw-block ops timeline volume --from-bundle <dir> <id> -o jsonl` | Read a saved event timeline. |
|
||||
| `sw-block ops explain volume --from-bundle <dir> <id>` | Explain ready, blocked, stale, or recovering state. |
|
||||
| `sw-block ops report --master-api 127.0.0.1:9333 --out <dir>` | Generate static report artifacts. |
|
||||
| `sw-block ops dashboard --master-api 127.0.0.1:9333 --listen 127.0.0.1:9334` | Serve local read-only dashboard. |
|
||||
| `sw-block ops inventory --namespace default --master 127.0.0.1:9333 --out <dir>` | Collect replica-level inventory. |
|
||||
|
||||
For replica-level support evidence:
|
||||
Reports and dashboard expose `operator-snapshot.json`, a read-only status
|
||||
projection for future operator work. There are no mutating admin actions.
|
||||
|
||||
Support-bundle replay:
|
||||
|
||||
```bash
|
||||
sw-block ops inventory \
|
||||
--namespace default \
|
||||
--master 127.0.0.1:9333 \
|
||||
--out /tmp/sw-block-inventory
|
||||
bash scripts/collect-helm-support-bundle.sh "$PWD"
|
||||
sw-block ops report --from-bundle <bundle-or-artifact-dir> --out /tmp/sw-block-report
|
||||
sw-block ops explain volume <volume-id> --from-bundle <bundle-or-artifact-dir>
|
||||
sw-block ops dashboard --from-bundle <bundle-or-artifact-dir> --listen 127.0.0.1:9334
|
||||
```
|
||||
|
||||
## What Users Can Do Today
|
||||
The status surface is negative-first. If evidence is missing or stale, the
|
||||
system reports `Ready=Unknown` / `EvidenceStale=True` rather than claiming a
|
||||
false ready state.
|
||||
|
||||
- Install the alpha stack on a supported Kubernetes/k3s lab.
|
||||
- Create PVC-backed block volumes through Kubernetes.
|
||||
- Run app pods that mount the PVC and verify file data.
|
||||
- Inspect cluster, volume, replica, primary, frontend, and event evidence.
|
||||
- Generate a local read-only HTML status report or dashboard from live master
|
||||
evidence or a saved support bundle.
|
||||
- Collect inventory and product evidence bundles for support.
|
||||
- Exercise documented recovery gates in TestOps/lab environments.
|
||||
## Cleanup
|
||||
|
||||
## What Users Should Not Expect Yet
|
||||
|
||||
- A production-grade operator.
|
||||
- Production-grade Helm lifecycle management; Helm is the supported v0.3 alpha
|
||||
install path, but upgrade/rollback/lifecycle hardening is not claimed.
|
||||
- A production hosted dashboard; the current dashboard is local and read-only.
|
||||
- Backup, snapshot, or restore workflows.
|
||||
- Mutating admin actions such as promote, repair, rebuild, failback, or cleanup.
|
||||
- Upgrade/rollback safety.
|
||||
- Performance, RTO, or SLO guarantees.
|
||||
- Broad distro/kernel/initiator compatibility.
|
||||
- Transparent Kubernetes node-loss failover without pod recreate.
|
||||
|
||||
## Repository layout
|
||||
|
||||
```text
|
||||
cmd/ command entry points (blockmaster, blockvolume, blockcsi, sw-block)
|
||||
core/ core storage logic (authority, csi, host, lifecycle, recovery, replication)
|
||||
internal/ non-public packages and TestOps registry
|
||||
deploy/ Kubernetes manifests
|
||||
docs/ design and quickstart docs
|
||||
examples/ Kubernetes examples
|
||||
scripts/ build, install, and smoke-test helpers
|
||||
```bash
|
||||
helm uninstall sw-block --namespace kube-system
|
||||
bash scripts/uninstall-k8s-alpha.sh "$PWD"
|
||||
bash scripts/verify-helm-cleanup.sh
|
||||
```
|
||||
|
||||
The cleanup verifier checks Kubernetes resources, iSCSI sessions, iSCSI node
|
||||
DB records, dm-multipath maps, `dmsetup` devices, product processes, and
|
||||
hostPath residue.
|
||||
|
||||
## Documentation
|
||||
|
||||
- [Kubernetes quickstart](docs/quickstart-kubernetes.md) - first install and PVC.
|
||||
- [User capabilities](docs/user-capabilities.md) - detailed current behavior.
|
||||
- [Release notes](docs/releases/README.md) - exact validated claims and evidence.
|
||||
- [Roadmap](docs/roadmap.md) - public planning summary.
|
||||
- [Architecture](docs/architecture.md), [developer architecture](docs/developer-architecture.md),
|
||||
and [runtime state machines](docs/runtime-state-machines.md) - engineering
|
||||
references, not release-claim sources.
|
||||
|
||||
## Development
|
||||
|
||||
Run the release-relevant scoped tests:
|
||||
Run release-relevant scoped tests:
|
||||
|
||||
```bash
|
||||
go test ./cmd/sw-block ./core/ops ./core/csi ./core/launcher ./core/host/master -count=1
|
||||
@@ -243,20 +178,13 @@ go test ./cmd/sw-block ./core/ops ./core/csi ./core/launcher ./core/host/master
|
||||
`go test ./...` is the full repository sweep and may include unrelated
|
||||
in-progress packages outside the current release gate.
|
||||
|
||||
Run the Kubernetes alpha smoke:
|
||||
Script activation remains available for development/local-image fallback:
|
||||
|
||||
```bash
|
||||
bash scripts/run-k8s-alpha.sh "$PWD"
|
||||
bash scripts/activate-k8s-alpha.sh "$PWD"
|
||||
bash scripts/run-basic-app-example.sh "$PWD"
|
||||
```
|
||||
|
||||
More detail:
|
||||
|
||||
- [docs/releases/README.md](docs/releases/README.md)
|
||||
- [docs/architecture.md](docs/architecture.md)
|
||||
- [docs/developer-architecture.md](docs/developer-architecture.md)
|
||||
- [docs/runtime-state-machines.md](docs/runtime-state-machines.md)
|
||||
- [docs/roadmap.md](docs/roadmap.md)
|
||||
|
||||
## License
|
||||
|
||||
Apache-2.0
|
||||
@@ -36,6 +36,14 @@ helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "seaweed-block.statePermissionsImage" -}}
|
||||
{{- if .Values.blockmaster.statePermissionsImage.digest -}}
|
||||
{{- printf "%s@%s" .Values.blockmaster.statePermissionsImage.repository .Values.blockmaster.statePermissionsImage.digest -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s:%s" .Values.blockmaster.statePermissionsImage.repository .Values.blockmaster.statePermissionsImage.tag -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "seaweed-block.blockmasterAddress" -}}
|
||||
{{- printf "%s.%s.svc.cluster.local:%v" .Values.blockmaster.serviceName .Release.Namespace .Values.blockmaster.listenPort -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -26,6 +26,20 @@ spec:
|
||||
hostNetwork: true
|
||||
dnsPolicy: ClusterFirstWithHostNet
|
||||
serviceAccountName: {{ include "seaweed-block.fullname" . }}-master
|
||||
{{- if .Values.blockmaster.stateHostPath }}
|
||||
initContainers:
|
||||
- name: state-permissions
|
||||
image: {{ include "seaweed-block.statePermissionsImage" . | quote }}
|
||||
imagePullPolicy: {{ .Values.blockmaster.statePermissionsImage.pullPolicy }}
|
||||
command: ["/bin/sh", "-c"]
|
||||
args:
|
||||
- "mkdir -p /var/lib/sw-block/authority /var/lib/sw-block/lifecycle && chown -R 65532:65532 /var/lib/sw-block"
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
volumeMounts:
|
||||
- name: state
|
||||
mountPath: /var/lib/sw-block
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: blockmaster
|
||||
image: {{ include "seaweed-block.image" . | quote }}
|
||||
|
||||
@@ -27,6 +27,29 @@
|
||||
"protocol": { "type": "string", "enum": ["iscsi", "nvme"] }
|
||||
}
|
||||
},
|
||||
"blockmaster": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"stateHostPath": { "type": "string" },
|
||||
"stateHostPathType": { "type": "string" },
|
||||
"statePermissionsImage": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"repository": { "type": "string", "minLength": 1 },
|
||||
"tag": { "type": "string" },
|
||||
"digest": { "type": "string" },
|
||||
"pullPolicy": { "type": "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"restartPersistence": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mode": { "type": "string", "enum": ["ephemeral", "hostpath"] },
|
||||
"stateHostPath": { "type": "string" }
|
||||
}
|
||||
},
|
||||
"network": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -41,6 +41,17 @@ blockmaster:
|
||||
launcherPVCOwnerRef: true
|
||||
stateHostPath: ""
|
||||
stateHostPathType: DirectoryOrCreate
|
||||
statePermissionsImage:
|
||||
repository: busybox
|
||||
tag: "1.36"
|
||||
digest: ""
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
restartPersistence:
|
||||
# ephemeral keeps the alpha/dev default. hostpath persists blockmaster and
|
||||
# generated blockvolume state across Kubernetes pod restarts.
|
||||
mode: ephemeral
|
||||
stateHostPath: ""
|
||||
|
||||
storageClass:
|
||||
create: true
|
||||
|
||||
@@ -624,6 +624,7 @@ func runOpsReport(args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stdout, "html=%s\n", ops.ObservationReportHTMLArtifact)
|
||||
fmt.Fprintf(stdout, "cluster_evidence=%s\n", ops.ObservationReportJSONArtifact)
|
||||
fmt.Fprintf(stdout, "timeline=%s\n", ops.ObservationReportJSONLArtifact)
|
||||
fmt.Fprintf(stdout, "operator_snapshot=%s\n", ops.ObservationOperatorSnapshotArtifact)
|
||||
fmt.Fprintf(stdout, "summary=%s\n", ops.ObservationReportTextArtifact)
|
||||
fmt.Fprintf(stdout, "read_only=true\n")
|
||||
return ops.VolumeStatusExitOK
|
||||
@@ -699,6 +700,7 @@ func runOpsDashboard(args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stdout, "url=http://%s/\n", ln.Addr().String())
|
||||
fmt.Fprintf(stdout, "cluster_evidence=%s\n", ops.ObservationReportJSONArtifact)
|
||||
fmt.Fprintf(stdout, "timeline=%s\n", ops.ObservationReportJSONLArtifact)
|
||||
fmt.Fprintf(stdout, "operator_snapshot=%s\n", ops.ObservationOperatorSnapshotArtifact)
|
||||
fmt.Fprintf(stdout, "summary=%s\n", ops.ObservationReportTextArtifact)
|
||||
fmt.Fprintf(stdout, "read_only=true\n")
|
||||
|
||||
@@ -785,9 +787,11 @@ type helmValuesFile struct {
|
||||
Image helmValuesImage `yaml:"image"`
|
||||
CSIImage helmValuesImage `yaml:"csiImage"`
|
||||
AppNamespace string `yaml:"appNamespace"`
|
||||
Blockmaster *helmValuesBlockmaster `yaml:"blockmaster,omitempty"`
|
||||
StorageClass helmValuesStorageClass `yaml:"storageClass"`
|
||||
Replication helmValuesReplication `yaml:"replication"`
|
||||
Network helmValuesNetwork `yaml:"network"`
|
||||
Restart *helmValuesRestart `yaml:"restartPersistence,omitempty"`
|
||||
Compat helmValuesCompat `yaml:"compat"`
|
||||
CHAP helmValuesCHAP `yaml:"chap"`
|
||||
Stage2Multipath helmValuesEnabled `yaml:"stage2Multipath"`
|
||||
@@ -800,6 +804,15 @@ type helmValuesImage struct {
|
||||
Digest string `yaml:"digest"`
|
||||
}
|
||||
|
||||
type helmValuesBlockmaster struct {
|
||||
StateHostPath string `yaml:"stateHostPath,omitempty"`
|
||||
}
|
||||
|
||||
type helmValuesRestart struct {
|
||||
Mode string `yaml:"mode,omitempty"`
|
||||
StateHostPath string `yaml:"stateHostPath,omitempty"`
|
||||
}
|
||||
|
||||
type helmValuesStorageClass struct {
|
||||
Create bool `yaml:"create"`
|
||||
Name string `yaml:"name"`
|
||||
@@ -853,21 +866,23 @@ func runOpsGenerateHelmValues(args []string, stdout, stderr io.Writer) int {
|
||||
fs := flag.NewFlagSet("sw-block ops generate-helm-values", flag.ContinueOnError)
|
||||
fs.SetOutput(stderr)
|
||||
var (
|
||||
outPath string
|
||||
kubeconfig string
|
||||
image string
|
||||
csiImage string
|
||||
replicationFactor int
|
||||
ackProfile string
|
||||
storageClass string
|
||||
appNamespace string
|
||||
targetNode string
|
||||
nodeLimit int
|
||||
chapSecretName string
|
||||
chapUsername string
|
||||
chapSecret string
|
||||
stage2Multipath bool
|
||||
timeout time.Duration
|
||||
outPath string
|
||||
kubeconfig string
|
||||
image string
|
||||
csiImage string
|
||||
replicationFactor int
|
||||
ackProfile string
|
||||
storageClass string
|
||||
appNamespace string
|
||||
targetNode string
|
||||
nodeLimit int
|
||||
chapSecretName string
|
||||
chapUsername string
|
||||
chapSecret string
|
||||
stage2Multipath bool
|
||||
restartPersistence string
|
||||
stateHostPath string
|
||||
timeout time.Duration
|
||||
)
|
||||
fs.StringVar(&outPath, "out", "", "output Helm values.yaml path")
|
||||
fs.StringVar(&outPath, "o", "", "output Helm values.yaml path")
|
||||
@@ -884,6 +899,8 @@ func runOpsGenerateHelmValues(args []string, stdout, stderr io.Writer) int {
|
||||
fs.StringVar(&chapUsername, "chap-username", "sw-block", "iSCSI CHAP username")
|
||||
fs.StringVar(&chapSecret, "chap-secret", "", "iSCSI CHAP shared secret; generated when needed and omitted")
|
||||
fs.BoolVar(&stage2Multipath, "stage2-multipath", false, "enable Stage 2 multipath chart values")
|
||||
fs.StringVar(&restartPersistence, "restart-persistence", "ephemeral", "restart persistence mode: ephemeral or hostpath")
|
||||
fs.StringVar(&stateHostPath, "state-hostpath", "/var/lib/sw-block", "hostPath base used when --restart-persistence=hostpath")
|
||||
fs.DurationVar(&timeout, "timeout", 10*time.Second, "kubectl discovery timeout")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return ops.VolumeStatusExitInvalid
|
||||
@@ -904,6 +921,14 @@ func runOpsGenerateHelmValues(args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stderr, "sw-block ops generate-helm-values: --ack-profile=%q invalid; want best-effort, sync-quorum, or sync-all\n", ackProfile)
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
if !helmValuesRestartPersistenceAccepted(restartPersistence) {
|
||||
fmt.Fprintf(stderr, "sw-block ops generate-helm-values: --restart-persistence=%q invalid; want ephemeral or hostpath\n", restartPersistence)
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
if restartPersistence == "hostpath" && strings.TrimSpace(stateHostPath) == "" {
|
||||
fmt.Fprintln(stderr, "sw-block ops generate-helm-values: --state-hostpath is required when --restart-persistence=hostpath")
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
@@ -963,6 +988,11 @@ func runOpsGenerateHelmValues(args []string, stdout, stderr io.Writer) int {
|
||||
Stage2Multipath: helmValuesEnabled{Enabled: stage2Multipath},
|
||||
BlockNodes: make([]helmValuesBlockNode, 0, len(selected)),
|
||||
}
|
||||
values.Restart = &helmValuesRestart{Mode: restartPersistence}
|
||||
if restartPersistence == "hostpath" {
|
||||
values.Blockmaster = &helmValuesBlockmaster{StateHostPath: stateHostPath}
|
||||
values.Restart.StateHostPath = stateHostPath
|
||||
}
|
||||
for i, node := range selected {
|
||||
ip := node.InternalIP
|
||||
if !multiNode {
|
||||
@@ -1008,6 +1038,10 @@ func runOpsGenerateHelmValues(args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stdout, "chap_enabled=%t\n", multiNode)
|
||||
fmt.Fprintf(stdout, "replication_factor=%d\n", replicationFactor)
|
||||
fmt.Fprintf(stdout, "ack_profile=%s\n", ackProfile)
|
||||
fmt.Fprintf(stdout, "restart_persistence_mode=%s\n", restartPersistence)
|
||||
if restartPersistence == "hostpath" {
|
||||
fmt.Fprintf(stdout, "state_hostpath=%s\n", stateHostPath)
|
||||
}
|
||||
return ops.VolumeStatusExitOK
|
||||
}
|
||||
|
||||
@@ -1020,6 +1054,15 @@ func helmValuesAckProfileAccepted(value string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func helmValuesRestartPersistenceAccepted(value string) bool {
|
||||
switch value {
|
||||
case "ephemeral", "hostpath":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func selectHelmValuesNodes(raw, targetNode string, nodeLimit int) ([]kubernetesReadyNode, []kubernetesReadyNode, error) {
|
||||
discovered := parseKubectlWideReadyNodes(raw)
|
||||
if len(discovered) == 0 {
|
||||
@@ -1240,6 +1283,7 @@ func usage(w io.Writer) {
|
||||
fmt.Fprintln(w, " sw-block ops dashboard --from-bundle <dir> [--listen 127.0.0.1:9334]")
|
||||
fmt.Fprintln(w, " sw-block ops dashboard --master-api <addr> [--listen 127.0.0.1:9334]")
|
||||
fmt.Fprintln(w, " sw-block ops generate-helm-values --out values.yaml [--target-node <node>] [--replication-factor <n>]")
|
||||
fmt.Fprintln(w, " [--restart-persistence ephemeral|hostpath] [--state-hostpath /var/lib/sw-block] [--timeout 10s]")
|
||||
}
|
||||
|
||||
func emptyCLI(value string) string {
|
||||
|
||||
@@ -307,6 +307,7 @@ func TestOpsGenerateHelmValuesSingleNodeFromKubernetes(t *testing.T) {
|
||||
"ready_kubernetes_nodes=1",
|
||||
"discovered_kubernetes_nodes=3",
|
||||
"target_node=m02",
|
||||
"restart_persistence_mode=ephemeral",
|
||||
} {
|
||||
if !strings.Contains(stdout.String(), want) {
|
||||
t.Fatalf("stdout missing %q:\n%s", want, stdout.String())
|
||||
@@ -322,6 +323,8 @@ func TestOpsGenerateHelmValuesSingleNodeFromKubernetes(t *testing.T) {
|
||||
"externalISCSI: false",
|
||||
"externalStatus: false",
|
||||
"rejectLoopbackPublishTargets: false",
|
||||
"restartPersistence:",
|
||||
"mode: ephemeral",
|
||||
"expectedSlotsPerVolume: 1",
|
||||
"enabled: false",
|
||||
"name: m02",
|
||||
@@ -363,6 +366,7 @@ func TestOpsGenerateHelmValuesMultiNodeExternalISCSI(t *testing.T) {
|
||||
"external_iscsi=true",
|
||||
"chap_enabled=true",
|
||||
"ack_profile=sync-quorum",
|
||||
"restart_persistence_mode=ephemeral",
|
||||
} {
|
||||
if !strings.Contains(stdout.String(), want) {
|
||||
t.Fatalf("stdout missing %q:\n%s", want, stdout.String())
|
||||
@@ -379,6 +383,8 @@ func TestOpsGenerateHelmValuesMultiNodeExternalISCSI(t *testing.T) {
|
||||
"externalISCSI: true",
|
||||
"externalStatus: true",
|
||||
"rejectLoopbackPublishTargets: true",
|
||||
"restartPersistence:",
|
||||
"mode: ephemeral",
|
||||
"enabled: true",
|
||||
"secret: fixed-chap-secret",
|
||||
"name: m01",
|
||||
@@ -404,6 +410,65 @@ func TestOpsGenerateHelmValuesMultiNodeExternalISCSI(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpsGenerateHelmValuesRestartPersistenceHostPath(t *testing.T) {
|
||||
oldRunCommand := opsGenerateHelmValuesRunCommand
|
||||
opsGenerateHelmValuesRunCommand = fixtureCmdKubectl(map[string]string{
|
||||
"kubectl get nodes -o wide --no-headers": cmdHelmNodeWide,
|
||||
})
|
||||
defer func() { opsGenerateHelmValuesRunCommand = oldRunCommand }()
|
||||
|
||||
outPath := filepath.Join(t.TempDir(), "values.yaml")
|
||||
var stdout, stderr bytes.Buffer
|
||||
code := run([]string{
|
||||
"ops", "generate-helm-values",
|
||||
"--out", outPath,
|
||||
"--target-node", "m02",
|
||||
"--node-limit", "1",
|
||||
"--restart-persistence", "hostpath",
|
||||
"--state-hostpath", "/var/lib/sw-block",
|
||||
}, &stdout, &stderr)
|
||||
if code != ops.VolumeStatusExitOK {
|
||||
t.Fatalf("exit=%d stderr=%s stdout=%s", code, stderr.String(), stdout.String())
|
||||
}
|
||||
for _, want := range []string{
|
||||
"restart_persistence_mode=hostpath",
|
||||
"state_hostpath=/var/lib/sw-block",
|
||||
} {
|
||||
if !strings.Contains(stdout.String(), want) {
|
||||
t.Fatalf("stdout missing %q:\n%s", want, stdout.String())
|
||||
}
|
||||
}
|
||||
values, err := os.ReadFile(outPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, want := range []string{
|
||||
"blockmaster:",
|
||||
"stateHostPath: /var/lib/sw-block",
|
||||
"restartPersistence:",
|
||||
"mode: hostpath",
|
||||
} {
|
||||
if !strings.Contains(string(values), want) {
|
||||
t.Fatalf("values missing %q:\n%s", want, values)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpsGenerateHelmValuesRejectsUnknownRestartPersistence(t *testing.T) {
|
||||
var stdout, stderr bytes.Buffer
|
||||
code := run([]string{
|
||||
"ops", "generate-helm-values",
|
||||
"--out", filepath.Join(t.TempDir(), "values.yaml"),
|
||||
"--restart-persistence", "durable-magic",
|
||||
}, &stdout, &stderr)
|
||||
if code != ops.VolumeStatusExitInvalid {
|
||||
t.Fatalf("exit=%d want invalid stdout=%s stderr=%s", code, stdout.String(), stderr.String())
|
||||
}
|
||||
if !strings.Contains(stderr.String(), "--restart-persistence=\"durable-magic\" invalid") {
|
||||
t.Fatalf("stderr=%s", stderr.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpsGenerateHelmValuesRejectsRFAboveSelectedNodes(t *testing.T) {
|
||||
oldRunCommand := opsGenerateHelmValuesRunCommand
|
||||
opsGenerateHelmValuesRunCommand = fixtureCmdKubectl(map[string]string{
|
||||
@@ -477,6 +542,7 @@ func TestOpsReportFromBundleWritesStaticReadOnlyArtifacts(t *testing.T) {
|
||||
ops.ObservationReportHTMLArtifact,
|
||||
ops.ObservationReportJSONArtifact,
|
||||
ops.ObservationReportJSONLArtifact,
|
||||
ops.ObservationOperatorSnapshotArtifact,
|
||||
ops.ObservationReportTextArtifact,
|
||||
} {
|
||||
if _, err := os.Stat(filepath.Join(outDir, name)); err != nil {
|
||||
@@ -504,7 +570,9 @@ func TestOpsReportFromBundleWritesStaticReadOnlyArtifacts(t *testing.T) {
|
||||
if !strings.Contains(string(summary), "read_only=true") || !strings.Contains(string(summary), "volume=pvc-product") {
|
||||
t.Fatalf("summary missing report evidence:\n%s", summary)
|
||||
}
|
||||
if !strings.Contains(stdout.String(), "report_status=ok") || !strings.Contains(stdout.String(), "html=index.html") {
|
||||
if !strings.Contains(stdout.String(), "report_status=ok") ||
|
||||
!strings.Contains(stdout.String(), "html=index.html") ||
|
||||
!strings.Contains(stdout.String(), "operator_snapshot=operator-snapshot.json") {
|
||||
t.Fatalf("stdout missing report paths:\n%s", stdout.String())
|
||||
}
|
||||
}
|
||||
@@ -556,6 +624,10 @@ func TestOpsDashboardFromBundleServesReadOnlyHTTP(t *testing.T) {
|
||||
if !strings.Contains(body, "read_only=true") {
|
||||
t.Fatalf("summary missing read_only=true:\n%s", body)
|
||||
}
|
||||
snapshot := waitForHTTPContains(t, "http://"+addr+"/operator-snapshot.json", `"read_only": true`)
|
||||
if !strings.Contains(snapshot, `"mutation_allowed": false`) {
|
||||
t.Fatalf("operator snapshot missing read-only boundary:\n%s", snapshot)
|
||||
}
|
||||
postResp, err := http.Post("http://"+addr+"/", "application/json", strings.NewReader(`{"action":"promote"}`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -598,6 +670,10 @@ func TestOpsDashboardMasterAPIServesLiveClusterEvidence(t *testing.T) {
|
||||
if !strings.Contains(body, `"managed_volumes"`) {
|
||||
t.Fatalf("cluster evidence missing managed_volumes:\n%s", body)
|
||||
}
|
||||
snapshot := waitForHTTPContains(t, "http://"+addr+"/operator-snapshot.json", `"read_only": true`)
|
||||
if !strings.Contains(snapshot, `"api_version": "block.seaweedfs.com/v1alpha1"`) {
|
||||
t.Fatalf("operator snapshot missing api version:\n%s", snapshot)
|
||||
}
|
||||
|
||||
select {
|
||||
case code := <-done:
|
||||
|
||||
@@ -109,16 +109,20 @@ func (s *ObservationStore) SlotFact(volumeID, replicaID string) (SlotFact, bool)
|
||||
if slot.VolumeID != volumeID || slot.ReplicaID != replicaID {
|
||||
continue
|
||||
}
|
||||
if slotExpired(slot, obs, now) {
|
||||
continue
|
||||
}
|
||||
if slot.DataAddr == "" {
|
||||
// Fail-closed: an observation that names the slot but
|
||||
// without a usable DataAddr is unusable for primary
|
||||
// fan-out.
|
||||
continue
|
||||
}
|
||||
if !found || obs.ObservedAt.After(bestObsAt) {
|
||||
candidateObsAt := slotObservedAt(slot, obs)
|
||||
if !found || candidateObsAt.After(bestObsAt) {
|
||||
best = slot
|
||||
best.Frontends = append([]FrontendTargetFact(nil), slot.Frontends...)
|
||||
bestObsAt = obs.ObservedAt
|
||||
bestObsAt = candidateObsAt
|
||||
found = true
|
||||
}
|
||||
}
|
||||
@@ -193,6 +197,10 @@ func (s *ObservationStore) Ingest(obs Observation) error {
|
||||
// caller-supplied ExpiresAt to prevent out-of-band freshness
|
||||
// fabrication.
|
||||
obs.ExpiresAt = obs.ObservedAt.Add(s.config.FreshnessWindow)
|
||||
for i := range obs.Slots {
|
||||
obs.Slots[i].ObservedAt = obs.ObservedAt
|
||||
obs.Slots[i].ExpiresAt = obs.ExpiresAt
|
||||
}
|
||||
|
||||
var fn func()
|
||||
s.mu.Lock()
|
||||
@@ -211,6 +219,7 @@ func (s *ObservationStore) Ingest(obs Observation) error {
|
||||
s.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
obs.Slots = mergeServerSlots(prev.Slots, obs.Slots)
|
||||
}
|
||||
s.observations[obs.ServerID] = obs
|
||||
s.revision++
|
||||
@@ -223,6 +232,60 @@ func (s *ObservationStore) Ingest(obs Observation) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func mergeServerSlots(prev []SlotFact, next []SlotFact) []SlotFact {
|
||||
if len(prev) == 0 {
|
||||
return cloneSlots(next)
|
||||
}
|
||||
out := make([]SlotFact, 0, len(prev)+len(next))
|
||||
replaced := make(map[string]struct{}, len(next))
|
||||
for _, slot := range next {
|
||||
replaced[slotKey(slot)] = struct{}{}
|
||||
}
|
||||
for _, slot := range prev {
|
||||
if _, ok := replaced[slotKey(slot)]; ok {
|
||||
continue
|
||||
}
|
||||
out = append(out, cloneSlot(slot))
|
||||
}
|
||||
for _, slot := range next {
|
||||
out = append(out, cloneSlot(slot))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func slotKey(slot SlotFact) string {
|
||||
return slot.VolumeID + "\x00" + slot.ReplicaID
|
||||
}
|
||||
|
||||
func cloneSlots(in []SlotFact) []SlotFact {
|
||||
out := make([]SlotFact, 0, len(in))
|
||||
for _, slot := range in {
|
||||
out = append(out, cloneSlot(slot))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func cloneSlot(in SlotFact) SlotFact {
|
||||
out := in
|
||||
out.Frontends = append([]FrontendTargetFact(nil), in.Frontends...)
|
||||
return out
|
||||
}
|
||||
|
||||
func slotExpired(slot SlotFact, obs Observation, now time.Time) bool {
|
||||
expiresAt := slot.ExpiresAt
|
||||
if expiresAt.IsZero() {
|
||||
expiresAt = obs.ExpiresAt
|
||||
}
|
||||
return !expiresAt.IsZero() && now.After(expiresAt)
|
||||
}
|
||||
|
||||
func slotObservedAt(slot SlotFact, obs Observation) time.Time {
|
||||
if !slot.ObservedAt.IsZero() {
|
||||
return slot.ObservedAt
|
||||
}
|
||||
return obs.ObservedAt
|
||||
}
|
||||
|
||||
// storeSnapshot is the immutable per-call value consumed by the
|
||||
// snapshot builder. It deliberately DOES NOT reference the live
|
||||
// store; the builder operates on this value alone. This is the
|
||||
|
||||
@@ -82,6 +82,89 @@ func TestObservationStore_SlotFact_LatestObservationWins(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservationStore_SlotFact_MergesDistinctSlotsFromSameServer(t *testing.T) {
|
||||
t0 := time.Date(2026, 5, 22, 12, 0, 0, 0, time.UTC)
|
||||
now := t0
|
||||
s := NewObservationStore(FreshnessConfig{FreshnessWindow: 30 * time.Second}, func() time.Time { return now })
|
||||
|
||||
if err := s.Ingest(Observation{
|
||||
ServerID: "m01",
|
||||
ObservedAt: t0,
|
||||
Slots: []SlotFact{{VolumeID: "v1", ReplicaID: "r1", DataAddr: "10.0.0.1:19101"}},
|
||||
}); err != nil {
|
||||
t.Fatalf("ingest v1: %v", err)
|
||||
}
|
||||
if err := s.Ingest(Observation{
|
||||
ServerID: "m01",
|
||||
ObservedAt: t0.Add(time.Second),
|
||||
Slots: []SlotFact{{VolumeID: "v2", ReplicaID: "r1", DataAddr: "10.0.0.1:19103"}},
|
||||
}); err != nil {
|
||||
t.Fatalf("ingest v2: %v", err)
|
||||
}
|
||||
|
||||
if got, ok := s.SlotFact("v1", "r1"); !ok || got.DataAddr != "10.0.0.1:19101" {
|
||||
t.Fatalf("v1 SlotFact=(%+v,%v), want preserved v1 slot after v2 heartbeat", got, ok)
|
||||
}
|
||||
if got, ok := s.SlotFact("v2", "r1"); !ok || got.DataAddr != "10.0.0.1:19103" {
|
||||
t.Fatalf("v2 SlotFact=(%+v,%v), want v2 slot", got, ok)
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservationStore_SlotFact_MergedSlotExpiresIndependently(t *testing.T) {
|
||||
t0 := time.Date(2026, 5, 22, 12, 0, 0, 0, time.UTC)
|
||||
now := t0
|
||||
s := NewObservationStore(FreshnessConfig{FreshnessWindow: 10 * time.Second}, func() time.Time { return now })
|
||||
|
||||
_ = s.Ingest(Observation{
|
||||
ServerID: "m01",
|
||||
ObservedAt: t0,
|
||||
Slots: []SlotFact{{VolumeID: "v1", ReplicaID: "r1", DataAddr: "10.0.0.1:19101"}},
|
||||
})
|
||||
_ = s.Ingest(Observation{
|
||||
ServerID: "m01",
|
||||
ObservedAt: t0.Add(9 * time.Second),
|
||||
Slots: []SlotFact{{VolumeID: "v2", ReplicaID: "r1", DataAddr: "10.0.0.1:19103"}},
|
||||
})
|
||||
|
||||
now = t0.Add(11 * time.Second)
|
||||
if got, ok := s.SlotFact("v1", "r1"); ok {
|
||||
t.Fatalf("v1 after independent expiry: ok=true got %+v; want false", got)
|
||||
}
|
||||
if got, ok := s.SlotFact("v2", "r1"); !ok || got.DataAddr != "10.0.0.1:19103" {
|
||||
t.Fatalf("v2 after v1 expiry=(%+v,%v), want still fresh", got, ok)
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservationStore_SlotFact_UsesMergedSlotObservationTime(t *testing.T) {
|
||||
t0 := time.Date(2026, 5, 22, 12, 0, 0, 0, time.UTC)
|
||||
now := t0.Add(10 * time.Second)
|
||||
s := NewObservationStore(FreshnessConfig{FreshnessWindow: time.Hour}, func() time.Time { return now })
|
||||
|
||||
_ = s.Ingest(Observation{
|
||||
ServerID: "m01",
|
||||
ObservedAt: t0,
|
||||
Slots: []SlotFact{{VolumeID: "v1", ReplicaID: "r1", DataAddr: "OLD:1"}},
|
||||
})
|
||||
_ = s.Ingest(Observation{
|
||||
ServerID: "m01",
|
||||
ObservedAt: t0.Add(10 * time.Second),
|
||||
Slots: []SlotFact{{VolumeID: "v2", ReplicaID: "r1", DataAddr: "OTHER:1"}},
|
||||
})
|
||||
_ = s.Ingest(Observation{
|
||||
ServerID: "m02",
|
||||
ObservedAt: t0.Add(5 * time.Second),
|
||||
Slots: []SlotFact{{VolumeID: "v1", ReplicaID: "r1", DataAddr: "NEW:1"}},
|
||||
})
|
||||
|
||||
got, ok := s.SlotFact("v1", "r1")
|
||||
if !ok {
|
||||
t.Fatal("SlotFact: ok=false")
|
||||
}
|
||||
if got.DataAddr != "NEW:1" {
|
||||
t.Fatalf("DataAddr=%q want NEW:1; carried-forward old slot must not inherit m01's newer heartbeat time", got.DataAddr)
|
||||
}
|
||||
}
|
||||
|
||||
// TestObservationStore_SlotFact_ExpiredObservation_FailsClosed pins
|
||||
// architect round 54 finding-1: expired heartbeat addrs MUST NOT be
|
||||
// used for live replication peer construction. Observation stays
|
||||
|
||||
@@ -20,6 +20,7 @@ import "time"
|
||||
// - an instruction to the authority layer
|
||||
// - an epoch or EndpointVersion proposal
|
||||
// - a "promote me" flag
|
||||
//
|
||||
// The observation institution records observations; it does not
|
||||
// interpret them as authority. (Load-bearing: sketch §3.)
|
||||
type Observation struct {
|
||||
@@ -53,6 +54,13 @@ type SlotFact struct {
|
||||
Eligible bool
|
||||
Withdrawn bool
|
||||
EvidenceScore uint64
|
||||
// ObservedAt/ExpiresAt are store-owned per-slot freshness
|
||||
// markers. They let one Kubernetes node run multiple
|
||||
// blockvolume processes that each report a different slot
|
||||
// without their heartbeats overwriting or refreshing each
|
||||
// other's safety window.
|
||||
ObservedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
// LocalRoleClaim is what the reporting server thinks its own
|
||||
// role is right now. Recorded as raw fact only; never
|
||||
// interpreted as authority. Two servers both claiming
|
||||
|
||||
@@ -74,8 +74,11 @@ func BuildSnapshot(store storeSnapshot, topology AcceptedTopology, reader Author
|
||||
continue
|
||||
}
|
||||
for _, s := range obs.Slots {
|
||||
if slotExpired(s, obs, store.evaluatedAt) {
|
||||
continue
|
||||
}
|
||||
freshSlotsByVolume[s.VolumeID] = append(freshSlotsByVolume[s.VolumeID],
|
||||
slotWithServer{slot: s, serverID: obs.ServerID, observedAt: obs.ObservedAt})
|
||||
slotWithServer{slot: s, serverID: obs.ServerID, observedAt: slotObservedAt(s, obs)})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,27 @@ func TestStatusFrontendsForAssignedVolume_DedupesRepeatedFacts(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatusFrontendsForAssignedVolume_PreservesMultipleVolumesOnSameServer(t *testing.T) {
|
||||
obs := authority.NewObservationHost(authority.ObservationHostConfig{})
|
||||
for _, hb := range []authority.HeartbeatMessage{
|
||||
frontendHeartbeat("node-a", "v1", "r1", "127.0.0.1:3260"),
|
||||
frontendHeartbeat("node-a", "v2", "r1", "127.0.0.1:3261"),
|
||||
} {
|
||||
if err := obs.IngestHeartbeat(hb); err != nil {
|
||||
t.Fatalf("ingest heartbeat: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
gotV1 := statusFrontendsForAssignedVolume(obs, "v1", []string{"r1"}, true)
|
||||
if len(gotV1) != 1 || gotV1[0].GetAddr() != "127.0.0.1:3260" {
|
||||
t.Fatalf("v1 frontends=%+v, want first heartbeat preserved", gotV1)
|
||||
}
|
||||
gotV2 := statusFrontendsForAssignedVolume(obs, "v2", []string{"r1"}, true)
|
||||
if len(gotV2) != 1 || gotV2[0].GetAddr() != "127.0.0.1:3261" {
|
||||
t.Fatalf("v2 frontends=%+v, want second heartbeat", gotV2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNodeLoss_PrimaryFirstReplicaIDsMovesPromotedReplicaFirst(t *testing.T) {
|
||||
got := primaryFirstReplicaIDs([]string{"r1", "r2", "r3"}, "r2")
|
||||
want := []string{"r2", "r1", "r3"}
|
||||
|
||||
@@ -33,8 +33,13 @@ func (h *Host) RunLifecycleWorkloadPlanTick(cfg lifecycle.WorkloadPlanConfig) (L
|
||||
volumeByID[volume.Spec.VolumeID] = volume
|
||||
}
|
||||
nodes := stores.Nodes.ListNodes()
|
||||
type pendingPlan struct {
|
||||
placement lifecycle.PlacementIntent
|
||||
plan lifecycle.BlockVolumeWorkloadPlan
|
||||
materialize bool
|
||||
}
|
||||
var result LifecycleWorkloadPlanTickResult
|
||||
portAllocator := newWorkloadPortAllocator()
|
||||
var pending []pendingPlan
|
||||
for _, placement := range stores.Placements.ListPlacements() {
|
||||
volume, ok := volumeByID[placement.VolumeID]
|
||||
if !ok {
|
||||
@@ -46,11 +51,22 @@ func (h *Host) RunLifecycleWorkloadPlanTick(cfg lifecycle.WorkloadPlanConfig) (L
|
||||
result.SkippedMissingInventory++
|
||||
continue
|
||||
}
|
||||
portAllocator.assign(&plan)
|
||||
result.Plans = append(result.Plans, plan)
|
||||
pending = append(pending, pendingPlan{
|
||||
placement: placement,
|
||||
plan: plan,
|
||||
materialize: placementHasBlankPool(placement),
|
||||
})
|
||||
result.PlannedVolumes++
|
||||
if placementHasBlankPool(placement) {
|
||||
materialized, err := lifecycle.MaterializePlacementFromWorkloadPlan(placement, plan)
|
||||
}
|
||||
plans := make([]*lifecycle.BlockVolumeWorkloadPlan, 0, len(pending))
|
||||
for i := range pending {
|
||||
plans = append(plans, &pending[i].plan)
|
||||
}
|
||||
newWorkloadPortAllocator().assignAll(plans)
|
||||
for _, item := range pending {
|
||||
result.Plans = append(result.Plans, item.plan)
|
||||
if item.materialize {
|
||||
materialized, err := lifecycle.MaterializePlacementFromWorkloadPlan(item.placement, item.plan)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
@@ -66,6 +82,10 @@ func (h *Host) RunLifecycleWorkloadPlanTick(cfg lifecycle.WorkloadPlanConfig) (L
|
||||
type workloadPortAllocator struct {
|
||||
nextOrdinalByNode map[string]int
|
||||
baseByNode map[string]nodePortBase
|
||||
usedISCSIByNode map[string]map[int]bool
|
||||
usedNVMeByNode map[string]map[int]bool
|
||||
usedDataByNode map[string]map[string]bool
|
||||
usedCtrlByNode map[string]map[string]bool
|
||||
}
|
||||
|
||||
type nodePortBase struct {
|
||||
@@ -79,35 +99,117 @@ func newWorkloadPortAllocator() *workloadPortAllocator {
|
||||
return &workloadPortAllocator{
|
||||
nextOrdinalByNode: make(map[string]int),
|
||||
baseByNode: make(map[string]nodePortBase),
|
||||
usedISCSIByNode: make(map[string]map[int]bool),
|
||||
usedNVMeByNode: make(map[string]map[int]bool),
|
||||
usedDataByNode: make(map[string]map[string]bool),
|
||||
usedCtrlByNode: make(map[string]map[string]bool),
|
||||
}
|
||||
}
|
||||
|
||||
func (a *workloadPortAllocator) assign(plan *lifecycle.BlockVolumeWorkloadPlan) {
|
||||
if a == nil || plan == nil {
|
||||
a.assignAll([]*lifecycle.BlockVolumeWorkloadPlan{plan})
|
||||
}
|
||||
|
||||
func (a *workloadPortAllocator) assignAll(plans []*lifecycle.BlockVolumeWorkloadPlan) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
for i := range plan.Replicas {
|
||||
replica := &plan.Replicas[i]
|
||||
key := replica.KubernetesNodeName
|
||||
if key == "" {
|
||||
key = replica.ServerID
|
||||
for _, plan := range plans {
|
||||
if plan == nil {
|
||||
continue
|
||||
}
|
||||
base, ok := a.baseByNode[key]
|
||||
if !ok {
|
||||
base = nodePortBase{
|
||||
iscsi: replica.ISCSIListenPort - i,
|
||||
nvme: replica.NVMeListenPort - i,
|
||||
data: replica.DataAddr,
|
||||
ctrl: replica.CtrlAddr,
|
||||
for i := range plan.Replicas {
|
||||
replica := &plan.Replicas[i]
|
||||
key := workloadNodeKey(*replica)
|
||||
a.ensureNode(key)
|
||||
if _, ok := a.baseByNode[key]; !ok {
|
||||
a.baseByNode[key] = nodePortBase{
|
||||
iscsi: replica.ISCSIListenPort - i,
|
||||
nvme: replica.NVMeListenPort - i,
|
||||
data: addPortOffset(replica.DataAddr, -i*2),
|
||||
ctrl: addPortOffset(replica.CtrlAddr, -i*2),
|
||||
}
|
||||
}
|
||||
if replica.PortAssignmentPinned {
|
||||
a.markUsed(key, *replica)
|
||||
}
|
||||
a.baseByNode[key] = base
|
||||
}
|
||||
ordinal := a.nextOrdinalByNode[key]
|
||||
a.nextOrdinalByNode[key] = ordinal + 1
|
||||
replica.ISCSIListenPort = base.iscsi + ordinal
|
||||
replica.NVMeListenPort = base.nvme + ordinal
|
||||
replica.DataAddr = addPortOffset(base.data, ordinal*2)
|
||||
replica.CtrlAddr = addPortOffset(base.ctrl, ordinal*2)
|
||||
}
|
||||
for _, plan := range plans {
|
||||
if plan == nil {
|
||||
continue
|
||||
}
|
||||
for i := range plan.Replicas {
|
||||
replica := &plan.Replicas[i]
|
||||
if replica.PortAssignmentPinned {
|
||||
continue
|
||||
}
|
||||
key := workloadNodeKey(*replica)
|
||||
a.ensureNode(key)
|
||||
base, ok := a.baseByNode[key]
|
||||
if !ok {
|
||||
base = nodePortBase{
|
||||
iscsi: replica.ISCSIListenPort - i,
|
||||
nvme: replica.NVMeListenPort - i,
|
||||
data: addPortOffset(replica.DataAddr, -i*2),
|
||||
ctrl: addPortOffset(replica.CtrlAddr, -i*2),
|
||||
}
|
||||
a.baseByNode[key] = base
|
||||
}
|
||||
ordinal := a.nextFreeOrdinal(key, base)
|
||||
a.nextOrdinalByNode[key] = ordinal + 1
|
||||
replica.ISCSIListenPort = base.iscsi + ordinal
|
||||
replica.NVMeListenPort = base.nvme + ordinal
|
||||
replica.DataAddr = addPortOffset(base.data, ordinal*2)
|
||||
replica.CtrlAddr = addPortOffset(base.ctrl, ordinal*2)
|
||||
a.markUsed(key, *replica)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func workloadNodeKey(replica lifecycle.BlockVolumeReplicaWorkload) string {
|
||||
if replica.KubernetesNodeName != "" {
|
||||
return replica.KubernetesNodeName
|
||||
}
|
||||
return replica.ServerID
|
||||
}
|
||||
|
||||
func (a *workloadPortAllocator) ensureNode(key string) {
|
||||
if a.usedISCSIByNode[key] == nil {
|
||||
a.usedISCSIByNode[key] = make(map[int]bool)
|
||||
a.usedNVMeByNode[key] = make(map[int]bool)
|
||||
a.usedDataByNode[key] = make(map[string]bool)
|
||||
a.usedCtrlByNode[key] = make(map[string]bool)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *workloadPortAllocator) markUsed(key string, replica lifecycle.BlockVolumeReplicaWorkload) {
|
||||
a.ensureNode(key)
|
||||
if replica.ISCSIListenPort != 0 {
|
||||
a.usedISCSIByNode[key][replica.ISCSIListenPort] = true
|
||||
}
|
||||
if replica.NVMeListenPort != 0 {
|
||||
a.usedNVMeByNode[key][replica.NVMeListenPort] = true
|
||||
}
|
||||
if replica.DataAddr != "" {
|
||||
a.usedDataByNode[key][replica.DataAddr] = true
|
||||
}
|
||||
if replica.CtrlAddr != "" {
|
||||
a.usedCtrlByNode[key][replica.CtrlAddr] = true
|
||||
}
|
||||
}
|
||||
|
||||
func (a *workloadPortAllocator) nextFreeOrdinal(key string, base nodePortBase) int {
|
||||
for ordinal := a.nextOrdinalByNode[key]; ; ordinal++ {
|
||||
data := addPortOffset(base.data, ordinal*2)
|
||||
ctrl := addPortOffset(base.ctrl, ordinal*2)
|
||||
if a.usedISCSIByNode[key][base.iscsi+ordinal] ||
|
||||
a.usedNVMeByNode[key][base.nvme+ordinal] ||
|
||||
a.usedDataByNode[key][data] ||
|
||||
a.usedCtrlByNode[key][ctrl] {
|
||||
continue
|
||||
}
|
||||
return ordinal
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,11 +245,15 @@ func placementPlanFromIntent(intent lifecycle.PlacementIntent) lifecycle.Placeme
|
||||
}
|
||||
for _, slot := range intent.Slots {
|
||||
plan.Candidates = append(plan.Candidates, lifecycle.PlacementCandidate{
|
||||
VolumeID: intent.VolumeID,
|
||||
ServerID: slot.ServerID,
|
||||
PoolID: slot.PoolID,
|
||||
ReplicaID: slot.ReplicaID,
|
||||
Source: slot.Source,
|
||||
VolumeID: intent.VolumeID,
|
||||
ServerID: slot.ServerID,
|
||||
PoolID: slot.PoolID,
|
||||
ReplicaID: slot.ReplicaID,
|
||||
Source: slot.Source,
|
||||
DataAddr: slot.DataAddr,
|
||||
CtrlAddr: slot.CtrlAddr,
|
||||
ISCSIListenPort: slot.ISCSIListenPort,
|
||||
NVMeListenPort: slot.NVMeListenPort,
|
||||
})
|
||||
}
|
||||
return plan
|
||||
|
||||
@@ -126,6 +126,88 @@ func TestG15d_WorkloadPlanTickAllocatesDistinctNodeLocalPortsAcrossVolumes(t *te
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15d_WorkloadPlanTickPreservesMaterializedPortsWhenVolumeIDsSortEarlier(t *testing.T) {
|
||||
h := newTestMaster(t, t.TempDir())
|
||||
defer closeTestMaster(t, h)
|
||||
stores := h.Lifecycle()
|
||||
if _, err := stores.Volumes.CreateVolume(lifecycle.VolumeSpec{
|
||||
VolumeID: "pvc-c",
|
||||
SizeBytes: 1 << 20,
|
||||
ReplicationFactor: 1,
|
||||
}); err != nil {
|
||||
t.Fatalf("create first volume: %v", err)
|
||||
}
|
||||
if _, err := stores.Nodes.RegisterNode(lifecycle.NodeRegistration{
|
||||
ServerID: "m02",
|
||||
DataAddr: "127.0.0.1:19101",
|
||||
CtrlAddr: "127.0.0.1:19102",
|
||||
Pools: []lifecycle.StoragePool{{
|
||||
PoolID: "default",
|
||||
TotalBytes: 1 << 30,
|
||||
FreeBytes: 1 << 30,
|
||||
BlockSize: 4096,
|
||||
}},
|
||||
}); err != nil {
|
||||
t.Fatalf("register node: %v", err)
|
||||
}
|
||||
if _, err := h.RunLifecycleProductTick(); err != nil {
|
||||
t.Fatalf("product tick: %v", err)
|
||||
}
|
||||
firstResult, err := h.RunLifecycleWorkloadPlanTick(lifecycle.WorkloadPlanConfig{
|
||||
ISCSIPortBase: 3260,
|
||||
NVMePortBase: 4420,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("first workload tick: %v", err)
|
||||
}
|
||||
if got := firstResult.Plans[0].Replicas[0].ISCSIListenPort; got != 3260 {
|
||||
t.Fatalf("first volume port=%d want 3260", got)
|
||||
}
|
||||
|
||||
for _, volumeID := range []string{"pvc-a", "pvc-b"} {
|
||||
if _, err := stores.Volumes.CreateVolume(lifecycle.VolumeSpec{
|
||||
VolumeID: volumeID,
|
||||
SizeBytes: 1 << 20,
|
||||
ReplicationFactor: 1,
|
||||
}); err != nil {
|
||||
t.Fatalf("create later volume %s: %v", volumeID, err)
|
||||
}
|
||||
}
|
||||
if _, err := h.RunLifecycleProductTick(); err != nil {
|
||||
t.Fatalf("second product tick: %v", err)
|
||||
}
|
||||
secondResult, err := h.RunLifecycleWorkloadPlanTick(lifecycle.WorkloadPlanConfig{
|
||||
ISCSIPortBase: 3260,
|
||||
NVMePortBase: 4420,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("second workload tick: %v", err)
|
||||
}
|
||||
portsByVolume := map[string]int{}
|
||||
dataByVolume := map[string]string{}
|
||||
for _, plan := range secondResult.Plans {
|
||||
portsByVolume[plan.VolumeID] = plan.Replicas[0].ISCSIListenPort
|
||||
dataByVolume[plan.VolumeID] = plan.Replicas[0].DataAddr
|
||||
}
|
||||
if portsByVolume["pvc-c"] != 3260 {
|
||||
t.Fatalf("materialized pvc-c port moved to %d; want preserved 3260", portsByVolume["pvc-c"])
|
||||
}
|
||||
seenPorts := map[int]string{}
|
||||
seenData := map[string]string{}
|
||||
for volumeID, port := range portsByVolume {
|
||||
if prior := seenPorts[port]; prior != "" {
|
||||
t.Fatalf("duplicate port %d for %s and %s: %+v", port, prior, volumeID, portsByVolume)
|
||||
}
|
||||
seenPorts[port] = volumeID
|
||||
}
|
||||
for volumeID, data := range dataByVolume {
|
||||
if prior := seenData[data]; prior != "" {
|
||||
t.Fatalf("duplicate data addr %s for %s and %s: %+v", data, prior, volumeID, dataByVolume)
|
||||
}
|
||||
seenData[data] = volumeID
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountedFailover_WorkloadPlanSupportsLogicalServersOnOneKubernetesNode(t *testing.T) {
|
||||
h := newTestMaster(t, t.TempDir())
|
||||
defer closeTestMaster(t, h)
|
||||
|
||||
@@ -118,6 +118,11 @@ func (h *Host) submitPlacementSnapshots(placements []lifecycle.PlacementIntent)
|
||||
}
|
||||
build := authority.BuildSnapshot(h.obs.Store().Snapshot(), topology, h.Publisher())
|
||||
probeCount, blockedCount, directAsks := h.applyPromotionEvidenceGate(&build.Snapshot)
|
||||
supported := supportedSnapshotVolumes(build.Snapshot)
|
||||
unsupportedProbeCount, unsupportedBlockedCount, unsupportedDirectAsks := h.applyUnsupportedPromotionEvidenceGate(placements, build.Report, supported)
|
||||
probeCount += unsupportedProbeCount
|
||||
blockedCount += unsupportedBlockedCount
|
||||
directAsks = append(directAsks, unsupportedDirectAsks...)
|
||||
return true, probeCount, blockedCount, directAsks, h.ctrl.SubmitObservedState(build.Snapshot, build.Report)
|
||||
}
|
||||
|
||||
@@ -201,6 +206,132 @@ func (h *Host) applyPromotionEvidenceGate(snap *authority.ClusterSnapshot) (int,
|
||||
return probeCount, blockedCount, directAsks
|
||||
}
|
||||
|
||||
func (h *Host) applyUnsupportedPromotionEvidenceGate(placements []lifecycle.PlacementIntent, report authority.SupportabilityReport, supported map[string]bool) (int, int, []authority.AssignmentAsk) {
|
||||
if len(report.Unsupported) == 0 {
|
||||
return 0, 0, nil
|
||||
}
|
||||
probeCount, blockedCount := 0, 0
|
||||
var directAsks []authority.AssignmentAsk
|
||||
for _, placement := range placements {
|
||||
if supported[placement.VolumeID] || len(placement.Slots) < 3 || !placementIsConcreteExistingReplica(placement) {
|
||||
continue
|
||||
}
|
||||
evidence, ok := report.Unsupported[placement.VolumeID]
|
||||
if !ok || !unsupportedReasonsAllowPromotionProbe(evidence.Reasons) {
|
||||
continue
|
||||
}
|
||||
current, ok := h.Publisher().VolumeAuthorityLine(placement.VolumeID)
|
||||
if !ok || !current.Assigned {
|
||||
continue
|
||||
}
|
||||
vol, ok := topologyFromUnsupportedPlacement(placement, current)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
currentIdx := replicaIndex(vol.Slots, current.ReplicaID)
|
||||
if currentIdx < 0 {
|
||||
continue
|
||||
}
|
||||
candidates := make([]authority.ReplicaCandidate, 0, len(vol.Slots)-1)
|
||||
for _, slot := range vol.Slots {
|
||||
if slot.ReplicaID != current.ReplicaID {
|
||||
candidates = append(candidates, slot)
|
||||
}
|
||||
}
|
||||
probeCount++
|
||||
result, probeOK := h.probePromotionCandidates(vol.VolumeID, current, candidates)
|
||||
allowed := promotionAllowedReplicas(result, probeOK)
|
||||
if probeOK {
|
||||
h.log.Printf("blockmaster: promotion gate unsupported volume=%s current=%s reasons=%v current_known=%t current_ready=%t ack_profile=%s required_lsn=%d candidates=%v allowed=%v",
|
||||
vol.VolumeID, current.ReplicaID, evidence.Reasons, result.CurrentKnown, result.Current.Ready, result.AckProfile, result.SyncAckLSN, result.Candidates, allowed)
|
||||
h.recordPromotionEvaluationEvents(vol.VolumeID, result, allowed)
|
||||
} else {
|
||||
h.log.Printf("blockmaster: promotion gate unsupported volume=%s current=%s probe_unavailable reasons=%v", vol.VolumeID, current.ReplicaID, evidence.Reasons)
|
||||
h.recordPromotionProbeUnavailableEvent(vol.VolumeID, current.ReplicaID)
|
||||
}
|
||||
enabledCandidate := false
|
||||
for _, slot := range vol.Slots {
|
||||
if slot.ReplicaID != current.ReplicaID && allowed[slot.ReplicaID] {
|
||||
enabledCandidate = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if enabledCandidate && (!result.CurrentKnown || !result.Current.Ready) {
|
||||
if target, ok := chooseAllowedPromotionTarget(vol, result, allowed); ok {
|
||||
h.log.Printf("blockmaster: promotion gate unsupported volume=%s direct_reassign=%s current=%s", vol.VolumeID, target.ReplicaID, current.ReplicaID)
|
||||
directAsks = append(directAsks, authority.AssignmentAsk{
|
||||
VolumeID: vol.VolumeID,
|
||||
ReplicaID: target.ReplicaID,
|
||||
DataAddr: target.DataAddr,
|
||||
CtrlAddr: target.CtrlAddr,
|
||||
Intent: authority.IntentReassign,
|
||||
})
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !enabledCandidate {
|
||||
blockedCount++
|
||||
h.recordVolumeBlockedEvent(vol.VolumeID, ops.ReasonNoPromotionReadyCandidate)
|
||||
}
|
||||
}
|
||||
return probeCount, blockedCount, directAsks
|
||||
}
|
||||
|
||||
func supportedSnapshotVolumes(snap authority.ClusterSnapshot) map[string]bool {
|
||||
out := make(map[string]bool, len(snap.Volumes))
|
||||
for _, volume := range snap.Volumes {
|
||||
out[volume.VolumeID] = true
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func unsupportedReasonsAllowPromotionProbe(reasons []string) bool {
|
||||
if len(reasons) == 0 {
|
||||
return false
|
||||
}
|
||||
for _, reason := range reasons {
|
||||
switch reason {
|
||||
case authority.ReasonPartialInventory, authority.ReasonMissingServerObservation, authority.ReasonStaleObservation:
|
||||
continue
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func topologyFromUnsupportedPlacement(placement lifecycle.PlacementIntent, current authority.AuthorityBasis) (authority.VolumeTopologySnapshot, bool) {
|
||||
vol := authority.VolumeTopologySnapshot{
|
||||
VolumeID: placement.VolumeID,
|
||||
Authority: current,
|
||||
Slots: make([]authority.ReplicaCandidate, 0, len(placement.Slots)),
|
||||
}
|
||||
for _, slot := range placement.Slots {
|
||||
dataAddr := slot.DataAddr
|
||||
ctrlAddr := slot.CtrlAddr
|
||||
if slot.ReplicaID == current.ReplicaID {
|
||||
if dataAddr == "" {
|
||||
dataAddr = current.DataAddr
|
||||
}
|
||||
if ctrlAddr == "" {
|
||||
ctrlAddr = current.CtrlAddr
|
||||
}
|
||||
}
|
||||
if dataAddr == "" || ctrlAddr == "" {
|
||||
return authority.VolumeTopologySnapshot{}, false
|
||||
}
|
||||
vol.Slots = append(vol.Slots, authority.ReplicaCandidate{
|
||||
ReplicaID: slot.ReplicaID,
|
||||
ServerID: slot.ServerID,
|
||||
DataAddr: dataAddr,
|
||||
CtrlAddr: ctrlAddr,
|
||||
Reachable: true,
|
||||
Eligible: true,
|
||||
})
|
||||
}
|
||||
return vol, true
|
||||
}
|
||||
|
||||
func (h *Host) recordPlacementVerifiedEvents(placements []lifecycle.VerifiedPlacement) {
|
||||
for _, placement := range placements {
|
||||
if !placement.Verified {
|
||||
|
||||
@@ -240,7 +240,7 @@ func TestMountedFailover_ProductLoopRF3BlocksHealthyCurrentRebalanceWithoutProbe
|
||||
if err != nil {
|
||||
t.Fatalf("rebalance product tick: %v", err)
|
||||
}
|
||||
if result.PromotionProbes != 1 || result.PromotionBlocked != 1 {
|
||||
if result.PromotionProbes != 2 || result.PromotionBlocked != 2 {
|
||||
t.Fatalf("result=%+v want RF3 rebalance candidates blocked without probe", result)
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
@@ -544,6 +544,57 @@ func TestMountedFailover_ProductLoopRF3ProbeCanAuthorizeStaleHeartbeatReadiness(
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountedFailover_ProductLoopRF3PromotesWhenCurrentSlotMissingButSurvivorProbeReady(t *testing.T) {
|
||||
h := newTestMasterWithControllerConfig(t, t.TempDir(), authority.TopologyControllerConfig{
|
||||
ExpectedSlotsPerVolume: 3,
|
||||
})
|
||||
defer closeTestMaster(t, h)
|
||||
h.SetPromotionEvidenceProvider(staticPromotionProbe{
|
||||
result: PromotionProbeResult{
|
||||
AckProfile: "sync-quorum",
|
||||
Candidates: []PromotionCandidateEvidence{
|
||||
{ReplicaID: "r2", Ready: true, DurableLSN: 70},
|
||||
{ReplicaID: "r3", Ready: true, DurableLSN: 90},
|
||||
},
|
||||
},
|
||||
})
|
||||
seedRF3PlacementForServersWithAddrs(t, h, "vol-rf3", "node-a", "node-b", "node-c")
|
||||
ingestRF3Observation(t, h, true, true, true)
|
||||
|
||||
if _, err := h.RunLifecycleProductTick(); err != nil {
|
||||
t.Fatalf("initial product tick: %v", err)
|
||||
}
|
||||
initial := waitAuthorityLine(t, h.Publisher(), "vol-rf3")
|
||||
if initial.ReplicaID != "r1" {
|
||||
t.Fatalf("initial line=%+v want r1", initial)
|
||||
}
|
||||
|
||||
// K8s can keep the server/node fresh while the generated primary
|
||||
// blockvolume pod is gone. That produces PartialInventory and excludes
|
||||
// the volume from the normal supported snapshot; the product loop must
|
||||
// still use placement + probe evidence to promote an eligible survivor.
|
||||
ingestRF3PartialInventoryMissingCurrent(t, h, "vol-rf3", "node-a", "node-b", "node-c")
|
||||
placements := h.Lifecycle().Placements.ListPlacements()
|
||||
report := authority.SupportabilityReport{Unsupported: map[string]authority.VolumeUnsupportedEvidence{
|
||||
"vol-rf3": {VolumeID: "vol-rf3", Reasons: []string{authority.ReasonPartialInventory}},
|
||||
}}
|
||||
probes, blocked, asks := h.applyUnsupportedPromotionEvidenceGate(placements, report, nil)
|
||||
if probes != 1 || blocked != 0 || len(asks) != 1 {
|
||||
line, _ := h.Publisher().VolumeAuthorityLine("vol-rf3")
|
||||
t.Fatalf("probes=%d blocked=%d asks=%+v placements=%+v line=%+v want one direct unsupported promotion ask", probes, blocked, asks, placements, line)
|
||||
}
|
||||
if asks[0].ReplicaID != "r3" || asks[0].Intent != authority.IntentReassign {
|
||||
t.Fatalf("ask=%+v want highest durable survivor r3 reassign", asks[0])
|
||||
}
|
||||
if err := h.ctrl.SubmitAssignmentAsk(asks[0]); err != nil {
|
||||
t.Fatalf("submit unsupported promotion ask: %v", err)
|
||||
}
|
||||
failover := waitAuthorityReplica(t, h.Publisher(), "vol-rf3", "r3")
|
||||
if failover.Epoch != 2 || failover.EndpointVersion != 1 {
|
||||
t.Fatalf("failover line=%+v want highest durable survivor r3@2/1", failover)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMountedFailover_ProductLoopRF3RejectsBestEffortProbeForHA(t *testing.T) {
|
||||
h := newTestMasterWithControllerConfig(t, t.TempDir(), authority.TopologyControllerConfig{
|
||||
ExpectedSlotsPerVolume: 3,
|
||||
@@ -819,6 +870,22 @@ func seedRF3PlacementForServers(t *testing.T, h *Host, volumeID, r1ServerID, r2S
|
||||
}
|
||||
}
|
||||
|
||||
func seedRF3PlacementForServersWithAddrs(t *testing.T, h *Host, volumeID, r1ServerID, r2ServerID, r3ServerID string) {
|
||||
t.Helper()
|
||||
stores := h.Lifecycle()
|
||||
if _, err := stores.Placements.ApplyPlan(lifecycle.PlacementPlan{
|
||||
VolumeID: volumeID,
|
||||
DesiredRF: 3,
|
||||
Candidates: []lifecycle.PlacementCandidate{
|
||||
{VolumeID: volumeID, ServerID: r1ServerID, ReplicaID: "r1", Source: lifecycle.PlacementSourceExistingReplica, DataAddr: "127.0.0.1:19101", CtrlAddr: "127.0.0.1:19102"},
|
||||
{VolumeID: volumeID, ServerID: r2ServerID, ReplicaID: "r2", Source: lifecycle.PlacementSourceExistingReplica, DataAddr: "127.0.0.1:19201", CtrlAddr: "127.0.0.1:19202"},
|
||||
{VolumeID: volumeID, ServerID: r3ServerID, ReplicaID: "r3", Source: lifecycle.PlacementSourceExistingReplica, DataAddr: "127.0.0.1:19301", CtrlAddr: "127.0.0.1:19302"},
|
||||
},
|
||||
}); err != nil {
|
||||
t.Fatalf("apply RF3 placement with addrs: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func ingestRF3ObservationForServers(t *testing.T, h *Host, volumeID, r1ServerID, r2ServerID, r3ServerID string, r1Ready, r2Ready, r3Ready bool) {
|
||||
t.Helper()
|
||||
ingestRF3ObservationForServersWithReady(t, h, volumeID, r1ServerID, r2ServerID, r3ServerID,
|
||||
@@ -860,6 +927,54 @@ func ingestRF3ObservationForServersWithReady(t *testing.T, h *Host, volumeID, r1
|
||||
}
|
||||
}
|
||||
|
||||
func ingestRF3PartialInventoryMissingCurrent(t *testing.T, h *Host, volumeID, r1ServerID, r2ServerID, r3ServerID string) {
|
||||
t.Helper()
|
||||
now := time.Now().UTC()
|
||||
observations := []authority.Observation{
|
||||
{
|
||||
ServerID: r1ServerID,
|
||||
ObservedAt: now,
|
||||
Server: authority.ServerFact{Reachable: true, Eligible: true},
|
||||
Slots: nil,
|
||||
},
|
||||
{
|
||||
ServerID: r2ServerID,
|
||||
ObservedAt: now,
|
||||
Server: authority.ServerFact{Reachable: true, Eligible: true},
|
||||
Slots: []authority.SlotFact{{
|
||||
VolumeID: volumeID,
|
||||
ReplicaID: "r2",
|
||||
DataAddr: "127.0.0.1:19201",
|
||||
CtrlAddr: "127.0.0.1:19202",
|
||||
Reachable: true,
|
||||
ReadyForPrimary: true,
|
||||
Eligible: true,
|
||||
EvidenceScore: 20,
|
||||
}},
|
||||
},
|
||||
{
|
||||
ServerID: r3ServerID,
|
||||
ObservedAt: now,
|
||||
Server: authority.ServerFact{Reachable: true, Eligible: true},
|
||||
Slots: []authority.SlotFact{{
|
||||
VolumeID: volumeID,
|
||||
ReplicaID: "r3",
|
||||
DataAddr: "127.0.0.1:19301",
|
||||
CtrlAddr: "127.0.0.1:19302",
|
||||
Reachable: true,
|
||||
ReadyForPrimary: true,
|
||||
Eligible: true,
|
||||
EvidenceScore: 10,
|
||||
}},
|
||||
},
|
||||
}
|
||||
for _, obs := range observations {
|
||||
if err := h.ObservationHost().Ingest(obs); err != nil {
|
||||
t.Fatalf("ingest RF3 partial inventory observation: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type staticPromotionProbe struct {
|
||||
result PromotionProbeResult
|
||||
err error
|
||||
|
||||
@@ -16,10 +16,14 @@ var ErrInsufficientPlacementCandidates = errors.New("lifecycle: insufficient pla
|
||||
// placement plan. It is still not authority: no epoch, no endpoint version,
|
||||
// no readiness.
|
||||
type PlacementSlotIntent struct {
|
||||
ServerID string `json:"server_id"`
|
||||
PoolID string `json:"pool_id,omitempty"`
|
||||
ReplicaID string `json:"replica_id,omitempty"`
|
||||
Source string `json:"source"`
|
||||
ServerID string `json:"server_id"`
|
||||
PoolID string `json:"pool_id,omitempty"`
|
||||
ReplicaID string `json:"replica_id,omitempty"`
|
||||
Source string `json:"source"`
|
||||
DataAddr string `json:"data_addr,omitempty"`
|
||||
CtrlAddr string `json:"ctrl_addr,omitempty"`
|
||||
ISCSIListenPort int `json:"iscsi_listen_port,omitempty"`
|
||||
NVMeListenPort int `json:"nvme_listen_port,omitempty"`
|
||||
}
|
||||
|
||||
// PlacementIntent is durable controller input for one volume.
|
||||
@@ -67,10 +71,14 @@ func (s *PlacementIntentStore) ApplyPlan(plan PlacementPlan) (PlacementIntent, e
|
||||
}
|
||||
for _, candidate := range plan.Candidates[:plan.DesiredRF] {
|
||||
intent.Slots = append(intent.Slots, PlacementSlotIntent{
|
||||
ServerID: candidate.ServerID,
|
||||
PoolID: candidate.PoolID,
|
||||
ReplicaID: candidate.ReplicaID,
|
||||
Source: candidate.Source,
|
||||
ServerID: candidate.ServerID,
|
||||
PoolID: candidate.PoolID,
|
||||
ReplicaID: candidate.ReplicaID,
|
||||
Source: candidate.Source,
|
||||
DataAddr: candidate.DataAddr,
|
||||
CtrlAddr: candidate.CtrlAddr,
|
||||
ISCSIListenPort: candidate.ISCSIListenPort,
|
||||
NVMeListenPort: candidate.NVMeListenPort,
|
||||
})
|
||||
}
|
||||
if err := validatePlacementIntent(intent); err != nil {
|
||||
@@ -203,6 +211,12 @@ func validatePlacementIntent(intent PlacementIntent) error {
|
||||
if seenServers[slot.ServerID] {
|
||||
return fmt.Errorf("%w: duplicate server %s", ErrInvalidVolumeSpec, slot.ServerID)
|
||||
}
|
||||
if err := validateOptionalPort("iscsi_listen_port", slot.ISCSIListenPort); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateOptionalPort("nvme_listen_port", slot.NVMeListenPort); err != nil {
|
||||
return err
|
||||
}
|
||||
seenServers[slot.ServerID] = true
|
||||
switch slot.Source {
|
||||
case PlacementSourceBlankPool:
|
||||
@@ -223,6 +237,13 @@ func validatePlacementIntent(intent PlacementIntent) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateOptionalPort(name string, port int) error {
|
||||
if port < 0 || port > 65535 {
|
||||
return fmt.Errorf("%w: %s %d outside 0..65535", ErrInvalidVolumeSpec, name, port)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func copyPlacementIntent(in PlacementIntent) PlacementIntent {
|
||||
out := in
|
||||
out.Slots = append([]PlacementSlotIntent(nil), in.Slots...)
|
||||
|
||||
@@ -13,11 +13,15 @@ const (
|
||||
// PlacementCandidate is planner output. It is a candidate for future
|
||||
// controller action, not an assignment and not readiness.
|
||||
type PlacementCandidate struct {
|
||||
VolumeID string
|
||||
ServerID string
|
||||
PoolID string
|
||||
ReplicaID string
|
||||
Source string
|
||||
VolumeID string
|
||||
ServerID string
|
||||
PoolID string
|
||||
ReplicaID string
|
||||
Source string
|
||||
DataAddr string
|
||||
CtrlAddr string
|
||||
ISCSIListenPort int
|
||||
NVMeListenPort int
|
||||
}
|
||||
|
||||
// PlacementConflict records inventory that blocks automatic placement.
|
||||
|
||||
@@ -72,6 +72,12 @@ func VerifyPlacementIntent(intent PlacementIntent, nodes []NodeRegistration, cfg
|
||||
return out
|
||||
}
|
||||
dataAddr, ctrlAddr := nodePlacementAddrs(node)
|
||||
if slot.DataAddr != "" {
|
||||
dataAddr = slot.DataAddr
|
||||
}
|
||||
if slot.CtrlAddr != "" {
|
||||
ctrlAddr = slot.CtrlAddr
|
||||
}
|
||||
if dataAddr == "" || ctrlAddr == "" {
|
||||
out.Reason = VerifyReasonMissingAddress
|
||||
return out
|
||||
|
||||
@@ -60,6 +60,40 @@ func TestG9F_VerifiedPlacement_IsNotAuthorityShaped(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestG15d_VerifiedPlacementUsesMaterializedWorkloadAddresses(t *testing.T) {
|
||||
now := time.Date(2026, 5, 2, 12, 0, 0, 0, time.UTC)
|
||||
intent := PlacementIntent{
|
||||
VolumeID: "vol-a",
|
||||
DesiredRF: 1,
|
||||
Slots: []PlacementSlotIntent{{
|
||||
ServerID: "node-a",
|
||||
ReplicaID: "r1",
|
||||
Source: PlacementSourceExistingReplica,
|
||||
DataAddr: "10.0.0.1:19103",
|
||||
CtrlAddr: "10.0.0.1:19104",
|
||||
}},
|
||||
}
|
||||
got := VerifyPlacementIntent(intent, []NodeRegistration{{
|
||||
ServerID: "node-a",
|
||||
DataAddr: "10.0.0.1:19101",
|
||||
CtrlAddr: "10.0.0.1:19102",
|
||||
SeenAt: now,
|
||||
Replicas: []ReplicaInventory{{
|
||||
VolumeID: "vol-a",
|
||||
ReplicaID: "r1",
|
||||
StoreUUID: "store-1",
|
||||
SizeBytes: 1 << 20,
|
||||
State: "ready",
|
||||
}},
|
||||
}}, VerificationConfig{Now: now, FreshnessWindow: time.Minute})
|
||||
if !got.Verified {
|
||||
t.Fatalf("materialized placement did not verify: %+v", got)
|
||||
}
|
||||
if got.Slots[0].DataAddr != "10.0.0.1:19103" || got.Slots[0].CtrlAddr != "10.0.0.1:19104" {
|
||||
t.Fatalf("verified addrs=%s/%s want materialized slot addrs", got.Slots[0].DataAddr, got.Slots[0].CtrlAddr)
|
||||
}
|
||||
}
|
||||
|
||||
func TestG9F_BlankPoolIntentWithFreshObservation_VerifiesCreateNeededSlot(t *testing.T) {
|
||||
now := time.Date(2026, 5, 2, 12, 0, 0, 0, time.UTC)
|
||||
intent := PlacementIntent{
|
||||
@@ -119,6 +153,37 @@ func TestG9F_FreshObservationMissingControlAddress_DoesNotVerify(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlacementIntentRejectsInvalidPersistedPorts(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
slot PlacementSlotIntent
|
||||
}{
|
||||
{
|
||||
name: "iscsi negative",
|
||||
slot: PlacementSlotIntent{ServerID: "node-a", PoolID: "pool-a", Source: PlacementSourceBlankPool, ISCSIListenPort: -1},
|
||||
},
|
||||
{
|
||||
name: "iscsi too high",
|
||||
slot: PlacementSlotIntent{ServerID: "node-a", PoolID: "pool-a", Source: PlacementSourceBlankPool, ISCSIListenPort: 70000},
|
||||
},
|
||||
{
|
||||
name: "nvme negative",
|
||||
slot: PlacementSlotIntent{ServerID: "node-a", PoolID: "pool-a", Source: PlacementSourceBlankPool, NVMeListenPort: -1},
|
||||
},
|
||||
{
|
||||
name: "nvme too high",
|
||||
slot: PlacementSlotIntent{ServerID: "node-a", PoolID: "pool-a", Source: PlacementSourceBlankPool, NVMeListenPort: 70000},
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err := validatePlacementIntent(PlacementIntent{VolumeID: "vol-a", DesiredRF: 1, Slots: []PlacementSlotIntent{tc.slot}})
|
||||
if err == nil {
|
||||
t.Fatal("expected invalid port to be rejected")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestG9F_ExistingReplicaIntentWithWrongInventory_DoesNotVerify(t *testing.T) {
|
||||
now := time.Date(2026, 5, 2, 12, 0, 0, 0, time.UTC)
|
||||
intent := PlacementIntent{
|
||||
|
||||
@@ -29,6 +29,10 @@ func MaterializePlacementFromWorkloadPlan(placement PlacementIntent, plan BlockV
|
||||
}
|
||||
slot.ReplicaID = replica.ReplicaID
|
||||
slot.Source = PlacementSourceExistingReplica
|
||||
slot.DataAddr = replica.DataAddr
|
||||
slot.CtrlAddr = replica.CtrlAddr
|
||||
slot.ISCSIListenPort = replica.ISCSIListenPort
|
||||
slot.NVMeListenPort = replica.NVMeListenPort
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
@@ -19,18 +19,19 @@ type BlockVolumeWorkloadPlan struct {
|
||||
}
|
||||
|
||||
type BlockVolumeReplicaWorkload struct {
|
||||
ServerID string
|
||||
KubernetesNodeName string
|
||||
PoolID string
|
||||
ReplicaID string
|
||||
Source string
|
||||
DataAddr string
|
||||
CtrlAddr string
|
||||
ISCSIListenPort int
|
||||
ISCSIQualifiedName string
|
||||
NVMeListenPort int
|
||||
NVMeSubsystemNQN string
|
||||
NVMeNSID int
|
||||
ServerID string
|
||||
KubernetesNodeName string
|
||||
PoolID string
|
||||
ReplicaID string
|
||||
Source string
|
||||
PortAssignmentPinned bool
|
||||
DataAddr string
|
||||
CtrlAddr string
|
||||
ISCSIListenPort int
|
||||
ISCSIQualifiedName string
|
||||
NVMeListenPort int
|
||||
NVMeSubsystemNQN string
|
||||
NVMeNSID int
|
||||
}
|
||||
|
||||
// PlanBlockVolumeWorkloads converts desired lifecycle state plus placement
|
||||
@@ -86,19 +87,39 @@ func PlanBlockVolumeWorkloads(volume VolumeRecord, placement PlacementIntent, no
|
||||
replicaID = fmt.Sprintf("r%d", i+1)
|
||||
}
|
||||
dataAddr, ctrlAddr := nodePlacementAddrs(node)
|
||||
portAssignmentPinned := false
|
||||
iscsiListenPort := cfg.ISCSIPortBase + i
|
||||
nvmeListenPort := cfg.NVMePortBase + i
|
||||
if slot.DataAddr != "" {
|
||||
dataAddr = slot.DataAddr
|
||||
portAssignmentPinned = true
|
||||
}
|
||||
if slot.CtrlAddr != "" {
|
||||
ctrlAddr = slot.CtrlAddr
|
||||
portAssignmentPinned = true
|
||||
}
|
||||
if slot.ISCSIListenPort != 0 {
|
||||
iscsiListenPort = slot.ISCSIListenPort
|
||||
portAssignmentPinned = true
|
||||
}
|
||||
if slot.NVMeListenPort != 0 {
|
||||
nvmeListenPort = slot.NVMeListenPort
|
||||
portAssignmentPinned = true
|
||||
}
|
||||
out.Replicas = append(out.Replicas, BlockVolumeReplicaWorkload{
|
||||
ServerID: slot.ServerID,
|
||||
KubernetesNodeName: kubernetesNodeName(node),
|
||||
PoolID: slot.PoolID,
|
||||
ReplicaID: replicaID,
|
||||
Source: slot.Source,
|
||||
DataAddr: dataAddr,
|
||||
CtrlAddr: ctrlAddr,
|
||||
ISCSIListenPort: cfg.ISCSIPortBase + i,
|
||||
ISCSIQualifiedName: fmt.Sprintf("%s:%s", cfg.IQNPrefix, volume.Spec.VolumeID),
|
||||
NVMeListenPort: cfg.NVMePortBase + i,
|
||||
NVMeSubsystemNQN: fmt.Sprintf("%s:%s", cfg.NQNPrefix, volume.Spec.VolumeID),
|
||||
NVMeNSID: 1,
|
||||
ServerID: slot.ServerID,
|
||||
KubernetesNodeName: kubernetesNodeName(node),
|
||||
PoolID: slot.PoolID,
|
||||
ReplicaID: replicaID,
|
||||
Source: slot.Source,
|
||||
PortAssignmentPinned: portAssignmentPinned,
|
||||
DataAddr: dataAddr,
|
||||
CtrlAddr: ctrlAddr,
|
||||
ISCSIListenPort: iscsiListenPort,
|
||||
ISCSIQualifiedName: fmt.Sprintf("%s:%s", cfg.IQNPrefix, volume.Spec.VolumeID),
|
||||
NVMeListenPort: nvmeListenPort,
|
||||
NVMeSubsystemNQN: fmt.Sprintf("%s:%s", cfg.NQNPrefix, volume.Spec.VolumeID),
|
||||
NVMeNSID: 1,
|
||||
})
|
||||
}
|
||||
return out, nil
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
CleanupSummaryStatusKey = "cleanup_status"
|
||||
CleanupSummaryKubernetesResidueKey = "k8s_residue_count"
|
||||
CleanupSummaryISCSIResidueKey = "iscsi_residue_count"
|
||||
CleanupSummaryMultipathResidueKey = "multipath_residue_count"
|
||||
CleanupSummaryProcessResidueKey = "process_residue_count"
|
||||
CleanupSummaryHostPathResidueKey = "hostpath_residue_count"
|
||||
CleanupSummaryFailureKey = "failure_count"
|
||||
CleanupSummaryFailedPhaseKey = "failed_phase"
|
||||
CleanupSummaryReasonCodesKey = "reason_codes"
|
||||
CleanupSummaryEvidenceKey = "cleanup_evidence"
|
||||
)
|
||||
|
||||
type CleanupEvidenceReportRow struct {
|
||||
Status string
|
||||
KubernetesResidueCount int
|
||||
ISCSIResidueCount int
|
||||
MultipathResidueCount int
|
||||
ProcessResidueCount int
|
||||
HostPathResidueCount int
|
||||
FailureCount int
|
||||
EvidenceRef string
|
||||
StatusClass string
|
||||
}
|
||||
|
||||
func CleanupEvidenceFromSummary(summary map[string]string, evidencePath string) *CleanupEvidence {
|
||||
if len(summary) == 0 {
|
||||
return nil
|
||||
}
|
||||
cleanup := &CleanupEvidence{
|
||||
Status: defaultString(summary[CleanupSummaryStatusKey], ObservationStatusUnavailable),
|
||||
EvidenceRef: evidencePath,
|
||||
}
|
||||
cleanup.KubernetesResidueCount = cleanupIntFromSummary(summary, CleanupSummaryKubernetesResidueKey)
|
||||
cleanup.ISCSIResidueCount = cleanupIntFromSummary(summary, CleanupSummaryISCSIResidueKey)
|
||||
cleanup.MultipathResidueCount = cleanupIntFromSummary(summary, CleanupSummaryMultipathResidueKey)
|
||||
cleanup.ProcessResidueCount = cleanupIntFromSummary(summary, CleanupSummaryProcessResidueKey)
|
||||
cleanup.HostPathResidueCount = cleanupIntFromSummary(summary, CleanupSummaryHostPathResidueKey)
|
||||
cleanup.FailureCount = cleanupIntFromSummary(summary, CleanupSummaryFailureKey)
|
||||
cleanup.FailedPhase = summary[CleanupSummaryFailedPhaseKey]
|
||||
if reasons := strings.TrimSpace(summary[CleanupSummaryReasonCodesKey]); reasons != "" {
|
||||
for _, reason := range strings.Split(reasons, ",") {
|
||||
reason = strings.TrimSpace(reason)
|
||||
if reason != "" {
|
||||
cleanup.ReasonCodes = append(cleanup.ReasonCodes, reason)
|
||||
}
|
||||
}
|
||||
}
|
||||
return cleanup
|
||||
}
|
||||
|
||||
func (cleanup CleanupEvidence) ReportSummaryLines() []string {
|
||||
lines := []string{
|
||||
fmt.Sprintf("%s=%s", CleanupSummaryStatusKey, emptyAsDash(cleanup.Status)),
|
||||
fmt.Sprintf("%s=%d", CleanupSummaryKubernetesResidueKey, cleanup.KubernetesResidueCount),
|
||||
fmt.Sprintf("%s=%d", CleanupSummaryISCSIResidueKey, cleanup.ISCSIResidueCount),
|
||||
fmt.Sprintf("%s=%d", CleanupSummaryMultipathResidueKey, cleanup.MultipathResidueCount),
|
||||
fmt.Sprintf("%s=%d", CleanupSummaryProcessResidueKey, cleanup.ProcessResidueCount),
|
||||
fmt.Sprintf("%s=%d", CleanupSummaryHostPathResidueKey, cleanup.HostPathResidueCount),
|
||||
fmt.Sprintf("%s=%d", CleanupSummaryFailureKey, cleanup.FailureCount),
|
||||
}
|
||||
if cleanup.FailedPhase != "" {
|
||||
lines = append(lines, fmt.Sprintf("%s=%s", CleanupSummaryFailedPhaseKey, cleanup.FailedPhase))
|
||||
}
|
||||
if cleanup.EvidenceRef != "" {
|
||||
lines = append(lines, fmt.Sprintf("%s=%s", CleanupSummaryEvidenceKey, cleanup.EvidenceRef))
|
||||
}
|
||||
return lines
|
||||
}
|
||||
|
||||
func (cleanup CleanupEvidence) ReportRow() CleanupEvidenceReportRow {
|
||||
class := "ok"
|
||||
if cleanup.Status != ObservationStatusOK || cleanup.FailureCount > 0 {
|
||||
class = "bad"
|
||||
}
|
||||
return CleanupEvidenceReportRow{
|
||||
Status: emptyAsDash(cleanup.Status),
|
||||
KubernetesResidueCount: cleanup.KubernetesResidueCount,
|
||||
ISCSIResidueCount: cleanup.ISCSIResidueCount,
|
||||
MultipathResidueCount: cleanup.MultipathResidueCount,
|
||||
ProcessResidueCount: cleanup.ProcessResidueCount,
|
||||
HostPathResidueCount: cleanup.HostPathResidueCount,
|
||||
FailureCount: cleanup.FailureCount,
|
||||
EvidenceRef: emptyAsDash(cleanup.EvidenceRef),
|
||||
StatusClass: class,
|
||||
}
|
||||
}
|
||||
|
||||
func cleanupIntFromSummary(summary map[string]string, key string) int {
|
||||
value := strings.TrimSpace(summary[key])
|
||||
if value == "" {
|
||||
return 0
|
||||
}
|
||||
parsed, err := strconv.Atoi(value)
|
||||
if err != nil || parsed < 0 {
|
||||
return 0
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCleanupEvidenceProjectionOwnsSummaryAndReportShape(t *testing.T) {
|
||||
cleanup := CleanupEvidenceFromSummary(map[string]string{
|
||||
CleanupSummaryStatusKey: "failed",
|
||||
CleanupSummaryKubernetesResidueKey: "1",
|
||||
CleanupSummaryISCSIResidueKey: "2",
|
||||
CleanupSummaryMultipathResidueKey: "3",
|
||||
CleanupSummaryProcessResidueKey: "4",
|
||||
CleanupSummaryHostPathResidueKey: "5",
|
||||
CleanupSummaryFailureKey: "6",
|
||||
CleanupSummaryFailedPhaseKey: "collect_and_cleanup",
|
||||
CleanupSummaryReasonCodesKey: "k8s_residue,multipath_residue",
|
||||
}, "cleanup-summary.txt")
|
||||
|
||||
if cleanup == nil {
|
||||
t.Fatal("cleanup evidence is nil")
|
||||
}
|
||||
if cleanup.Status != "failed" ||
|
||||
cleanup.KubernetesResidueCount != 1 ||
|
||||
cleanup.ISCSIResidueCount != 2 ||
|
||||
cleanup.MultipathResidueCount != 3 ||
|
||||
cleanup.ProcessResidueCount != 4 ||
|
||||
cleanup.HostPathResidueCount != 5 ||
|
||||
cleanup.FailureCount != 6 ||
|
||||
cleanup.FailedPhase != "collect_and_cleanup" ||
|
||||
cleanup.EvidenceRef != "cleanup-summary.txt" {
|
||||
t.Fatalf("cleanup evidence=%+v", cleanup)
|
||||
}
|
||||
if len(cleanup.ReasonCodes) != 2 || cleanup.ReasonCodes[1] != "multipath_residue" {
|
||||
t.Fatalf("reason codes=%+v", cleanup.ReasonCodes)
|
||||
}
|
||||
|
||||
lines := strings.Join(cleanup.ReportSummaryLines(), "\n")
|
||||
for _, want := range []string{
|
||||
"cleanup_status=failed",
|
||||
"k8s_residue_count=1",
|
||||
"iscsi_residue_count=2",
|
||||
"multipath_residue_count=3",
|
||||
"process_residue_count=4",
|
||||
"hostpath_residue_count=5",
|
||||
"failure_count=6",
|
||||
"failed_phase=collect_and_cleanup",
|
||||
"cleanup_evidence=cleanup-summary.txt",
|
||||
} {
|
||||
if !strings.Contains(lines, want) {
|
||||
t.Fatalf("summary lines missing %q:\n%s", want, lines)
|
||||
}
|
||||
}
|
||||
|
||||
row := cleanup.ReportRow()
|
||||
if row.StatusClass != "bad" || row.Status != "failed" || row.EvidenceRef != "cleanup-summary.txt" {
|
||||
t.Fatalf("row=%+v", row)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupEvidenceProjectionMarksCleanStatusOK(t *testing.T) {
|
||||
cleanup := CleanupEvidence{
|
||||
Status: ObservationStatusOK,
|
||||
}
|
||||
row := cleanup.ReportRow()
|
||||
if row.StatusClass != "ok" {
|
||||
t.Fatalf("row=%+v", row)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupEvidenceRejectsNegativeCounters(t *testing.T) {
|
||||
cleanup := CleanupEvidenceFromSummary(map[string]string{
|
||||
CleanupSummaryStatusKey: "failed",
|
||||
CleanupSummaryKubernetesResidueKey: "-1",
|
||||
CleanupSummaryFailureKey: "-2",
|
||||
}, "cleanup-summary.txt")
|
||||
if cleanup.KubernetesResidueCount != 0 || cleanup.FailureCount != 0 {
|
||||
t.Fatalf("negative counters should parse as zero, got %+v", cleanup)
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,30 @@ func TestManagedVolumeProjection_RecoveredConditionForTransparentFailover(t *tes
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeProjection_EvidenceStaleIsNotReady(t *testing.T) {
|
||||
projection := ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-stale",
|
||||
EvidenceStale: true,
|
||||
EvidenceStaleReason: ReasonEvidenceStale,
|
||||
EvidenceRefs: []string{"product/unreachable.txt"},
|
||||
})
|
||||
|
||||
ready := findObservationCondition(projection.Conditions, "Ready")
|
||||
stale := findObservationCondition(projection.Conditions, "EvidenceStale")
|
||||
if ready == nil || stale == nil {
|
||||
t.Fatalf("conditions=%+v", projection.Conditions)
|
||||
}
|
||||
if ready.Status != "Unknown" || ready.Reason != ReasonEvidenceStale {
|
||||
t.Fatalf("ready=%+v", ready)
|
||||
}
|
||||
if stale.Status != "True" || stale.Severity != "warning" || stale.Reason != ReasonEvidenceStale {
|
||||
t.Fatalf("stale=%+v", stale)
|
||||
}
|
||||
if projection.Status != ManagedVolumeStatusUnknown || projection.ReasonCode != ReasonEvidenceStale {
|
||||
t.Fatalf("projection=%+v", projection)
|
||||
}
|
||||
}
|
||||
|
||||
func findObservationCondition(conditions []ObservationCondition, conditionType string) *ObservationCondition {
|
||||
for i := range conditions {
|
||||
if conditions[i].Type == conditionType {
|
||||
|
||||
@@ -0,0 +1,440 @@
|
||||
package ops
|
||||
|
||||
const (
|
||||
ManagedVolumeFieldStable = "stable"
|
||||
ManagedVolumeFieldProvisional = "provisional"
|
||||
ManagedVolumeFieldTestOnly = "test_only"
|
||||
|
||||
FactAggregationPassive = "passive"
|
||||
FactAggregationProbe = "bounded_probe"
|
||||
FactAggregationDual = "passive_plus_bounded_probe"
|
||||
|
||||
FactAuthorityKubernetesObject = "kubernetes_object_authority"
|
||||
FactAuthorityPlacement = "placement_authority"
|
||||
FactAuthorityAuthorityLine = "authority_line_authority"
|
||||
FactAuthorityReplicaDurability = "replica_durability_authority"
|
||||
FactAuthorityCSIAttach = "csi_attach_authority"
|
||||
FactAuthorityHostPath = "host_path_authority"
|
||||
FactAuthorityWorkloadEvidence = "workload_evidence_authority"
|
||||
FactAuthorityCleanup = "cleanup_authority"
|
||||
FactAuthorityObservation = "observation_authority"
|
||||
|
||||
MasterEngine = "engine_master"
|
||||
MasterManagedVolume = "managed_volume_master"
|
||||
|
||||
ActionPolicyReadOnly = "read_only"
|
||||
ActionPolicyDryRun = "dry_run"
|
||||
ActionPolicyDisabled = "disabled_until_operator_policy"
|
||||
)
|
||||
|
||||
type ManagedVolumeFactContractEntry struct {
|
||||
Path string `json:"path"`
|
||||
Stability string `json:"stability"`
|
||||
Participant string `json:"participant"`
|
||||
FactAuthority string `json:"fact_authority"`
|
||||
Master string `json:"master"`
|
||||
AggregationMode string `json:"aggregation_mode"`
|
||||
ProbeAllowed bool `json:"probe_allowed"`
|
||||
ProbeTrigger string `json:"probe_trigger,omitempty"`
|
||||
ConditionSurface string `json:"condition_surface,omitempty"`
|
||||
EvidenceRequired string `json:"evidence_required"`
|
||||
}
|
||||
|
||||
type ManagedVolumeActionContractEntry struct {
|
||||
Type string `json:"type"`
|
||||
Master string `json:"master"`
|
||||
Mode string `json:"mode"`
|
||||
SideEffectClass string `json:"side_effect_class"`
|
||||
OwnerExecutor string `json:"owner_executor"`
|
||||
PolicyGate string `json:"policy_gate"`
|
||||
RequiredFacts []string `json:"required_facts,omitempty"`
|
||||
InvariantRefs []string `json:"invariant_refs,omitempty"`
|
||||
EvidenceRequired string `json:"evidence_required"`
|
||||
MutationAllowed bool `json:"mutation_allowed"`
|
||||
}
|
||||
|
||||
func ManagedVolumeFactContract() []ManagedVolumeFactContractEntry {
|
||||
return []ManagedVolumeFactContractEntry{
|
||||
{
|
||||
Path: "identity.namespace",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "kubernetes_watcher",
|
||||
FactAuthority: FactAuthorityKubernetesObject,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "metadata",
|
||||
EvidenceRequired: "pvc_or_pv_object",
|
||||
},
|
||||
{
|
||||
Path: "identity.pvc_name",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "kubernetes_watcher",
|
||||
FactAuthority: FactAuthorityKubernetesObject,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "metadata",
|
||||
EvidenceRequired: "pvc_object",
|
||||
},
|
||||
{
|
||||
Path: "identity.volume_id",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "kubernetes_watcher_or_inventory",
|
||||
FactAuthority: FactAuthorityKubernetesObject,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "metadata",
|
||||
EvidenceRequired: "pv_handle_or_inventory_volume_id",
|
||||
},
|
||||
{
|
||||
Path: "desired.replication_factor",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "storageclass_or_helm_values_reader",
|
||||
FactAuthority: FactAuthorityKubernetesObject,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "metadata/Ready/Blocked",
|
||||
EvidenceRequired: "storageclass_parameter_or_helm_values",
|
||||
},
|
||||
{
|
||||
Path: "desired.ack_profile",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "storageclass_or_helm_values_reader",
|
||||
FactAuthority: FactAuthorityKubernetesObject,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "metadata/Ready/Blocked",
|
||||
EvidenceRequired: "storageclass_parameter_or_helm_values",
|
||||
},
|
||||
{
|
||||
Path: "desired.claim_profile",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "storageclass_or_scenario_contract",
|
||||
FactAuthority: FactAuthorityObservation,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "metadata/non_claims",
|
||||
EvidenceRequired: "claim_profile_artifact_or_release_contract",
|
||||
},
|
||||
{
|
||||
Path: "desired.protocol",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "storageclass_or_helm_values_reader",
|
||||
FactAuthority: FactAuthorityKubernetesObject,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "metadata/Ready/Blocked",
|
||||
EvidenceRequired: "storageclass_parameter_or_helm_values",
|
||||
},
|
||||
{
|
||||
Path: "kubernetes.pvc_phase",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "kubernetes_watcher",
|
||||
FactAuthority: FactAuthorityKubernetesObject,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationDual,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "pvc_pending_or_first_volume_timeout",
|
||||
ConditionSurface: "Ready/Blocked",
|
||||
EvidenceRequired: "pvc_status_or_kubectl_describe",
|
||||
},
|
||||
{
|
||||
Path: "placement.replica_node",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "launcher_or_operator",
|
||||
FactAuthority: FactAuthorityPlacement,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "Ready/Degraded/Blocked",
|
||||
EvidenceRequired: "launcher_plan_or_generated_deployment",
|
||||
},
|
||||
{
|
||||
Path: "authority.primary_replica",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "blockmaster_authority",
|
||||
FactAuthority: FactAuthorityAuthorityLine,
|
||||
Master: MasterEngine,
|
||||
AggregationMode: FactAggregationDual,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "primary_missing_or_promotion_decision",
|
||||
ConditionSurface: "Ready/Recovering/Blocked",
|
||||
EvidenceRequired: "authority_event_or_inventory_primary",
|
||||
},
|
||||
{
|
||||
Path: "authority.epoch",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "blockmaster_authority",
|
||||
FactAuthority: FactAuthorityAuthorityLine,
|
||||
Master: MasterEngine,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "Ready/Recovered",
|
||||
EvidenceRequired: "authority_event",
|
||||
},
|
||||
{
|
||||
Path: "authority.endpoint_version",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "blockmaster_authority",
|
||||
FactAuthority: FactAuthorityAuthorityLine,
|
||||
Master: MasterEngine,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "Ready/Recovered",
|
||||
EvidenceRequired: "authority_event",
|
||||
},
|
||||
{
|
||||
Path: "authority.publish_target",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "blockmaster_authority",
|
||||
FactAuthority: FactAuthorityAuthorityLine,
|
||||
Master: MasterEngine,
|
||||
AggregationMode: FactAggregationDual,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "publish_target_missing_or_reattach_decision",
|
||||
ConditionSurface: "Ready/Recovering/Blocked",
|
||||
EvidenceRequired: "authority_event_or_inventory_publish_target",
|
||||
},
|
||||
{
|
||||
Path: "replica.durable_frontier_lsn",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "blockvolume_status_or_replica_probe",
|
||||
FactAuthority: FactAuthorityReplicaDurability,
|
||||
Master: MasterEngine,
|
||||
AggregationMode: FactAggregationDual,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "promotion_decision_or_required_frontier_unknown",
|
||||
ConditionSurface: "Recovering/Blocked",
|
||||
EvidenceRequired: "status_endpoint_or_promotion_evidence",
|
||||
},
|
||||
{
|
||||
Path: "csi.staged_target",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "csi_node",
|
||||
FactAuthority: FactAuthorityCSIAttach,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationDual,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "reattach_timeout_or_target_mismatch",
|
||||
ConditionSurface: "Ready/Recovering/Blocked",
|
||||
EvidenceRequired: "csi_event_or_node_stage_log",
|
||||
},
|
||||
{
|
||||
Path: "host_path.rtpg_aas",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "host_path_probe",
|
||||
FactAuthority: FactAuthorityHostPath,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationDual,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "transparent_failover_claim_or_path_suspect",
|
||||
ConditionSurface: "Ready/Recovered/Blocked",
|
||||
EvidenceRequired: "sg_rtpg_artifact",
|
||||
},
|
||||
{
|
||||
Path: "host_path.stale_path_probe",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "host_path_probe",
|
||||
FactAuthority: FactAuthorityHostPath,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "stale_primary_fencing_claim",
|
||||
ConditionSurface: "Recovered/Blocked",
|
||||
EvidenceRequired: "direct_stale_path_io_probe",
|
||||
},
|
||||
{
|
||||
Path: "workload.reader_verified",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "workload_probe_or_test_app",
|
||||
FactAuthority: FactAuthorityWorkloadEvidence,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "recovery_or_first_volume_claim",
|
||||
ConditionSurface: "Ready/Recovered",
|
||||
EvidenceRequired: "reader_log_checksum",
|
||||
},
|
||||
{
|
||||
Path: "cleanup.status",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "cleanup_verifier",
|
||||
FactAuthority: FactAuthorityCleanup,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "cleanup_close_gate",
|
||||
ConditionSurface: "CleanupRequired/Ready",
|
||||
EvidenceRequired: "cleanup_summary",
|
||||
},
|
||||
{
|
||||
Path: "cleanup.k8s_residue_count",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "cleanup_verifier",
|
||||
FactAuthority: FactAuthorityCleanup,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "cleanup_close_gate",
|
||||
ConditionSurface: "CleanupRequired",
|
||||
EvidenceRequired: "cleanup_summary_and_kubectl_artifact",
|
||||
},
|
||||
{
|
||||
Path: "cleanup.iscsi_residue_count",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "cleanup_verifier",
|
||||
FactAuthority: FactAuthorityCleanup,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "cleanup_close_gate",
|
||||
ConditionSurface: "CleanupRequired",
|
||||
EvidenceRequired: "cleanup_summary_and_iscsiadm_artifact",
|
||||
},
|
||||
{
|
||||
Path: "cleanup.multipath_residue_count",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "cleanup_verifier",
|
||||
FactAuthority: FactAuthorityCleanup,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "cleanup_close_gate",
|
||||
ConditionSurface: "CleanupRequired",
|
||||
EvidenceRequired: "cleanup_summary_and_multipath_artifact",
|
||||
},
|
||||
{
|
||||
Path: "cleanup.process_residue_count",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "cleanup_verifier",
|
||||
FactAuthority: FactAuthorityCleanup,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "cleanup_close_gate",
|
||||
ConditionSurface: "CleanupRequired",
|
||||
EvidenceRequired: "cleanup_summary_and_process_artifact",
|
||||
},
|
||||
{
|
||||
Path: "cleanup.hostpath_residue_count",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "cleanup_verifier",
|
||||
FactAuthority: FactAuthorityCleanup,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "cleanup_close_gate",
|
||||
ConditionSurface: "CleanupRequired",
|
||||
EvidenceRequired: "cleanup_summary_and_hostpath_artifact",
|
||||
},
|
||||
{
|
||||
Path: "cleanup.failure_count",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "cleanup_verifier",
|
||||
FactAuthority: FactAuthorityCleanup,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "cleanup_close_gate",
|
||||
ConditionSurface: "CleanupRequired",
|
||||
EvidenceRequired: "cleanup_summary",
|
||||
},
|
||||
{
|
||||
Path: "evidence.reason_code",
|
||||
Stability: ManagedVolumeFieldStable,
|
||||
Participant: "managed_volume_projection",
|
||||
FactAuthority: FactAuthorityObservation,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationPassive,
|
||||
ConditionSurface: "all_conditions",
|
||||
EvidenceRequired: "projection_inputs",
|
||||
},
|
||||
{
|
||||
Path: "workload.same_pod_uid",
|
||||
Stability: ManagedVolumeFieldTestOnly,
|
||||
Participant: "testops_or_workload_probe",
|
||||
FactAuthority: FactAuthorityWorkloadEvidence,
|
||||
Master: MasterManagedVolume,
|
||||
AggregationMode: FactAggregationProbe,
|
||||
ProbeAllowed: true,
|
||||
ProbeTrigger: "transparent_failover_claim",
|
||||
ConditionSurface: "Recovered",
|
||||
EvidenceRequired: "pod_uid_before_after_artifact",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ManagedVolumeActionContract() []ManagedVolumeActionContractEntry {
|
||||
return []ManagedVolumeActionContractEntry{
|
||||
{
|
||||
Type: ManagedVolumeActionCollectBundle,
|
||||
Master: MasterManagedVolume,
|
||||
Mode: ManagedVolumeActionModeReadOnly,
|
||||
SideEffectClass: ManagedVolumeSideEffectObserve,
|
||||
OwnerExecutor: "ops",
|
||||
PolicyGate: ActionPolicyReadOnly,
|
||||
RequiredFacts: []string{"evidence.reason_code"},
|
||||
EvidenceRequired: "projection_inputs_or_bundle",
|
||||
},
|
||||
{
|
||||
Type: ManagedVolumeActionWaitForPVCBound,
|
||||
Master: MasterManagedVolume,
|
||||
Mode: ManagedVolumeActionModeDryRun,
|
||||
SideEffectClass: ManagedVolumeSideEffectObserve,
|
||||
OwnerExecutor: "ops",
|
||||
PolicyGate: ActionPolicyDryRun,
|
||||
RequiredFacts: []string{"identity.pvc_name", "kubernetes.pvc_phase"},
|
||||
EvidenceRequired: "pvc_status_or_kubectl_describe",
|
||||
},
|
||||
{
|
||||
Type: ManagedVolumeActionInspectMountFailure,
|
||||
Master: MasterManagedVolume,
|
||||
Mode: ManagedVolumeActionModeDryRun,
|
||||
SideEffectClass: ManagedVolumeSideEffectObserve,
|
||||
OwnerExecutor: "ops",
|
||||
PolicyGate: ActionPolicyDryRun,
|
||||
RequiredFacts: []string{"identity.pvc_name", "kubernetes.pvc_phase", "csi.staged_target"},
|
||||
EvidenceRequired: "pod_describe_or_csi_node_log",
|
||||
},
|
||||
{
|
||||
Type: ManagedVolumeActionInspectHostPath,
|
||||
Master: MasterManagedVolume,
|
||||
Mode: ManagedVolumeActionModeDryRun,
|
||||
SideEffectClass: ManagedVolumeSideEffectObserve,
|
||||
OwnerExecutor: "ops",
|
||||
PolicyGate: ActionPolicyDryRun,
|
||||
RequiredFacts: []string{"host_path.rtpg_aas", "host_path.stale_path_probe"},
|
||||
InvariantRefs: []string{"INV-HOSTPATH-FACTS-001", "INV-HOSTPATH-TRANSPARENT-001"},
|
||||
EvidenceRequired: "sg_rtpg_artifact_and_stale_path_probe",
|
||||
},
|
||||
{
|
||||
Type: ManagedVolumeActionReinstallExternalISCSI,
|
||||
Master: MasterManagedVolume,
|
||||
Mode: ManagedVolumeActionModeDryRun,
|
||||
SideEffectClass: ManagedVolumeSideEffectSafeK8S,
|
||||
OwnerExecutor: "installer_or_operator",
|
||||
PolicyGate: ActionPolicyDryRun,
|
||||
RequiredFacts: []string{"authority.publish_target", "placement.replica_node"},
|
||||
InvariantRefs: []string{"INV-K8S-NONLOOPBACK-001"},
|
||||
EvidenceRequired: "loopback_cross_node_evidence",
|
||||
},
|
||||
{
|
||||
Type: ManagedVolumeActionImportCSIImage,
|
||||
Master: MasterManagedVolume,
|
||||
Mode: ManagedVolumeActionModeDryRun,
|
||||
SideEffectClass: ManagedVolumeSideEffectSafeK8S,
|
||||
OwnerExecutor: "installer_or_operator",
|
||||
PolicyGate: ActionPolicyDryRun,
|
||||
RequiredFacts: []string{"kubernetes.pvc_phase", "csi.staged_target"},
|
||||
InvariantRefs: []string{"INV-MANAGED-VOLUME-READMODEL-001"},
|
||||
EvidenceRequired: "csi_node_image_pull_evidence",
|
||||
},
|
||||
{
|
||||
Type: ManagedVolumeActionRequestPromotion,
|
||||
Master: MasterEngine,
|
||||
Mode: ManagedVolumeActionModeDryRun,
|
||||
SideEffectClass: ManagedVolumeSideEffectAuthorityMutating,
|
||||
OwnerExecutor: "authority_recovery_executor",
|
||||
PolicyGate: ActionPolicyDisabled,
|
||||
RequiredFacts: []string{"authority.primary_replica", "replica.durable_frontier_lsn"},
|
||||
EvidenceRequired: "promotion_readiness_evidence",
|
||||
MutationAllowed: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
package ops
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestManagedVolumeFactContract_CriticalFieldsHaveAuthorities(t *testing.T) {
|
||||
entries := ManagedVolumeFactContract()
|
||||
required := map[string]string{
|
||||
"identity.volume_id": FactAuthorityKubernetesObject,
|
||||
"identity.pvc_name": FactAuthorityKubernetesObject,
|
||||
"desired.replication_factor": FactAuthorityKubernetesObject,
|
||||
"desired.ack_profile": FactAuthorityKubernetesObject,
|
||||
"desired.claim_profile": FactAuthorityObservation,
|
||||
"desired.protocol": FactAuthorityKubernetesObject,
|
||||
"authority.primary_replica": FactAuthorityAuthorityLine,
|
||||
"authority.publish_target": FactAuthorityAuthorityLine,
|
||||
"authority.endpoint_version": FactAuthorityAuthorityLine,
|
||||
"replica.durable_frontier_lsn": FactAuthorityReplicaDurability,
|
||||
"csi.staged_target": FactAuthorityCSIAttach,
|
||||
"host_path.rtpg_aas": FactAuthorityHostPath,
|
||||
"host_path.stale_path_probe": FactAuthorityHostPath,
|
||||
"workload.reader_verified": FactAuthorityWorkloadEvidence,
|
||||
"cleanup.status": FactAuthorityCleanup,
|
||||
"cleanup.k8s_residue_count": FactAuthorityCleanup,
|
||||
"cleanup.iscsi_residue_count": FactAuthorityCleanup,
|
||||
"cleanup.multipath_residue_count": FactAuthorityCleanup,
|
||||
"cleanup.process_residue_count": FactAuthorityCleanup,
|
||||
"cleanup.hostpath_residue_count": FactAuthorityCleanup,
|
||||
"cleanup.failure_count": FactAuthorityCleanup,
|
||||
"evidence.reason_code": FactAuthorityObservation,
|
||||
}
|
||||
|
||||
byPath := managedVolumeContractByPath(entries)
|
||||
for path, authority := range required {
|
||||
entry, ok := byPath[path]
|
||||
if !ok {
|
||||
t.Fatalf("missing contract path %q", path)
|
||||
}
|
||||
if entry.FactAuthority != authority {
|
||||
t.Fatalf("path %s authority=%s want %s", path, entry.FactAuthority, authority)
|
||||
}
|
||||
if entry.Master == "" {
|
||||
t.Fatalf("path %s missing master", path)
|
||||
}
|
||||
if entry.EvidenceRequired == "" {
|
||||
t.Fatalf("path %s missing evidence requirement", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeFactContract_FieldRolesStayReadOnly(t *testing.T) {
|
||||
for _, entry := range ManagedVolumeFactContract() {
|
||||
if entry.Path == "" {
|
||||
t.Fatalf("contract entry missing path: %+v", entry)
|
||||
}
|
||||
if entry.FactAuthority == "" || entry.Master == "" || entry.Participant == "" {
|
||||
t.Fatalf("field %s missing layered role: %+v", entry.Path, entry)
|
||||
}
|
||||
if entry.EvidenceRequired == "" {
|
||||
t.Fatalf("field %s missing evidence requirement", entry.Path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeFactContract_DualModeOnlyForDecisionBoundaries(t *testing.T) {
|
||||
byPath := managedVolumeContractByPath(ManagedVolumeFactContract())
|
||||
|
||||
for _, path := range []string{
|
||||
"authority.primary_replica",
|
||||
"replica.durable_frontier_lsn",
|
||||
"csi.staged_target",
|
||||
"host_path.rtpg_aas",
|
||||
} {
|
||||
entry := byPath[path]
|
||||
if entry.AggregationMode != FactAggregationDual {
|
||||
t.Fatalf("path %s aggregation=%s want %s", path, entry.AggregationMode, FactAggregationDual)
|
||||
}
|
||||
if !entry.ProbeAllowed || entry.ProbeTrigger == "" {
|
||||
t.Fatalf("path %s must allow bounded probe with trigger: %+v", path, entry)
|
||||
}
|
||||
}
|
||||
|
||||
for _, path := range []string{
|
||||
"identity.pvc_name",
|
||||
"placement.replica_node",
|
||||
"evidence.reason_code",
|
||||
} {
|
||||
entry := byPath[path]
|
||||
if entry.AggregationMode != FactAggregationPassive {
|
||||
t.Fatalf("path %s aggregation=%s want passive", path, entry.AggregationMode)
|
||||
}
|
||||
if entry.ProbeAllowed {
|
||||
t.Fatalf("path %s should not need active probe: %+v", path, entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeFactContract_StableFieldsAreOperatorSafe(t *testing.T) {
|
||||
for _, entry := range ManagedVolumeFactContract() {
|
||||
if entry.Stability != ManagedVolumeFieldStable {
|
||||
continue
|
||||
}
|
||||
if entry.ConditionSurface == "" {
|
||||
t.Fatalf("stable path %s missing condition surface", entry.Path)
|
||||
}
|
||||
if entry.FactAuthority == "" || entry.Participant == "" || entry.Master == "" {
|
||||
t.Fatalf("stable path %s incomplete role contract: %+v", entry.Path, entry)
|
||||
}
|
||||
switch entry.AggregationMode {
|
||||
case FactAggregationPassive:
|
||||
if entry.ProbeTrigger != "" {
|
||||
t.Fatalf("passive path %s should not define probe trigger: %+v", entry.Path, entry)
|
||||
}
|
||||
case FactAggregationProbe, FactAggregationDual:
|
||||
if !entry.ProbeAllowed || entry.ProbeTrigger == "" {
|
||||
t.Fatalf("probe-capable path %s missing bounded probe contract: %+v", entry.Path, entry)
|
||||
}
|
||||
default:
|
||||
t.Fatalf("path %s unknown aggregation mode %q", entry.Path, entry.AggregationMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeActionContract_AllProjectedActionsHaveExecutors(t *testing.T) {
|
||||
contract := managedVolumeActionContractByType(ManagedVolumeActionContract())
|
||||
|
||||
projections := []ManagedVolumeProjection{
|
||||
ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-ready",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: "r1",
|
||||
PublishTarget: "192.168.1.181:3260",
|
||||
},
|
||||
Replicas: []ReplicaFact{{
|
||||
ReplicaID: "r1",
|
||||
KubernetesNode: "m01",
|
||||
Role: "primary",
|
||||
Observed: true,
|
||||
}},
|
||||
CSIStages: []CSIStageFact{{NodeName: "m01", Target: "192.168.1.181:3260"}},
|
||||
Workload: &WorkloadCheckFact{WriterVerified: true, ReaderVerified: true},
|
||||
}),
|
||||
ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-loopback",
|
||||
PVCName: "demo-pvc",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: "r1",
|
||||
PublishTarget: "127.0.0.1:3260",
|
||||
},
|
||||
Replicas: []ReplicaFact{{
|
||||
ReplicaID: "r1",
|
||||
KubernetesNode: "m01",
|
||||
Role: "primary",
|
||||
Observed: true,
|
||||
}},
|
||||
CSIStages: []CSIStageFact{{NodeName: "m02", Target: "127.0.0.1:3260"}},
|
||||
}),
|
||||
ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-pending",
|
||||
PVCName: "pending-pvc",
|
||||
PVC: &PVCFact{Phase: "Pending"},
|
||||
}),
|
||||
}
|
||||
|
||||
for _, projection := range projections {
|
||||
for _, action := range projection.Actions {
|
||||
entry, ok := contract[action.Type]
|
||||
if !ok {
|
||||
t.Fatalf("action %s missing action contract", action.Type)
|
||||
}
|
||||
if entry.Master == "" || entry.OwnerExecutor == "" {
|
||||
t.Fatalf("action %s missing master/executor: %+v", action.Type, entry)
|
||||
}
|
||||
if entry.MutationAllowed {
|
||||
t.Fatalf("phase30 must not expose mutating actions: %+v", entry)
|
||||
}
|
||||
if action.Mode != entry.Mode || action.SideEffectClass != entry.SideEffectClass || action.OwnerExecutor != entry.OwnerExecutor {
|
||||
t.Fatalf("action %s projection boundary=%+v contract=%+v", action.Type, action, entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeActionContract_Phase30NoExecutableMutation(t *testing.T) {
|
||||
for _, entry := range ManagedVolumeActionContract() {
|
||||
if entry.Type == "" || entry.Master == "" || entry.OwnerExecutor == "" {
|
||||
t.Fatalf("action contract missing role boundary: %+v", entry)
|
||||
}
|
||||
if entry.EvidenceRequired == "" {
|
||||
t.Fatalf("action %s missing evidence requirement", entry.Type)
|
||||
}
|
||||
if len(entry.RequiredFacts) == 0 {
|
||||
t.Fatalf("action %s missing required facts", entry.Type)
|
||||
}
|
||||
if entry.Mode != ManagedVolumeActionModeReadOnly && entry.Mode != ManagedVolumeActionModeDryRun {
|
||||
t.Fatalf("action %s exposes executable mode: %+v", entry.Type, entry)
|
||||
}
|
||||
if entry.MutationAllowed {
|
||||
t.Fatalf("phase30 action must not allow mutation: %+v", entry)
|
||||
}
|
||||
if entry.SideEffectClass != ManagedVolumeSideEffectObserve && entry.PolicyGate != ActionPolicyDryRun && entry.PolicyGate != ActionPolicyDisabled {
|
||||
t.Fatalf("non-observe action %s must be dry-run or disabled: %+v", entry.Type, entry)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func managedVolumeContractByPath(entries []ManagedVolumeFactContractEntry) map[string]ManagedVolumeFactContractEntry {
|
||||
out := make(map[string]ManagedVolumeFactContractEntry, len(entries))
|
||||
for _, entry := range entries {
|
||||
out[entry.Path] = entry
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func managedVolumeActionContractByType(entries []ManagedVolumeActionContractEntry) map[string]ManagedVolumeActionContractEntry {
|
||||
out := make(map[string]ManagedVolumeActionContractEntry, len(entries))
|
||||
for _, entry := range entries {
|
||||
out[entry.Type] = entry
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package ops
|
||||
|
||||
const (
|
||||
SwBlockVolumeAPIVersion = "block.seaweedfs.com/v1alpha1"
|
||||
SwBlockVolumeKind = "SwBlockVolume"
|
||||
SwBlockClusterKind = "SwBlockCluster"
|
||||
|
||||
ConditionReady = "Ready"
|
||||
ConditionRecovered = "Recovered"
|
||||
ConditionRecovering = "Recovering"
|
||||
ConditionBlocked = "Blocked"
|
||||
ConditionInvalid = "Invalid"
|
||||
ConditionCleanupRequired = "CleanupRequired"
|
||||
ConditionEvidenceStale = "EvidenceStale"
|
||||
)
|
||||
|
||||
type ManagedVolumeCRDContract struct {
|
||||
Group string `json:"group"`
|
||||
Version string `json:"version"`
|
||||
ReadOnly bool `json:"read_only"`
|
||||
RBAC ManagedVolumeCRDRBAC `json:"rbac"`
|
||||
Resources []ManagedVolumeCRDKind `json:"resources"`
|
||||
Conditions []string `json:"conditions"`
|
||||
EventRules []ManagedVolumeEventRule `json:"event_rules"`
|
||||
}
|
||||
|
||||
type ManagedVolumeCRDRBAC struct {
|
||||
AllowedVerbs []string `json:"allowed_verbs"`
|
||||
ForbiddenActions []string `json:"forbidden_actions"`
|
||||
MutatingStorageVerbsAllowed bool `json:"mutating_storage_verbs_allowed"`
|
||||
}
|
||||
|
||||
type ManagedVolumeCRDKind struct {
|
||||
Kind string `json:"kind"`
|
||||
Scope string `json:"scope"`
|
||||
StatusFrom string `json:"status_from"`
|
||||
SpecFields []string `json:"spec_fields,omitempty"`
|
||||
StatusPaths []string `json:"status_paths"`
|
||||
NonClaims []string `json:"non_claims,omitempty"`
|
||||
}
|
||||
|
||||
type ManagedVolumeEventRule struct {
|
||||
ConditionSeverity string `json:"condition_severity"`
|
||||
KubernetesType string `json:"kubernetes_type"`
|
||||
}
|
||||
|
||||
func ManagedVolumeCRDContractDefinition() ManagedVolumeCRDContract {
|
||||
return ManagedVolumeCRDContract{
|
||||
Group: "block.seaweedfs.com",
|
||||
Version: "v1alpha1",
|
||||
ReadOnly: true,
|
||||
RBAC: ManagedVolumeCRDRBAC{
|
||||
AllowedVerbs: []string{
|
||||
"get",
|
||||
"list",
|
||||
"watch",
|
||||
"update_status",
|
||||
"patch_status",
|
||||
"create_event",
|
||||
},
|
||||
ForbiddenActions: []string{
|
||||
"promote",
|
||||
"repair",
|
||||
"rebuild",
|
||||
"failback",
|
||||
"delete_storage",
|
||||
"cleanup_live_state",
|
||||
},
|
||||
MutatingStorageVerbsAllowed: false,
|
||||
},
|
||||
Resources: []ManagedVolumeCRDKind{{
|
||||
Kind: SwBlockClusterKind,
|
||||
Scope: "Namespaced",
|
||||
StatusFrom: "ManagedVolumeProjection aggregate",
|
||||
SpecFields: []string{
|
||||
"image",
|
||||
"csiImage",
|
||||
"storageClass",
|
||||
"blockNodes",
|
||||
"ackProfile",
|
||||
"protocol",
|
||||
},
|
||||
StatusPaths: []string{
|
||||
"status.conditions",
|
||||
"status.observedAt",
|
||||
"status.nodeCount",
|
||||
"status.volumeCount",
|
||||
"status.readyVolumeCount",
|
||||
"status.blockedVolumeCount",
|
||||
"status.staleVolumeCount",
|
||||
"status.observedGeneration",
|
||||
"status.evidenceRefs",
|
||||
},
|
||||
NonClaims: []string{
|
||||
"no_mutating_storage_actions",
|
||||
"no_repair_rebuild_failback",
|
||||
"no_backup_restore",
|
||||
},
|
||||
}, {
|
||||
Kind: SwBlockVolumeKind,
|
||||
Scope: "Namespaced",
|
||||
StatusFrom: "ManagedVolumeProjection",
|
||||
SpecFields: []string{
|
||||
"pvcName",
|
||||
"storageClass",
|
||||
},
|
||||
StatusPaths: []string{
|
||||
"status.volumeID",
|
||||
"status.pvcName",
|
||||
"status.status",
|
||||
"status.reasonCode",
|
||||
"status.conditions",
|
||||
"status.observedAt",
|
||||
"status.nonClaims",
|
||||
"status.evidenceRefs",
|
||||
"status.allowedActions",
|
||||
},
|
||||
NonClaims: []string{
|
||||
"status_only",
|
||||
"no_primary_selection",
|
||||
"no_promote_repair_rebuild_delete",
|
||||
},
|
||||
}},
|
||||
Conditions: []string{
|
||||
ConditionReady,
|
||||
ConditionRecovered,
|
||||
ConditionRecovering,
|
||||
ConditionBlocked,
|
||||
ConditionInvalid,
|
||||
ConditionCleanupRequired,
|
||||
ConditionEvidenceStale,
|
||||
},
|
||||
EventRules: []ManagedVolumeEventRule{{
|
||||
ConditionSeverity: "info",
|
||||
KubernetesType: "Normal",
|
||||
}, {
|
||||
ConditionSeverity: "warning",
|
||||
KubernetesType: "Warning",
|
||||
}, {
|
||||
ConditionSeverity: "error",
|
||||
KubernetesType: "Warning",
|
||||
}},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package ops
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestManagedVolumeCRDContract_StatusOnlyResources(t *testing.T) {
|
||||
contract := ManagedVolumeCRDContractDefinition()
|
||||
if contract.Group != "block.seaweedfs.com" || contract.Version != "v1alpha1" {
|
||||
t.Fatalf("contract group/version=%+v", contract)
|
||||
}
|
||||
if !contract.ReadOnly {
|
||||
t.Fatalf("CRD contract must be read-only: %+v", contract)
|
||||
}
|
||||
if contract.RBAC.MutatingStorageVerbsAllowed {
|
||||
t.Fatalf("CRD contract exposes storage mutation: %+v", contract.RBAC)
|
||||
}
|
||||
for _, want := range []string{"get", "list", "watch", "update_status", "patch_status", "create_event"} {
|
||||
if !stringSliceContains(contract.RBAC.AllowedVerbs, want) {
|
||||
t.Fatalf("missing allowed verb %s in %+v", want, contract.RBAC.AllowedVerbs)
|
||||
}
|
||||
}
|
||||
for _, forbidden := range []string{"promote", "repair", "rebuild", "failback", "delete_storage", "cleanup_live_state"} {
|
||||
if !stringSliceContains(contract.RBAC.ForbiddenActions, forbidden) {
|
||||
t.Fatalf("missing forbidden action %s in %+v", forbidden, contract.RBAC.ForbiddenActions)
|
||||
}
|
||||
}
|
||||
|
||||
kinds := map[string]ManagedVolumeCRDKind{}
|
||||
for _, resource := range contract.Resources {
|
||||
kinds[resource.Kind] = resource
|
||||
}
|
||||
for _, kind := range []string{SwBlockClusterKind, SwBlockVolumeKind} {
|
||||
resource, ok := kinds[kind]
|
||||
if !ok {
|
||||
t.Fatalf("missing resource %s", kind)
|
||||
}
|
||||
if resource.StatusFrom == "" || len(resource.StatusPaths) == 0 {
|
||||
t.Fatalf("resource %s missing status contract: %+v", kind, resource)
|
||||
}
|
||||
for _, want := range []string{"status.conditions", "status.observedAt", "status.evidenceRefs"} {
|
||||
if !stringSliceContains(resource.StatusPaths, want) {
|
||||
t.Fatalf("resource %s missing status path %s in %+v", kind, want, resource.StatusPaths)
|
||||
}
|
||||
}
|
||||
if !stringSliceContains(resource.NonClaims, "no_mutating_storage_actions") &&
|
||||
!stringSliceContains(resource.NonClaims, "no_promote_repair_rebuild_delete") {
|
||||
t.Fatalf("resource %s missing mutating-action non-claim: %+v", kind, resource.NonClaims)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeCRDContract_ConditionVocabularyCoversProjection(t *testing.T) {
|
||||
contract := ManagedVolumeCRDContractDefinition()
|
||||
for _, condition := range []string{
|
||||
ConditionReady,
|
||||
ConditionRecovered,
|
||||
ConditionRecovering,
|
||||
ConditionBlocked,
|
||||
ConditionInvalid,
|
||||
ConditionCleanupRequired,
|
||||
ConditionEvidenceStale,
|
||||
} {
|
||||
if !stringSliceContains(contract.Conditions, condition) {
|
||||
t.Fatalf("missing condition %s in %+v", condition, contract.Conditions)
|
||||
}
|
||||
}
|
||||
|
||||
cases := []ManagedVolumeFacts{
|
||||
{
|
||||
VolumeID: "pvc-ready",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: "r1",
|
||||
PublishTarget: "127.0.0.1:3260",
|
||||
},
|
||||
CSIStages: []CSIStageFact{{NodeName: "m02", Target: "127.0.0.1:3260"}},
|
||||
Workload: &WorkloadCheckFact{WriterVerified: true, ReaderVerified: true},
|
||||
},
|
||||
{
|
||||
VolumeID: "pvc-blocked",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: "r1",
|
||||
PublishTarget: "127.0.0.1:3260",
|
||||
},
|
||||
Replicas: []ReplicaFact{{ReplicaID: "r1", KubernetesNode: "m01", Role: "primary", Observed: true}},
|
||||
CSIStages: []CSIStageFact{{NodeName: "m02", Target: "127.0.0.1:3260"}},
|
||||
},
|
||||
{
|
||||
VolumeID: "pvc-recovered",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: "r2",
|
||||
PreviousPrimary: "r1",
|
||||
PublishTarget: "192.168.1.184:3261",
|
||||
},
|
||||
HostPaths: []HostPathFact{{
|
||||
Protocol: "iscsi",
|
||||
State: HostPathStateActiveOptimized,
|
||||
MultipathReady: true,
|
||||
StaleFenced: true,
|
||||
}},
|
||||
Workload: &WorkloadCheckFact{WriterVerified: true, ReaderVerified: true, SamePodUID: true},
|
||||
},
|
||||
{
|
||||
VolumeID: "pvc-stale",
|
||||
EvidenceStale: true,
|
||||
EvidenceStaleReason: ReasonEvidenceStale,
|
||||
EvidenceRefs: []string{"product/unreachable.txt"},
|
||||
ProductStatus: ObservationStatusUnavailable,
|
||||
ProductReason: ReasonEvidenceStale,
|
||||
},
|
||||
}
|
||||
|
||||
for _, facts := range cases {
|
||||
projection := ProjectManagedVolume(facts)
|
||||
for _, condition := range projection.Conditions {
|
||||
if !stringSliceContains(contract.Conditions, condition.Type) {
|
||||
t.Fatalf("projection emitted condition outside CRD contract: %s from %+v", condition.Type, projection)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeCRDContract_EventRulesMatchOperatorEvents(t *testing.T) {
|
||||
contract := ManagedVolumeCRDContractDefinition()
|
||||
rules := map[string]string{}
|
||||
for _, rule := range contract.EventRules {
|
||||
rules[rule.ConditionSeverity] = rule.KubernetesType
|
||||
}
|
||||
for severity, want := range map[string]string{
|
||||
"info": "Normal",
|
||||
"warning": "Warning",
|
||||
"error": "Warning",
|
||||
} {
|
||||
if got := rules[severity]; got != want {
|
||||
t.Fatalf("severity %s event type=%s want %s", severity, got, want)
|
||||
}
|
||||
}
|
||||
|
||||
projection := ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-blocked",
|
||||
PVC: &PVCFact{Phase: "Pending"},
|
||||
})
|
||||
operatorContract := ManagedVolumeOperatorContractFromProjection(projection)
|
||||
for _, event := range operatorContract.Events {
|
||||
if event.Type != "Warning" {
|
||||
t.Fatalf("blocked projection should produce warning event: %+v", operatorContract.Events)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestManagedVolumeCRDContract_EvidenceStaleEventIsWarning(t *testing.T) {
|
||||
projection := ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-stale",
|
||||
EvidenceStale: true,
|
||||
EvidenceStaleReason: ReasonEvidenceStale,
|
||||
EvidenceRefs: []string{"product/unreachable.txt"},
|
||||
})
|
||||
contract := ManagedVolumeOperatorContractFromProjection(projection)
|
||||
found := false
|
||||
for _, event := range contract.Events {
|
||||
if event.Reason == ReasonEvidenceStale && event.Type == "Warning" {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("missing EvidenceStale warning event: %+v", contract.Events)
|
||||
}
|
||||
}
|
||||
@@ -71,6 +71,7 @@ const (
|
||||
ReasonWriterMountFailed = "writer_mount_failed"
|
||||
ReasonHostPathNotMultipathed = "host_path_not_multipathed"
|
||||
ReasonTransparentHostPathRecovered = "transparent_host_path_recovered"
|
||||
ReasonEvidenceStale = "evidence_stale"
|
||||
|
||||
HostPathStateActiveOptimized = "active_optimized"
|
||||
HostPathStateSinglePath = "single_path"
|
||||
@@ -87,26 +88,28 @@ type FactMeta struct {
|
||||
}
|
||||
|
||||
type ManagedVolumeFacts struct {
|
||||
VolumeID string `json:"volume_id,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
PVCName string `json:"pvc_name,omitempty"`
|
||||
PVName string `json:"pv_name,omitempty"`
|
||||
StorageClass string `json:"storage_class,omitempty"`
|
||||
ReplicationFactor int `json:"replication_factor,omitempty"`
|
||||
AckProfile string `json:"ack_profile,omitempty"`
|
||||
ClaimProfile string `json:"claim_profile,omitempty"`
|
||||
Protocol string `json:"protocol,omitempty"`
|
||||
ProductStatus string `json:"product_status,omitempty"`
|
||||
ProductReason string `json:"product_reason,omitempty"`
|
||||
KubernetesNodes []KubernetesNodeFact `json:"kubernetes_nodes,omitempty"`
|
||||
PVC *PVCFact `json:"pvc,omitempty"`
|
||||
PodMounts []PodMountFact `json:"pod_mounts,omitempty"`
|
||||
Authority *AuthorityFact `json:"authority,omitempty"`
|
||||
Replicas []ReplicaFact `json:"replicas,omitempty"`
|
||||
CSIStages []CSIStageFact `json:"csi_stages,omitempty"`
|
||||
HostPaths []HostPathFact `json:"host_paths,omitempty"`
|
||||
Workload *WorkloadCheckFact `json:"workload,omitempty"`
|
||||
EvidenceRefs []string `json:"evidence_refs,omitempty"`
|
||||
VolumeID string `json:"volume_id,omitempty"`
|
||||
Namespace string `json:"namespace,omitempty"`
|
||||
PVCName string `json:"pvc_name,omitempty"`
|
||||
PVName string `json:"pv_name,omitempty"`
|
||||
StorageClass string `json:"storage_class,omitempty"`
|
||||
ReplicationFactor int `json:"replication_factor,omitempty"`
|
||||
AckProfile string `json:"ack_profile,omitempty"`
|
||||
ClaimProfile string `json:"claim_profile,omitempty"`
|
||||
Protocol string `json:"protocol,omitempty"`
|
||||
ProductStatus string `json:"product_status,omitempty"`
|
||||
ProductReason string `json:"product_reason,omitempty"`
|
||||
EvidenceStale bool `json:"evidence_stale,omitempty"`
|
||||
EvidenceStaleReason string `json:"evidence_stale_reason,omitempty"`
|
||||
KubernetesNodes []KubernetesNodeFact `json:"kubernetes_nodes,omitempty"`
|
||||
PVC *PVCFact `json:"pvc,omitempty"`
|
||||
PodMounts []PodMountFact `json:"pod_mounts,omitempty"`
|
||||
Authority *AuthorityFact `json:"authority,omitempty"`
|
||||
Replicas []ReplicaFact `json:"replicas,omitempty"`
|
||||
CSIStages []CSIStageFact `json:"csi_stages,omitempty"`
|
||||
HostPaths []HostPathFact `json:"host_paths,omitempty"`
|
||||
Workload *WorkloadCheckFact `json:"workload,omitempty"`
|
||||
EvidenceRefs []string `json:"evidence_refs,omitempty"`
|
||||
}
|
||||
|
||||
type PVCFact struct {
|
||||
@@ -535,6 +538,9 @@ func classifyManagedVolume(p ManagedVolumeProjection, facts ManagedVolumeFacts)
|
||||
if p.States.Kubernetes == ManagedVolumeKubernetesPending {
|
||||
return ManagedVolumeStatusBlocked, ReasonPVCUnbound
|
||||
}
|
||||
if facts.EvidenceStale || facts.ProductReason == ReasonEvidenceStale {
|
||||
return ManagedVolumeStatusUnknown, defaultString(facts.EvidenceStaleReason, ReasonEvidenceStale)
|
||||
}
|
||||
if p.States.HostPath == ManagedVolumeHostPathTransparentReady &&
|
||||
facts.Workload != nil &&
|
||||
facts.Workload.WriterVerified &&
|
||||
@@ -730,7 +736,7 @@ func managedVolumeConditionsForProjection(p ManagedVolumeProjection) []Observati
|
||||
EvidenceRefs: append([]string(nil), p.EvidenceRefs...),
|
||||
}}
|
||||
default:
|
||||
return []ObservationCondition{{
|
||||
conditions := []ObservationCondition{{
|
||||
Type: "Ready",
|
||||
Status: "Unknown",
|
||||
Reason: reason,
|
||||
@@ -738,6 +744,19 @@ func managedVolumeConditionsForProjection(p ManagedVolumeProjection) []Observati
|
||||
Message: "insufficient managed volume facts",
|
||||
EvidenceRefs: append([]string(nil), p.EvidenceRefs...),
|
||||
}}
|
||||
if reason == ReasonEvidenceStale {
|
||||
conditions[0].Severity = "warning"
|
||||
conditions[0].Message = "managed volume evidence is stale or unreachable; readiness is not claimed"
|
||||
conditions = append(conditions, ObservationCondition{
|
||||
Type: ConditionEvidenceStale,
|
||||
Status: "True",
|
||||
Reason: reason,
|
||||
Severity: "warning",
|
||||
Message: "bounded probe or fresh evidence is required before claiming readiness",
|
||||
EvidenceRefs: append([]string(nil), p.EvidenceRefs...),
|
||||
})
|
||||
}
|
||||
return conditions
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,11 +51,25 @@ type ClusterEvidence struct {
|
||||
Nodes []NodeEvidence `json:"nodes"`
|
||||
Volumes []VolumeEvidence `json:"volumes"`
|
||||
ManagedVolumes []ManagedVolumeProjection `json:"managed_volumes,omitempty"`
|
||||
Cleanup *CleanupEvidence `json:"cleanup,omitempty"`
|
||||
Conditions []ObservationCondition `json:"conditions,omitempty"`
|
||||
Events []ClusterEvent `json:"events,omitempty"`
|
||||
NonClaims []string `json:"non_claims,omitempty"`
|
||||
}
|
||||
|
||||
type CleanupEvidence struct {
|
||||
Status string `json:"status"`
|
||||
KubernetesResidueCount int `json:"k8s_residue_count,omitempty"`
|
||||
ISCSIResidueCount int `json:"iscsi_residue_count,omitempty"`
|
||||
MultipathResidueCount int `json:"multipath_residue_count,omitempty"`
|
||||
ProcessResidueCount int `json:"process_residue_count,omitempty"`
|
||||
HostPathResidueCount int `json:"hostpath_residue_count,omitempty"`
|
||||
FailureCount int `json:"failure_count,omitempty"`
|
||||
FailedPhase string `json:"failed_phase,omitempty"`
|
||||
ReasonCodes []string `json:"reason_codes,omitempty"`
|
||||
EvidenceRef string `json:"evidence_ref,omitempty"`
|
||||
}
|
||||
|
||||
type NodeEvidence struct {
|
||||
NodeName string `json:"node_name"`
|
||||
KubernetesNode string `json:"kubernetes_node,omitempty"`
|
||||
|
||||
@@ -13,11 +13,13 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
ClusterEvidenceArtifact = "cluster-evidence.json"
|
||||
ObservationReportHTMLArtifact = "index.html"
|
||||
ObservationReportJSONArtifact = ClusterEvidenceArtifact
|
||||
ObservationReportTextArtifact = "summary.txt"
|
||||
ObservationReportJSONLArtifact = "timeline.jsonl"
|
||||
ClusterEvidenceArtifact = "cluster-evidence.json"
|
||||
RestartClusterEvidenceArtifact = "cluster-after-restart.json"
|
||||
ObservationReportHTMLArtifact = "index.html"
|
||||
ObservationReportJSONArtifact = ClusterEvidenceArtifact
|
||||
ObservationReportTextArtifact = "summary.txt"
|
||||
ObservationReportJSONLArtifact = "timeline.jsonl"
|
||||
ObservationCleanupSummaryArtifact = "cleanup-summary.txt"
|
||||
|
||||
NodeLossRecoverySummaryArtifact = "node-loss-recovery-summary.txt"
|
||||
PrimaryFailureRecoveryArtifact = "primary-failure-recovery.txt"
|
||||
@@ -73,6 +75,10 @@ func BuildObservationFromBundle(opts ObservationBundleOptions) (ClusterEvidence,
|
||||
}
|
||||
}
|
||||
}
|
||||
cleanup, cleanupPath, _ := loadKeyValueArtifact(opts.Dir, ObservationCleanupSummaryArtifact)
|
||||
if len(cleanup) > 0 {
|
||||
cluster.Cleanup = CleanupEvidenceFromSummary(cleanup, cleanupPath)
|
||||
}
|
||||
if blocked, blockedVolume := buildImagePullBlockedEvidence(opts.Dir); blocked {
|
||||
cluster.Status = ObservationStatusBlocked
|
||||
sourceLoaded = true
|
||||
@@ -168,34 +174,85 @@ func loadBestVolumeInventory(root string) (VolumeInventory, string, error) {
|
||||
}
|
||||
|
||||
func loadBestClusterEvidence(root string) (ClusterEvidence, string, error) {
|
||||
paths, err := findArtifactPaths(root, ClusterEvidenceArtifact)
|
||||
paths, err := findClusterEvidenceCandidatePaths(root)
|
||||
if err != nil {
|
||||
return ClusterEvidence{}, "", err
|
||||
}
|
||||
if len(paths) == 0 {
|
||||
return ClusterEvidence{}, "", fmt.Errorf("%s not found under %s", ClusterEvidenceArtifact, root)
|
||||
}
|
||||
sort.SliceStable(paths, func(i, j int) bool {
|
||||
return clusterEvidencePathRank(paths[i]) < clusterEvidencePathRank(paths[j])
|
||||
|
||||
type candidate struct {
|
||||
path string
|
||||
cluster ClusterEvidence
|
||||
}
|
||||
candidates := make([]candidate, 0, len(paths))
|
||||
var loadErrs []string
|
||||
for _, path := range paths {
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
loadErrs = append(loadErrs, fmt.Sprintf("read %s: %v", path, err))
|
||||
continue
|
||||
}
|
||||
var cluster ClusterEvidence
|
||||
if err := json.Unmarshal(raw, &cluster); err != nil {
|
||||
loadErrs = append(loadErrs, fmt.Sprintf("decode %s: %v", path, err))
|
||||
continue
|
||||
}
|
||||
candidates = append(candidates, candidate{path: path, cluster: cluster})
|
||||
}
|
||||
if len(candidates) == 0 {
|
||||
if len(loadErrs) > 0 {
|
||||
return ClusterEvidence{}, "", fmt.Errorf("no valid %s candidates under %s: %s", ClusterEvidenceArtifact, root, strings.Join(loadErrs, "; "))
|
||||
}
|
||||
return ClusterEvidence{}, "", fmt.Errorf("%s not found under %s", ClusterEvidenceArtifact, root)
|
||||
}
|
||||
sort.SliceStable(candidates, func(i, j int) bool {
|
||||
left := candidates[i].cluster.CapturedAt
|
||||
right := candidates[j].cluster.CapturedAt
|
||||
if !left.IsZero() || !right.IsZero() {
|
||||
if left.IsZero() {
|
||||
return false
|
||||
}
|
||||
if right.IsZero() {
|
||||
return true
|
||||
}
|
||||
if !left.Equal(right) {
|
||||
return left.After(right)
|
||||
}
|
||||
}
|
||||
leftRank := clusterEvidencePathRank(candidates[i].path)
|
||||
rightRank := clusterEvidencePathRank(candidates[j].path)
|
||||
if leftRank != rightRank {
|
||||
return leftRank < rightRank
|
||||
}
|
||||
return filepath.ToSlash(candidates[i].path) < filepath.ToSlash(candidates[j].path)
|
||||
})
|
||||
raw, err := os.ReadFile(paths[0])
|
||||
if err != nil {
|
||||
return ClusterEvidence{}, paths[0], fmt.Errorf("read %s: %w", paths[0], err)
|
||||
return NormalizeObservationCluster(candidates[0].cluster), candidates[0].path, nil
|
||||
}
|
||||
|
||||
func findClusterEvidenceCandidatePaths(root string) ([]string, error) {
|
||||
var out []string
|
||||
for _, name := range []string{ClusterEvidenceArtifact, RestartClusterEvidenceArtifact} {
|
||||
paths, err := findArtifactPaths(root, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, paths...)
|
||||
}
|
||||
var cluster ClusterEvidence
|
||||
if err := json.Unmarshal(raw, &cluster); err != nil {
|
||||
return ClusterEvidence{}, paths[0], fmt.Errorf("decode %s: %w", paths[0], err)
|
||||
}
|
||||
return NormalizeObservationCluster(cluster), paths[0], nil
|
||||
sort.Strings(out)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func clusterEvidencePathRank(path string) int {
|
||||
path = filepath.ToSlash(path)
|
||||
switch {
|
||||
case strings.Contains(path, "product-observation"):
|
||||
case strings.Contains(path, "/restart/"):
|
||||
return 0
|
||||
case strings.Contains(path, "/status/"):
|
||||
case strings.Contains(path, "product-observation"):
|
||||
return 1
|
||||
case strings.Contains(path, "/status/"):
|
||||
return 2
|
||||
default:
|
||||
return 10
|
||||
}
|
||||
|
||||
@@ -203,6 +203,125 @@ func TestObservationBundle_ManagedVolumeUsesPrimaryFailureArtifactHints(t *testi
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservationBundle_D7PrefersNewestRestartClusterEvidence(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
oldCluster := NewClusterEvidence(time.Date(2026, 5, 25, 21, 32, 48, 0, time.UTC))
|
||||
oldCluster.Volumes = []VolumeEvidence{{
|
||||
VolumeID: "pvc-restart",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
ReplicationFactor: 3,
|
||||
AckProfile: "sync-quorum",
|
||||
Status: ObservationStatusOK,
|
||||
PrimaryReplica: "r1",
|
||||
PrimaryNode: "m01",
|
||||
PublishTarget: "192.168.1.181:3260",
|
||||
Epoch: 1,
|
||||
}}
|
||||
newCluster := NewClusterEvidence(time.Date(2026, 5, 25, 21, 33, 37, 0, time.UTC))
|
||||
newCluster.Volumes = []VolumeEvidence{{
|
||||
VolumeID: "pvc-restart",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
ReplicationFactor: 3,
|
||||
AckProfile: "sync-quorum",
|
||||
Status: ObservationStatusOK,
|
||||
PrimaryReplica: "r2",
|
||||
PrimaryNode: "m02",
|
||||
PublishTarget: "192.168.1.184:3260",
|
||||
Epoch: 2,
|
||||
}}
|
||||
writeClusterEvidenceArtifact(t, filepath.Join(dir, "recovery", "setup", "status", ClusterEvidenceArtifact), oldCluster)
|
||||
writeClusterEvidenceArtifact(t, filepath.Join(dir, "restart", RestartClusterEvidenceArtifact), newCluster)
|
||||
|
||||
out, err := BuildObservationFromBundle(ObservationBundleOptions{Dir: dir, VolumeID: "pvc-restart"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(out.Volumes) != 1 {
|
||||
t.Fatalf("volumes=%+v", out.Volumes)
|
||||
}
|
||||
volume := out.Volumes[0]
|
||||
if volume.PrimaryReplica != "r2" || volume.PrimaryNode != "m02" || volume.PublishTarget != "192.168.1.184:3260" || volume.Epoch != 2 {
|
||||
t.Fatalf("expected post-restart evidence, got %+v", volume)
|
||||
}
|
||||
summary := RenderObservationReportSummary(out)
|
||||
if !strings.Contains(summary, "primary=r2@m02 frontend=192.168.1.184:3260") {
|
||||
t.Fatalf("summary used stale primary:\n%s", summary)
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservationBundle_SkipsCorruptClusterEvidenceCandidate(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
if err := os.MkdirAll(filepath.Join(dir, "stale", "status"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mustWrite(t, filepath.Join(dir, "stale", "status", ClusterEvidenceArtifact), "{not-json")
|
||||
good := NewClusterEvidence(time.Date(2026, 5, 25, 21, 33, 37, 0, time.UTC))
|
||||
good.Volumes = []VolumeEvidence{healthyObservationVolume()}
|
||||
writeClusterEvidenceArtifact(t, filepath.Join(dir, "restart", RestartClusterEvidenceArtifact), good)
|
||||
|
||||
out, err := BuildObservationFromBundle(ObservationBundleOptions{Dir: dir})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(out.Volumes) != 1 || out.Volumes[0].VolumeID != healthyObservationVolume().VolumeID {
|
||||
t.Fatalf("unexpected bundle replay output: %+v", out.Volumes)
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservationBundle_CarriesCleanupEvidenceIntoReportSurfaces(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeProductClusterEvidence(t, dir, []VolumeEvidence{healthyObservationVolume()})
|
||||
mustWrite(t, filepath.Join(dir, "demo", ObservationCleanupSummaryArtifact), strings.Join([]string{
|
||||
"cleanup_status=failed",
|
||||
"k8s_residue_count=1",
|
||||
"iscsi_residue_count=2",
|
||||
"multipath_residue_count=3",
|
||||
"process_residue_count=4",
|
||||
"hostpath_residue_count=5",
|
||||
"failure_count=2",
|
||||
"failed_phase=collect_and_cleanup",
|
||||
"reason_codes=kubernetes_sw_block_resources_present,multipath_maps_present",
|
||||
}, "\n"))
|
||||
|
||||
cluster, err := BuildObservationFromBundle(ObservationBundleOptions{Dir: dir})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cluster.Cleanup == nil {
|
||||
t.Fatalf("missing cleanup evidence")
|
||||
}
|
||||
if cluster.Cleanup.Status != "failed" || cluster.Cleanup.KubernetesResidueCount != 1 || cluster.Cleanup.MultipathResidueCount != 3 {
|
||||
t.Fatalf("cleanup evidence=%+v", cluster.Cleanup)
|
||||
}
|
||||
if len(cluster.Cleanup.ReasonCodes) != 2 || cluster.Cleanup.ReasonCodes[1] != "multipath_maps_present" {
|
||||
t.Fatalf("cleanup reason codes=%+v", cluster.Cleanup.ReasonCodes)
|
||||
}
|
||||
|
||||
summary := RenderObservationReportSummary(cluster)
|
||||
for _, want := range []string{
|
||||
"cleanup_status=failed",
|
||||
"k8s_residue_count=1",
|
||||
"iscsi_residue_count=2",
|
||||
"multipath_residue_count=3",
|
||||
"process_residue_count=4",
|
||||
"hostpath_residue_count=5",
|
||||
"failure_count=2",
|
||||
"failed_phase=collect_and_cleanup",
|
||||
"cleanup_evidence=",
|
||||
} {
|
||||
if !strings.Contains(summary, want) {
|
||||
t.Fatalf("summary missing %q:\n%s", want, summary)
|
||||
}
|
||||
}
|
||||
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if snapshot.Cluster.Cleanup == nil || snapshot.Cluster.Cleanup.Status != "failed" || snapshot.Cluster.Cleanup.FailedPhase != "collect_and_cleanup" {
|
||||
t.Fatalf("operator cleanup evidence=%+v", snapshot.Cluster.Cleanup)
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservationBundle_D6ReplayGate_FirstVolumeBlockedAndRecovery(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
@@ -290,6 +409,7 @@ deployment.apps/sw-block-csi-controller 1/1 1 1 2m3s block-csi sw-block-csi:loca
|
||||
ObservationReportHTMLArtifact,
|
||||
ObservationReportJSONArtifact,
|
||||
ObservationReportJSONLArtifact,
|
||||
ObservationOperatorSnapshotArtifact,
|
||||
ObservationReportTextArtifact,
|
||||
} {
|
||||
if _, err := os.Stat(filepath.Join(reportDir, artifact)); err != nil {
|
||||
@@ -397,6 +517,7 @@ deployment.apps/sw-block-csi-controller 1/1 1 1 2m3s block-csi sw-block-csi:loca
|
||||
defer server.Close()
|
||||
assertDashboardEndpointContains(t, server.URL+"/", tc.wantHTML)
|
||||
assertDashboardEndpointContains(t, server.URL+"/"+ObservationReportJSONArtifact, tc.wantJSON)
|
||||
assertDashboardEndpointContains(t, server.URL+"/"+ObservationOperatorSnapshotArtifact, `"read_only": true`)
|
||||
assertDashboardEndpointContains(t, server.URL+"/"+ObservationReportTextArtifact, tc.wantText)
|
||||
|
||||
resp, err := http.Post(server.URL+"/", "application/json", strings.NewReader(`{"action":"repair"}`))
|
||||
@@ -451,6 +572,20 @@ func writeProductClusterEvidence(t *testing.T, dir string, volumes []VolumeEvide
|
||||
}
|
||||
}
|
||||
|
||||
func writeClusterEvidenceArtifact(t *testing.T, path string, cluster ClusterEvidence) {
|
||||
t.Helper()
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
raw, err := MarshalObservationJSON(cluster)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path, raw, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func mustWriteInventory(t *testing.T, dir string, inventory VolumeInventory) {
|
||||
t.Helper()
|
||||
raw, err := MarshalObservationJSON(inventory)
|
||||
|
||||
@@ -43,6 +43,13 @@ func (h observationDashboardHandler) ServeHTTP(w http.ResponseWriter, r *http.Re
|
||||
writeDashboardResponse(w, r, "application/x-ndjson; charset=utf-8", []byte(raw))
|
||||
case "/" + ObservationReportTextArtifact:
|
||||
writeDashboardResponse(w, r, "text/plain; charset=utf-8", []byte(RenderObservationReportSummary(h.cluster)))
|
||||
case "/" + ObservationOperatorSnapshotArtifact:
|
||||
raw, err := MarshalObservationJSON(BuildOperatorFoundationSnapshot(h.cluster))
|
||||
if err != nil {
|
||||
http.Error(w, fmt.Sprintf("render operator snapshot: %v", err), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
writeDashboardResponse(w, r, "application/json; charset=utf-8", raw)
|
||||
case "/healthz":
|
||||
writeDashboardResponse(w, r, "text/plain; charset=utf-8", []byte("ok\n"))
|
||||
default:
|
||||
|
||||
@@ -58,6 +58,8 @@ func TestObservationDashboardHandlerServesMachineArtifacts(t *testing.T) {
|
||||
assertEndpointContains(t, server.URL+"/cluster-evidence.json", `"managed_volumes"`)
|
||||
assertEndpointContains(t, server.URL+"/timeline.jsonl", `"event_id":"master-1"`)
|
||||
assertEndpointContains(t, server.URL+"/summary.txt", "managed_volume_condition=Ready")
|
||||
assertEndpointContains(t, server.URL+"/operator-snapshot.json", `"read_only": true`)
|
||||
assertEndpointContains(t, server.URL+"/operator-snapshot.json", `"mutation_allowed": false`)
|
||||
}
|
||||
|
||||
func TestObservationDashboardHandlerRejectsMutationMethods(t *testing.T) {
|
||||
|
||||
@@ -27,6 +27,13 @@ func WriteObservationReportArtifacts(outDir string, cluster ClusterEvidence) err
|
||||
if err := os.WriteFile(filepath.Join(outDir, ObservationReportTextArtifact), []byte(RenderObservationReportSummary(cluster)), 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
operatorRaw, err := MarshalObservationJSON(BuildOperatorFoundationSnapshot(cluster))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(outDir, ObservationOperatorSnapshotArtifact), operatorRaw, 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
jsonl, err := RenderClusterEventsJSONL(cluster.Events)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -46,6 +53,12 @@ func RenderObservationReportSummary(cluster ClusterEvidence) string {
|
||||
fmt.Fprintf(&b, "volumes=%d\n", len(cluster.Volumes))
|
||||
fmt.Fprintf(&b, "nodes=%d\n", len(cluster.Nodes))
|
||||
fmt.Fprintf(&b, "events=%d\n", len(cluster.Events))
|
||||
fmt.Fprintf(&b, "operator_snapshot=%s\n", ObservationOperatorSnapshotArtifact)
|
||||
if cluster.Cleanup != nil {
|
||||
for _, line := range cluster.Cleanup.ReportSummaryLines() {
|
||||
fmt.Fprintf(&b, "%s\n", line)
|
||||
}
|
||||
}
|
||||
for _, volume := range cluster.Volumes {
|
||||
fmt.Fprintf(&b, "volume=%s status=%s pvc=%s/%s primary=%s@%s frontend=%s rf=%d ack=%s\n",
|
||||
emptyAsDash(volume.VolumeID),
|
||||
@@ -115,6 +128,22 @@ func RenderObservationReportHTML(cluster ClusterEvidence) string {
|
||||
reportCard(&b, "Read Only", "true", "ok")
|
||||
b.WriteString("</div>")
|
||||
|
||||
if cluster.Cleanup != nil {
|
||||
row := cluster.Cleanup.ReportRow()
|
||||
b.WriteString("<section><h2>Lifecycle Cleanup</h2><table><thead><tr><th>Status</th><th>K8s</th><th>iSCSI</th><th>Multipath</th><th>Processes</th><th>HostPath</th><th>Failures</th><th>Evidence</th></tr></thead><tbody>")
|
||||
fmt.Fprintf(&b, "<tr><td class=\"%s\">%s</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%d</td><td>%s</td></tr>",
|
||||
row.StatusClass,
|
||||
esc(row.Status),
|
||||
row.KubernetesResidueCount,
|
||||
row.ISCSIResidueCount,
|
||||
row.MultipathResidueCount,
|
||||
row.ProcessResidueCount,
|
||||
row.HostPathResidueCount,
|
||||
row.FailureCount,
|
||||
esc(row.EvidenceRef))
|
||||
b.WriteString("</tbody></table></section>")
|
||||
}
|
||||
|
||||
b.WriteString("<section><h2>Managed Volumes</h2><table><thead><tr><th>Volume</th><th>Status</th><th>Reason</th><th>Conditions</th><th>Safe Actions</th></tr></thead><tbody>")
|
||||
for _, managed := range cluster.ManagedVolumes {
|
||||
class := "ok"
|
||||
|
||||
@@ -56,9 +56,28 @@ func TestObservationExplain_IncludesManagedVolumeProjectionAndDryRunActions(t *t
|
||||
func TestObservationReportSummary_IncludesManagedVolumeStatus(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 20, 12, 0, 0, 0, time.UTC))
|
||||
cluster.Volumes = []VolumeEvidence{healthyObservationVolume()}
|
||||
cluster.Cleanup = &CleanupEvidence{
|
||||
Status: "ok",
|
||||
KubernetesResidueCount: 0,
|
||||
ISCSIResidueCount: 0,
|
||||
MultipathResidueCount: 0,
|
||||
ProcessResidueCount: 0,
|
||||
HostPathResidueCount: 0,
|
||||
FailureCount: 0,
|
||||
EvidenceRef: "cleanup-summary.txt",
|
||||
}
|
||||
|
||||
summary := RenderObservationReportSummary(cluster)
|
||||
for _, want := range []string{
|
||||
"operator_snapshot=operator-snapshot.json",
|
||||
"cleanup_status=ok",
|
||||
"k8s_residue_count=0",
|
||||
"iscsi_residue_count=0",
|
||||
"multipath_residue_count=0",
|
||||
"process_residue_count=0",
|
||||
"hostpath_residue_count=0",
|
||||
"failure_count=0",
|
||||
"cleanup_evidence=cleanup-summary.txt",
|
||||
"volume=pvc-healthy status=ok pvc=default/mysql-data",
|
||||
"managed_volume=pvc-healthy status=ready reason=first_volume_verified",
|
||||
"managed_volume_condition=Ready status=True reason=first_volume_verified severity=info",
|
||||
@@ -73,6 +92,13 @@ func TestObservationReportSummary_IncludesManagedVolumeStatus(t *testing.T) {
|
||||
func TestObservationReportHTML_IncludesManagedVolumeConditions(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 20, 12, 0, 0, 0, time.UTC))
|
||||
cluster.Status = ObservationStatusBlocked
|
||||
cluster.Cleanup = &CleanupEvidence{
|
||||
Status: "failed",
|
||||
KubernetesResidueCount: 1,
|
||||
MultipathResidueCount: 2,
|
||||
FailureCount: 2,
|
||||
EvidenceRef: "cleanup-summary.txt",
|
||||
}
|
||||
cluster.Volumes = []VolumeEvidence{{
|
||||
VolumeID: "pvc-loopback",
|
||||
Namespace: "default",
|
||||
@@ -93,8 +119,10 @@ func TestObservationReportHTML_IncludesManagedVolumeConditions(t *testing.T) {
|
||||
|
||||
html := RenderObservationReportHTML(cluster)
|
||||
for _, want := range []string{
|
||||
"Lifecycle Cleanup",
|
||||
"Managed Volumes",
|
||||
"Managed Volume Conditions",
|
||||
"cleanup-summary.txt",
|
||||
"pvc-loopback",
|
||||
"publish_target_loopback_cross_node",
|
||||
"safe_k8s.reinstall_external_iscsi",
|
||||
@@ -131,4 +159,19 @@ func TestObservationReportArtifacts_JSONIncludesManagedVolumeProjection(t *testi
|
||||
if len(managed.Actions) == 0 || managed.Actions[0].Mode != ManagedVolumeActionModeReadOnly {
|
||||
t.Fatalf("managed actions=%+v", managed.Actions)
|
||||
}
|
||||
|
||||
raw, err = os.ReadFile(filepath.Join(dir, ObservationOperatorSnapshotArtifact))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var snapshot OperatorFoundationSnapshot
|
||||
if err := json.Unmarshal(raw, &snapshot); err != nil {
|
||||
t.Fatalf("decode operator snapshot json: %v\n%s", err, raw)
|
||||
}
|
||||
if !snapshot.ReadOnly || snapshot.Mutation.MutationAllowed {
|
||||
t.Fatalf("operator snapshot must be read-only: %+v", snapshot)
|
||||
}
|
||||
if snapshot.Cluster.VolumeCount != 1 || len(snapshot.Volumes) != 1 {
|
||||
t.Fatalf("operator snapshot missing volume evidence: %+v", snapshot)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package ops
|
||||
|
||||
const ObservationOperatorSnapshotArtifact = "operator-snapshot.json"
|
||||
|
||||
type OperatorFoundationSnapshot struct {
|
||||
APIVersion string `json:"api_version"`
|
||||
Kind string `json:"kind"`
|
||||
ReadOnly bool `json:"read_only"`
|
||||
Mutation OperatorMutationBoundary `json:"mutation"`
|
||||
CRDContract ManagedVolumeCRDContract `json:"crd_contract"`
|
||||
Cluster OperatorClusterStatus `json:"cluster"`
|
||||
Volumes []ManagedVolumeOperatorContract `json:"volumes"`
|
||||
}
|
||||
|
||||
type OperatorMutationBoundary struct {
|
||||
MutationAllowed bool `json:"mutation_allowed"`
|
||||
AllowedModes []string `json:"allowed_modes"`
|
||||
NonClaims []string `json:"non_claims"`
|
||||
}
|
||||
|
||||
type OperatorClusterStatus struct {
|
||||
Status string `json:"status"`
|
||||
VolumeCount int `json:"volume_count"`
|
||||
ReadyVolumeCount int `json:"ready_volume_count"`
|
||||
BlockedVolumeCount int `json:"blocked_volume_count"`
|
||||
StaleVolumeCount int `json:"stale_volume_count"`
|
||||
Cleanup *CleanupEvidence `json:"cleanup,omitempty"`
|
||||
Conditions []ObservationCondition `json:"conditions,omitempty"`
|
||||
NonClaims []string `json:"non_claims,omitempty"`
|
||||
}
|
||||
|
||||
func BuildOperatorFoundationSnapshot(cluster ClusterEvidence) OperatorFoundationSnapshot {
|
||||
cluster = NormalizeObservationCluster(cluster)
|
||||
snapshot := OperatorFoundationSnapshot{
|
||||
APIVersion: SwBlockVolumeAPIVersion,
|
||||
Kind: "ReadOnlyOperatorFoundationSnapshot",
|
||||
ReadOnly: true,
|
||||
Mutation: OperatorMutationBoundary{
|
||||
MutationAllowed: false,
|
||||
AllowedModes: []string{
|
||||
ManagedVolumeActionModeReadOnly,
|
||||
ManagedVolumeActionModeDryRun,
|
||||
},
|
||||
NonClaims: []string{
|
||||
"no_promote",
|
||||
"no_repair",
|
||||
"no_rebuild",
|
||||
"no_failback",
|
||||
"no_delete",
|
||||
"no_cleanup_mutation",
|
||||
},
|
||||
},
|
||||
CRDContract: ManagedVolumeCRDContractDefinition(),
|
||||
Cluster: OperatorClusterStatus{
|
||||
Status: cluster.Status,
|
||||
Cleanup: cluster.Cleanup,
|
||||
Conditions: append([]ObservationCondition(nil), cluster.Conditions...),
|
||||
NonClaims: append([]string(nil), cluster.NonClaims...),
|
||||
},
|
||||
}
|
||||
|
||||
for _, managed := range cluster.ManagedVolumes {
|
||||
contract := ManagedVolumeOperatorContractFromProjection(managed)
|
||||
snapshot.Volumes = append(snapshot.Volumes, contract)
|
||||
snapshot.Cluster.VolumeCount++
|
||||
switch managed.Status {
|
||||
case ManagedVolumeStatusReady, ManagedVolumeStatusRecovered:
|
||||
snapshot.Cluster.ReadyVolumeCount++
|
||||
case ManagedVolumeStatusBlocked, ManagedVolumeStatusInvalid, ManagedVolumeStatusUnsafe:
|
||||
snapshot.Cluster.BlockedVolumeCount++
|
||||
}
|
||||
if managed.ReasonCode == ReasonEvidenceStale || hasCondition(managed.Conditions, ConditionEvidenceStale, "True") {
|
||||
snapshot.Cluster.StaleVolumeCount++
|
||||
}
|
||||
}
|
||||
if snapshot.Cluster.StaleVolumeCount > 0 && !hasCondition(snapshot.Cluster.Conditions, ConditionEvidenceStale, "True") {
|
||||
snapshot.Cluster.Conditions = append(snapshot.Cluster.Conditions, ObservationCondition{
|
||||
Type: ConditionEvidenceStale,
|
||||
Status: "True",
|
||||
Reason: ReasonEvidenceStale,
|
||||
Severity: "warning",
|
||||
Message: "one or more managed volumes have stale or unreachable evidence",
|
||||
})
|
||||
}
|
||||
return snapshot
|
||||
}
|
||||
|
||||
func hasCondition(conditions []ObservationCondition, conditionType, status string) bool {
|
||||
for _, condition := range conditions {
|
||||
if condition.Type == conditionType && (status == "" || condition.Status == status) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestOperatorFoundationSnapshot_ReadOnlyBoundary(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 23, 20, 0, 0, 0, time.UTC))
|
||||
cluster.Volumes = []VolumeEvidence{healthyObservationVolume()}
|
||||
cluster.Cleanup = &CleanupEvidence{
|
||||
Status: "ok",
|
||||
KubernetesResidueCount: 0,
|
||||
MultipathResidueCount: 0,
|
||||
FailureCount: 0,
|
||||
EvidenceRef: "cleanup-summary.txt",
|
||||
}
|
||||
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if !snapshot.ReadOnly || snapshot.Mutation.MutationAllowed {
|
||||
t.Fatalf("snapshot must be read-only: %+v", snapshot.Mutation)
|
||||
}
|
||||
if snapshot.APIVersion != SwBlockVolumeAPIVersion || snapshot.Kind != "ReadOnlyOperatorFoundationSnapshot" {
|
||||
t.Fatalf("snapshot identity=%s/%s", snapshot.APIVersion, snapshot.Kind)
|
||||
}
|
||||
if snapshot.CRDContract.Group != "block.seaweedfs.com" || len(snapshot.CRDContract.Resources) == 0 {
|
||||
t.Fatalf("missing CRD contract: %+v", snapshot.CRDContract)
|
||||
}
|
||||
if snapshot.Cluster.VolumeCount != 1 || snapshot.Cluster.ReadyVolumeCount != 1 || snapshot.Cluster.BlockedVolumeCount != 0 {
|
||||
t.Fatalf("cluster status=%+v", snapshot.Cluster)
|
||||
}
|
||||
if snapshot.Cluster.Cleanup == nil || snapshot.Cluster.Cleanup.Status != "ok" || snapshot.Cluster.Cleanup.EvidenceRef != "cleanup-summary.txt" {
|
||||
t.Fatalf("missing cleanup evidence: %+v", snapshot.Cluster.Cleanup)
|
||||
}
|
||||
if len(snapshot.Volumes) != 1 {
|
||||
t.Fatalf("volumes=%+v", snapshot.Volumes)
|
||||
}
|
||||
for _, action := range snapshot.Volumes[0].AllowedActions {
|
||||
if action.MutationAllowed {
|
||||
t.Fatalf("operator snapshot exposed mutating action: %+v", action)
|
||||
}
|
||||
if action.Mode != ManagedVolumeActionModeReadOnly && action.Mode != ManagedVolumeActionModeDryRun {
|
||||
t.Fatalf("operator snapshot exposed unsupported action mode: %+v", action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorFoundationSnapshot_BlockedVolumeCarriesWarningEvent(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 23, 20, 0, 0, 0, time.UTC))
|
||||
cluster.Status = ObservationStatusBlocked
|
||||
cluster.Volumes = []VolumeEvidence{{
|
||||
VolumeID: "pvc-loopback",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
Status: ObservationStatusBlocked,
|
||||
Reason: ReasonPublishTargetLoopbackCrossNode,
|
||||
PrimaryReplica: "r1",
|
||||
PrimaryNode: "m01",
|
||||
PublishTarget: "127.0.0.1:3260",
|
||||
Replicas: []ReplicaEvidence{{
|
||||
ReplicaID: "r1",
|
||||
KubernetesNode: "m01",
|
||||
Observed: true,
|
||||
Role: "primary",
|
||||
FrontendAddr: "127.0.0.1:3260",
|
||||
}},
|
||||
}}
|
||||
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if snapshot.Cluster.VolumeCount != 1 || snapshot.Cluster.BlockedVolumeCount != 1 {
|
||||
t.Fatalf("cluster status=%+v", snapshot.Cluster)
|
||||
}
|
||||
if len(snapshot.Volumes) != 1 {
|
||||
t.Fatalf("volumes=%+v", snapshot.Volumes)
|
||||
}
|
||||
volume := snapshot.Volumes[0]
|
||||
if volume.Status.Status != ManagedVolumeStatusBlocked || volume.Status.ReasonCode != ReasonPublishTargetLoopbackCrossNode {
|
||||
t.Fatalf("volume status=%+v", volume.Status)
|
||||
}
|
||||
warning := false
|
||||
for _, event := range volume.Events {
|
||||
if event.Type == "Warning" && event.Reason == ReasonPublishTargetLoopbackCrossNode {
|
||||
warning = true
|
||||
}
|
||||
}
|
||||
if !warning {
|
||||
t.Fatalf("missing warning event: %+v", volume.Events)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorFoundationSnapshot_CountsStaleEvidenceVolumes(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 25, 20, 0, 0, 0, time.UTC))
|
||||
cluster.ManagedVolumes = []ManagedVolumeProjection{ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-stale",
|
||||
EvidenceStale: true,
|
||||
EvidenceStaleReason: ReasonEvidenceStale,
|
||||
EvidenceRefs: []string{"product/unreachable.txt"},
|
||||
})}
|
||||
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if snapshot.Cluster.VolumeCount != 1 || snapshot.Cluster.StaleVolumeCount != 1 {
|
||||
t.Fatalf("cluster status=%+v", snapshot.Cluster)
|
||||
}
|
||||
found := false
|
||||
for _, condition := range snapshot.Cluster.Conditions {
|
||||
if condition.Type == ConditionEvidenceStale && condition.Status == "True" && condition.Reason == ReasonEvidenceStale {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("missing cluster EvidenceStale condition: %+v", snapshot.Cluster.Conditions)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestPhase32D3ReadyStatusSurfacesAgree(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 25, 21, 0, 0, 0, time.UTC))
|
||||
cluster.Volumes = []VolumeEvidence{{
|
||||
VolumeID: "pvc-ready",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
PVName: "pvc-ready",
|
||||
ReplicationFactor: 1,
|
||||
AckProfile: "best-effort",
|
||||
Status: ObservationStatusOK,
|
||||
PrimaryReplica: "r1",
|
||||
PrimaryNode: "m02",
|
||||
PublishTarget: "127.0.0.1:3260",
|
||||
Epoch: 1,
|
||||
EndpointVersion: 1,
|
||||
}}
|
||||
cluster.ManagedVolumes = []ManagedVolumeProjection{ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-ready",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
PVName: "pvc-ready",
|
||||
ReplicationFactor: 1,
|
||||
AckProfile: "best-effort",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: "r1",
|
||||
PublishTarget: "127.0.0.1:3260",
|
||||
Epoch: 1,
|
||||
EndpointVersion: 1,
|
||||
},
|
||||
CSIStages: []CSIStageFact{{NodeName: "m02", Target: "127.0.0.1:3260"}},
|
||||
Workload: &WorkloadCheckFact{WriterVerified: true, ReaderVerified: true},
|
||||
EvidenceRefs: []string{"writer.log", "reader.log"},
|
||||
})}
|
||||
|
||||
summary := RenderObservationReportSummary(cluster)
|
||||
for _, want := range []string{
|
||||
"managed_volume=pvc-ready status=ready reason=first_volume_verified",
|
||||
"managed_volume_condition=Ready status=True reason=first_volume_verified severity=info",
|
||||
"read_only=true",
|
||||
} {
|
||||
if !strings.Contains(summary, want) {
|
||||
t.Fatalf("summary missing %q:\n%s", want, summary)
|
||||
}
|
||||
}
|
||||
|
||||
html := RenderObservationReportHTML(cluster)
|
||||
for _, want := range []string{
|
||||
"pvc-ready",
|
||||
"first_volume_verified",
|
||||
"Ready=True/first_volume_verified",
|
||||
} {
|
||||
if !strings.Contains(html, want) {
|
||||
t.Fatalf("html missing %q", want)
|
||||
}
|
||||
}
|
||||
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if !snapshot.ReadOnly || snapshot.Mutation.MutationAllowed {
|
||||
t.Fatalf("snapshot mutation boundary=%+v", snapshot.Mutation)
|
||||
}
|
||||
if snapshot.Cluster.VolumeCount != 1 || snapshot.Cluster.ReadyVolumeCount != 1 || snapshot.Cluster.BlockedVolumeCount != 0 {
|
||||
t.Fatalf("cluster status=%+v", snapshot.Cluster)
|
||||
}
|
||||
volume := snapshot.Volumes[0]
|
||||
if volume.Status.Status != ManagedVolumeStatusReady || volume.Status.ReasonCode != ReasonFirstVolumeVerified {
|
||||
t.Fatalf("volume status=%+v", volume.Status)
|
||||
}
|
||||
if !operatorContractHasCondition(volume, ConditionReady, "True", ReasonFirstVolumeVerified) {
|
||||
t.Fatalf("conditions=%+v", volume.Status.Conditions)
|
||||
}
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
NewObservationDashboardHandler(cluster).ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, "/operator-snapshot.json", nil))
|
||||
if recorder.Code != http.StatusOK || !strings.Contains(recorder.Body.String(), `"reason_code": "first_volume_verified"`) {
|
||||
t.Fatalf("dashboard operator snapshot code=%d body=%s", recorder.Code, recorder.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhase32D4BlockedStatusSurfacesAgree(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 25, 21, 10, 0, 0, time.UTC))
|
||||
cluster.Status = ObservationStatusBlocked
|
||||
cluster.Volumes = []VolumeEvidence{{
|
||||
VolumeID: "pvc-blocked",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
Status: ObservationStatusBlocked,
|
||||
Reason: ReasonCSINodeImagePullFailed,
|
||||
ReplicationFactor: 1,
|
||||
}}
|
||||
cluster.ManagedVolumes = []ManagedVolumeProjection{ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-blocked",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
KubernetesNodes: []KubernetesNodeFact{{
|
||||
NodeName: "m02",
|
||||
Ready: true,
|
||||
Schedulable: true,
|
||||
CSINodeReady: false,
|
||||
Reason: ReasonCSINodeImagePullFailed,
|
||||
Message: "CSI node image pull failed",
|
||||
}},
|
||||
EvidenceRefs: []string{"blocked-bundle/demo/kube-system-pods-deploys.txt", "blocked-bundle/explain.txt"},
|
||||
})}
|
||||
|
||||
summary := RenderObservationReportSummary(cluster)
|
||||
for _, want := range []string{
|
||||
"managed_volume=pvc-blocked status=blocked reason=csi_node_image_pull_failed",
|
||||
"managed_volume_condition=Ready status=False reason=csi_node_image_pull_failed severity=warning",
|
||||
"managed_volume_condition=Blocked status=True reason=csi_node_image_pull_failed severity=warning",
|
||||
"managed_volume_action=safe_k8s.import_csi_image mode=dry_run side_effect=safe_k8s executor=installer_or_operator",
|
||||
} {
|
||||
if !strings.Contains(summary, want) {
|
||||
t.Fatalf("summary missing %q:\n%s", want, summary)
|
||||
}
|
||||
}
|
||||
|
||||
html := RenderObservationReportHTML(cluster)
|
||||
for _, want := range []string{
|
||||
"pvc-blocked",
|
||||
"csi_node_image_pull_failed",
|
||||
"Blocked=True/csi_node_image_pull_failed",
|
||||
"safe_k8s.import_csi_image(dry_run)",
|
||||
} {
|
||||
if !strings.Contains(html, want) {
|
||||
t.Fatalf("html missing %q", want)
|
||||
}
|
||||
}
|
||||
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if snapshot.Cluster.VolumeCount != 1 || snapshot.Cluster.ReadyVolumeCount != 0 || snapshot.Cluster.BlockedVolumeCount != 1 {
|
||||
t.Fatalf("cluster status=%+v", snapshot.Cluster)
|
||||
}
|
||||
volume := snapshot.Volumes[0]
|
||||
if volume.Status.Status != ManagedVolumeStatusBlocked || volume.Status.ReasonCode != ReasonCSINodeImagePullFailed {
|
||||
t.Fatalf("volume status=%+v", volume.Status)
|
||||
}
|
||||
if !operatorContractHasCondition(volume, ConditionReady, "False", ReasonCSINodeImagePullFailed) ||
|
||||
!operatorContractHasCondition(volume, ConditionBlocked, "True", ReasonCSINodeImagePullFailed) {
|
||||
t.Fatalf("conditions=%+v", volume.Status.Conditions)
|
||||
}
|
||||
for _, action := range volume.AllowedActions {
|
||||
if action.MutationAllowed {
|
||||
t.Fatalf("blocked surface exposed mutating action: %+v", action)
|
||||
}
|
||||
}
|
||||
|
||||
recorder := httptest.NewRecorder()
|
||||
NewObservationDashboardHandler(cluster).ServeHTTP(recorder, httptest.NewRequest(http.MethodGet, "/operator-snapshot.json", nil))
|
||||
body := recorder.Body.String()
|
||||
if recorder.Code != http.StatusOK ||
|
||||
!strings.Contains(body, `"reason_code": "csi_node_image_pull_failed"`) ||
|
||||
!strings.Contains(body, `"mutation_allowed": false`) {
|
||||
t.Fatalf("dashboard operator snapshot code=%d body=%s", recorder.Code, body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhase32D5RestartPromotionStatusSurfacesAgree(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 25, 22, 0, 0, 0, time.UTC))
|
||||
cluster.Volumes = []VolumeEvidence{{
|
||||
VolumeID: "pvc-restart",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
PVName: "pvc-restart",
|
||||
ReplicationFactor: 3,
|
||||
AckProfile: "sync-quorum",
|
||||
Status: ObservationStatusOK,
|
||||
Reason: "authority_persisted",
|
||||
PrimaryReplica: "r2",
|
||||
PrimaryNode: "m02",
|
||||
PublishTarget: "192.168.1.184:3260",
|
||||
Epoch: 2,
|
||||
EndpointVersion: 1,
|
||||
}}
|
||||
cluster.ManagedVolumes = []ManagedVolumeProjection{ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: "pvc-restart",
|
||||
Namespace: "default",
|
||||
PVCName: "demo-pvc",
|
||||
PVName: "pvc-restart",
|
||||
ReplicationFactor: 3,
|
||||
AckProfile: "sync-quorum",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: "r2",
|
||||
PreviousPrimary: "r1",
|
||||
PublishTarget: "192.168.1.184:3260",
|
||||
Epoch: 2,
|
||||
EndpointVersion: 1,
|
||||
RequiredFrontierKnown: true,
|
||||
RequiredFrontierLSN: 52,
|
||||
},
|
||||
Replicas: []ReplicaFact{{
|
||||
ReplicaID: "r1",
|
||||
KubernetesNode: "m01",
|
||||
Role: "unavailable",
|
||||
Observed: false,
|
||||
StalePrimaryFenced: true,
|
||||
}, {
|
||||
ReplicaID: "r2",
|
||||
KubernetesNode: "m02",
|
||||
Role: "primary",
|
||||
Observed: true,
|
||||
DurableFrontierKnown: true,
|
||||
DurableFrontierLSN: 52,
|
||||
FrontendAddr: "192.168.1.184:3260",
|
||||
}, {
|
||||
ReplicaID: "r3",
|
||||
KubernetesNode: "tp01",
|
||||
Role: "replica",
|
||||
Observed: true,
|
||||
DurableFrontierKnown: true,
|
||||
DurableFrontierLSN: 52,
|
||||
}},
|
||||
CSIStages: []CSIStageFact{{
|
||||
NodeName: "m02",
|
||||
Target: "192.168.1.184:3260",
|
||||
Epoch: 2,
|
||||
EndpointVersion: 1,
|
||||
Reattach: true,
|
||||
}},
|
||||
Workload: &WorkloadCheckFact{ReaderVerified: true},
|
||||
EvidenceRefs: []string{"restart-promotion-summary.txt", "reader-after-restart.log"},
|
||||
})}
|
||||
|
||||
summary := RenderObservationReportSummary(cluster)
|
||||
for _, want := range []string{
|
||||
"volume=pvc-restart status=ok pvc=default/demo-pvc primary=r2@m02 frontend=192.168.1.184:3260 rf=3 ack=sync-quorum",
|
||||
"managed_volume=pvc-restart status=recovered reason=csi_reattach_recovered",
|
||||
"managed_volume_condition=Ready status=True reason=csi_reattach_recovered severity=info",
|
||||
"managed_volume_condition=Recovered status=True reason=csi_reattach_recovered severity=info",
|
||||
} {
|
||||
if !strings.Contains(summary, want) {
|
||||
t.Fatalf("summary missing %q:\n%s", want, summary)
|
||||
}
|
||||
}
|
||||
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if snapshot.Cluster.VolumeCount != 1 || snapshot.Cluster.ReadyVolumeCount != 1 || snapshot.Cluster.BlockedVolumeCount != 0 {
|
||||
t.Fatalf("cluster status=%+v", snapshot.Cluster)
|
||||
}
|
||||
volume := snapshot.Volumes[0]
|
||||
if volume.Status.Status != ManagedVolumeStatusRecovered || volume.Status.ReasonCode != ReasonCSIReattachRecovered {
|
||||
t.Fatalf("volume status=%+v", volume.Status)
|
||||
}
|
||||
if !operatorContractHasCondition(volume, ConditionRecovered, "True", ReasonCSIReattachRecovered) {
|
||||
t.Fatalf("conditions=%+v", volume.Status.Conditions)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPhase32D6MultiVolumeStatusSurfacesKeepVolumesIndependent(t *testing.T) {
|
||||
cluster := NewClusterEvidence(time.Date(2026, 5, 25, 22, 15, 0, 0, time.UTC))
|
||||
cluster.Volumes = []VolumeEvidence{
|
||||
phase32VolumeEvidence("pvc-a", "app-a", "r1", "m01", "192.168.1.181:3260"),
|
||||
phase32VolumeEvidence("pvc-b", "app-b", "r2", "m02", "192.168.1.184:3260"),
|
||||
phase32VolumeEvidence("pvc-c", "app-c", "r3", "tp01", "192.168.1.188:3260"),
|
||||
}
|
||||
cluster.ManagedVolumes = []ManagedVolumeProjection{
|
||||
phase32ReadyManagedProjection("pvc-a", "app-a", "r1", "192.168.1.181:3260"),
|
||||
phase32ReadyManagedProjection("pvc-b", "app-b", "r2", "192.168.1.184:3260"),
|
||||
phase32ReadyManagedProjection("pvc-c", "app-c", "r3", "192.168.1.188:3260"),
|
||||
}
|
||||
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if snapshot.Cluster.VolumeCount != 3 || snapshot.Cluster.ReadyVolumeCount != 3 || snapshot.Cluster.BlockedVolumeCount != 0 {
|
||||
t.Fatalf("cluster status=%+v", snapshot.Cluster)
|
||||
}
|
||||
seenVolumes := map[string]bool{}
|
||||
seenTargets := map[string]bool{}
|
||||
for _, volume := range snapshot.Volumes {
|
||||
if seenVolumes[volume.Status.VolumeID] {
|
||||
t.Fatalf("duplicate volume in snapshot: %+v", snapshot.Volumes)
|
||||
}
|
||||
seenVolumes[volume.Status.VolumeID] = true
|
||||
if volume.Status.Status != ManagedVolumeStatusReady || volume.Status.ReasonCode != ReasonFirstVolumeVerified {
|
||||
t.Fatalf("bad managed volume=%+v", volume.Status)
|
||||
}
|
||||
if !operatorContractHasCondition(volume, ConditionReady, "True", ReasonFirstVolumeVerified) {
|
||||
t.Fatalf("conditions=%+v", volume.Status.Conditions)
|
||||
}
|
||||
}
|
||||
for _, volume := range cluster.Volumes {
|
||||
if seenTargets[volume.PublishTarget] {
|
||||
t.Fatalf("duplicate publish target: %+v", cluster.Volumes)
|
||||
}
|
||||
seenTargets[volume.PublishTarget] = true
|
||||
}
|
||||
|
||||
summary := RenderObservationReportSummary(cluster)
|
||||
for _, want := range []string{
|
||||
"volume=pvc-a status=ok pvc=default/app-a primary=r1@m01 frontend=192.168.1.181:3260 rf=3 ack=sync-quorum",
|
||||
"volume=pvc-b status=ok pvc=default/app-b primary=r2@m02 frontend=192.168.1.184:3260 rf=3 ack=sync-quorum",
|
||||
"volume=pvc-c status=ok pvc=default/app-c primary=r3@tp01 frontend=192.168.1.188:3260 rf=3 ack=sync-quorum",
|
||||
} {
|
||||
if !strings.Contains(summary, want) {
|
||||
t.Fatalf("summary missing %q:\n%s", want, summary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func operatorContractHasCondition(contract ManagedVolumeOperatorContract, conditionType, status, reason string) bool {
|
||||
for _, condition := range contract.Status.Conditions {
|
||||
if condition.Type == conditionType && condition.Status == status && condition.Reason == reason {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func phase32VolumeEvidence(volumeID, pvc, primary, node, frontend string) VolumeEvidence {
|
||||
return VolumeEvidence{
|
||||
VolumeID: volumeID,
|
||||
Namespace: "default",
|
||||
PVCName: pvc,
|
||||
PVName: volumeID,
|
||||
ReplicationFactor: 3,
|
||||
AckProfile: "sync-quorum",
|
||||
Status: ObservationStatusOK,
|
||||
PrimaryReplica: primary,
|
||||
PrimaryNode: node,
|
||||
PublishTarget: frontend,
|
||||
Epoch: 1,
|
||||
EndpointVersion: 1,
|
||||
}
|
||||
}
|
||||
|
||||
func phase32ReadyManagedProjection(volumeID, pvc, primary, frontend string) ManagedVolumeProjection {
|
||||
return ProjectManagedVolume(ManagedVolumeFacts{
|
||||
VolumeID: volumeID,
|
||||
Namespace: "default",
|
||||
PVCName: pvc,
|
||||
PVName: volumeID,
|
||||
ReplicationFactor: 3,
|
||||
AckProfile: "sync-quorum",
|
||||
PVC: &PVCFact{Phase: "Bound"},
|
||||
Authority: &AuthorityFact{
|
||||
PrimaryReplica: primary,
|
||||
PublishTarget: frontend,
|
||||
Epoch: 1,
|
||||
EndpointVersion: 1,
|
||||
},
|
||||
Replicas: []ReplicaFact{{
|
||||
ReplicaID: primary,
|
||||
Role: "primary",
|
||||
Observed: true,
|
||||
DurableFrontierKnown: true,
|
||||
DurableFrontierLSN: 44,
|
||||
FrontendAddr: frontend,
|
||||
}},
|
||||
CSIStages: []CSIStageFact{{Target: frontend}},
|
||||
Workload: &WorkloadCheckFact{WriterVerified: true, ReaderVerified: true},
|
||||
EvidenceRefs: []string{volumeID + "/writer.log", volumeID + "/reader.log"},
|
||||
})
|
||||
}
|
||||
@@ -1,5 +1,11 @@
|
||||
# Seaweed Block Architecture
|
||||
|
||||
> Document status: engineering architecture reference. Some operational
|
||||
> examples in this file may lag the latest alpha release gates. Use
|
||||
> [`quickstart-kubernetes.md`](quickstart-kubernetes.md) and
|
||||
> [`releases/README.md`](releases/README.md) as the source of truth for current
|
||||
> user-facing install, cleanup, and capability claims.
|
||||
|
||||
`seaweed-block` is a lightweight Kubernetes block-storage project. The current
|
||||
alpha MVP is intentionally narrow: it proves the main control/data path before
|
||||
expanding into a full storage operator.
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# Seaweed Block Developer Architecture
|
||||
|
||||
> Document status: contributor architecture reference. It explains module
|
||||
> boundaries and design rules, but it is not the release-claim source. Use
|
||||
> [`quickstart-kubernetes.md`](quickstart-kubernetes.md) and
|
||||
> [`releases/README.md`](releases/README.md) for the current validated user
|
||||
> path and non-claims.
|
||||
|
||||
This document is for developers who want to understand or contribute to
|
||||
`seaweed-block`. It describes the current alpha architecture without relying on
|
||||
internal planning labels.
|
||||
|
||||
@@ -11,7 +11,8 @@ This directory contains public and technical documentation.
|
||||
| `runtime-state-machines.md` | Mermaid state-machine and loop overview. |
|
||||
| `roadmap.md` | Alpha roadmap and non-claims. |
|
||||
| `quickstart-kubernetes.md` | First-volume Kubernetes quickstart. |
|
||||
| `operations-v1.md` | V1 alpha operations manual for install, first PVC, inventory, cleanup, and support bundles. |
|
||||
| `user-capabilities.md` | User-facing current capabilities, operations commands, status vocabulary, and non-claims. |
|
||||
| `operations-v1.md` | Legacy V1 alpha operations manual; use quickstart and release notes for current claims. |
|
||||
| `kubernetes-app-demo.md` | Presentation-friendly Kubernetes app + PVC demo. |
|
||||
|
||||
## Calibration Evidence
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Kubernetes Quick Start
|
||||
|
||||
This guide is the v0.3 alpha path for Seaweed Block on Kubernetes.
|
||||
This guide is the current alpha path for Seaweed Block on Kubernetes.
|
||||
|
||||
It shows the user loop:
|
||||
|
||||
@@ -15,7 +15,9 @@ generate Helm values
|
||||
```
|
||||
|
||||
The current quickstart is for supported test clusters, not production. For
|
||||
deeper operational detail, see [`operations-v1.md`](operations-v1.md).
|
||||
the release boundary and exact QA evidence, see
|
||||
[`docs/releases/README.md`](releases/README.md). The top-level README contains
|
||||
the current operations command matrix.
|
||||
|
||||
## What This Proves
|
||||
|
||||
@@ -27,10 +29,13 @@ The quickstart proves:
|
||||
- A replacement reader pod can mount the same PVC and verify the same data.
|
||||
- Product-owned status evidence, a local read-only report, and a local
|
||||
read-only dashboard are available.
|
||||
- The report/dashboard include `operator-snapshot.json`, a read-only
|
||||
operator-facing status projection. It is not a mutating operator.
|
||||
- The example resources and host-side residue are cleaned up.
|
||||
|
||||
It does not prove production HA, backup/restore, upgrade safety, broad platform
|
||||
compatibility, operator lifecycle, mutating admin workflows, or production UI.
|
||||
It does not prove production HA, backup/restore, broad upgrade safety, broad
|
||||
platform compatibility, mutating operator lifecycle, mutating admin workflows,
|
||||
or production UI.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
@@ -80,8 +85,8 @@ From the repository root:
|
||||
export KUBECONFIG="${KUBECONFIG:-/etc/rancher/k3s/k3s.yaml}"
|
||||
sw-block ops generate-helm-values \
|
||||
--out values.day1.yaml \
|
||||
--image ghcr.io/seaweedfs/seaweed-block:sha-28a99ce4f644 \
|
||||
--csi-image ghcr.io/seaweedfs/seaweed-block-csi:sha-28a99ce4f644
|
||||
--image ghcr.io/seaweedfs/seaweed-block:sha-6260e46fd3be \
|
||||
--csi-image ghcr.io/seaweedfs/seaweed-block-csi:sha-6260e46fd3be
|
||||
```
|
||||
|
||||
The `KUBECONFIG` fallback above is the common k3s path. Non-k3s users should
|
||||
@@ -129,7 +134,19 @@ sw-block ops generate-helm-values \
|
||||
--csi-image ghcr.io/seaweedfs/seaweed-block-csi:sha-<commit>
|
||||
```
|
||||
|
||||
Current validated v0.3 walkthrough image tag: `sha-28a99ce4f644`.
|
||||
Current validated alpha image tag:
|
||||
`sha-6260e46fd3be`.
|
||||
|
||||
Published image digests:
|
||||
|
||||
```text
|
||||
seaweed-block
|
||||
index: sha256:ef9c60f82c36f22360b10faafd32caf807f98ac0ea86c0365c0d0836e5f67110
|
||||
linux/amd64: sha256:36481cbc1fc98fafdfa386823e0e5906785cb6f35748ef698ff1cec39bb40464
|
||||
seaweed-block-csi
|
||||
index: sha256:b160ceee874dc6743074ef6b6735ccf05914c1de5951972922f6d3779bc73592
|
||||
linux/amd64: sha256:82e41b7ef92ad8db38b6927e334cc1d564b1012ad916e9bde2e882cece680be8
|
||||
```
|
||||
|
||||
Mutable `:alpha` is a smoke/demo tag only. Do not use it as release evidence
|
||||
unless the publish commit is known.
|
||||
@@ -211,6 +228,7 @@ status_evidence=status/cluster-evidence.json,status/inventory
|
||||
cluster_evidence=status/cluster-evidence.json
|
||||
inventory_bundle=status/inventory
|
||||
status_report=status/report/index.html
|
||||
operator_snapshot=status/report/operator-snapshot.json
|
||||
cleanup_status=ok
|
||||
```
|
||||
|
||||
@@ -233,11 +251,24 @@ Expected files:
|
||||
index.html
|
||||
cluster-evidence.json
|
||||
timeline.jsonl
|
||||
operator-snapshot.json
|
||||
summary.txt
|
||||
```
|
||||
|
||||
`sw-block ops report` writes static artifacts. `sw-block ops dashboard` serves
|
||||
the same evidence locally over HTTP.
|
||||
the same evidence locally over HTTP. `operator-snapshot.json` uses the same
|
||||
ManagedVolume status vocabulary as the report/dashboard and is the status-only
|
||||
foundation for future Kubernetes operator work.
|
||||
|
||||
Important status vocabulary:
|
||||
|
||||
- `Ready=True reason=first_volume_verified` means the report has positive
|
||||
writer/reader evidence for the volume.
|
||||
- `Blocked=True reason=<stable_reason_code>` means the product found a known
|
||||
blocker, such as `csi_node_image_pull_failed`.
|
||||
- `EvidenceStale=True` or `Ready=Unknown` means the evidence is missing,
|
||||
stale, or still reconverging. The alpha status surface should not claim
|
||||
`Ready=True` without current evidence.
|
||||
|
||||
Serve the collected bundle:
|
||||
|
||||
@@ -348,22 +379,35 @@ the alpha stack:
|
||||
```bash
|
||||
helm uninstall sw-block --namespace kube-system
|
||||
bash scripts/uninstall-k8s-alpha.sh "$PWD"
|
||||
bash scripts/verify-helm-cleanup.sh
|
||||
```
|
||||
|
||||
Verify:
|
||||
The uninstall script removes Kubernetes resources and scrubs Seaweed Block
|
||||
iSCSI sessions and iSCSI node DB records. The verifier checks the same residue
|
||||
classes used by release QA.
|
||||
|
||||
Manual spot checks:
|
||||
|
||||
```bash
|
||||
kubectl get sc | grep sw-block || echo "no sw-block StorageClass"
|
||||
kubectl get deploy -A | grep sw-block || echo "no sw-block deployments"
|
||||
sudo iscsiadm -m session || true
|
||||
sudo iscsiadm -m node | grep io.seaweedfs || echo "no Seaweed Block iSCSI node records"
|
||||
```
|
||||
|
||||
Expected clean state:
|
||||
|
||||
```text
|
||||
cleanup_status=ok
|
||||
k8s_residue_count=0
|
||||
iscsi_residue_count=0
|
||||
multipath_residue_count=0
|
||||
process_residue_count=0
|
||||
hostpath_residue_count=0
|
||||
no sw-block StorageClass
|
||||
no sw-block deployments
|
||||
iscsiadm: No active sessions.
|
||||
no Seaweed Block iSCSI node records
|
||||
```
|
||||
|
||||
Do not run broad cluster cleanup commands in a shared cluster unless you know no
|
||||
@@ -375,7 +419,8 @@ other run owns the resources.
|
||||
- The dashboard is local and read-only, not a production hosted UI.
|
||||
- Mutating admin workflows are not exposed: no promote, repair, rebuild,
|
||||
failback, delete, backup, restore, or cleanup button.
|
||||
- Upgrade and rollback safety are not claimed.
|
||||
- Broad upgrade and rollback safety are not claimed beyond the gated alpha
|
||||
smoke path.
|
||||
- Backup, snapshot, and restore are not claimed.
|
||||
- Broad distro/kernel/initiator compatibility is not claimed.
|
||||
- Performance, RTO, and SLO numbers are not claimed.
|
||||
|
||||
@@ -7,6 +7,10 @@ is still outside the supported boundary.
|
||||
- [v0.1 Alpha — Kubernetes Block Foundation](v0.1-alpha.md)
|
||||
- [v0.2 Alpha — Day-1 Activation And First Volume](v0.2-alpha.md)
|
||||
- [v0.3 Alpha — Helm Install And Observable First Volume](v0.3-alpha.md)
|
||||
- [v0.3.1 Alpha — Helm Lifecycle Hardening](v0.3.1-alpha.md)
|
||||
- [v0.3.2 Alpha — Multi-Volume HA Independence](v0.3.2-alpha.md)
|
||||
- [v0.3.3 Alpha — Productized Operations And Read-Only Operator Foundation](v0.3.3-alpha.md)
|
||||
- [v0.3.4 Alpha — Status Surface Hardening And Strict New-User Path](v0.3.4-alpha.md)
|
||||
|
||||
## Version Boundary
|
||||
|
||||
@@ -20,7 +24,23 @@ is still outside the supported boundary.
|
||||
- `v0.3-alpha` is the Helm-first alpha loop: generated chart values, Helm
|
||||
install, first PVC, writer/reader verification, local read-only
|
||||
report/dashboard, and cleanup verification.
|
||||
- `v0.3.1-alpha` hardens the Helm alpha loop with chart hygiene, a narrow
|
||||
upgrade/rollback smoke, three-PVC Day-1 smoke, and cold support-bundle
|
||||
replay.
|
||||
- `v0.3.2-alpha` adds scenario-gated RF=3 multi-volume HA independence:
|
||||
three PVC-backed volumes, per-volume CSI reattach recovery, mounted
|
||||
transparent failover, interleaved failover isolation, and cleanup hardening.
|
||||
- `v0.3.3-alpha` is the Phase 28 packaging target for productized
|
||||
operations: stable ManagedVolume vocabulary, CRD/Condition/Event contract,
|
||||
read-only operator snapshot, report/dashboard alignment, and close-gate QA.
|
||||
D12 close passed on 2026-05-24; immutable GHCR image pins are recorded in
|
||||
the v0.3.3 release note.
|
||||
- `v0.3.4-alpha` hardens the status surface and release walkthrough:
|
||||
happy/blocked/restart/multi-volume/stale-evidence surfaces agree, support
|
||||
bundle replay prefers the freshest evidence, and the documented cleanup path
|
||||
scrubs iSCSI node DB residue.
|
||||
|
||||
Operator packaging is not included in these alphas. v0.3 introduces Helm as
|
||||
the preferred Kubernetes alpha install path; the script path remains available
|
||||
for development and fallback validation.
|
||||
Mutating operator packaging is not included in these alphas. v0.3 introduces
|
||||
Helm as the preferred Kubernetes alpha install path; the script path remains
|
||||
available for development and fallback validation. The first operator-facing
|
||||
surface is read-only/status-first.
|
||||
@@ -0,0 +1,92 @@
|
||||
# v0.3.1 Alpha - Helm Lifecycle Hardening
|
||||
|
||||
## Summary
|
||||
|
||||
Seaweed Block v0.3.1 alpha hardens the v0.3 Helm-first Kubernetes path. The
|
||||
release remains alpha, but the install loop now has gated evidence for chart
|
||||
hygiene, a narrow upgrade/rollback smoke, multiple small PVCs, and cold
|
||||
support-bundle replay.
|
||||
|
||||
The release boundary is:
|
||||
|
||||
```text
|
||||
generate Helm values
|
||||
-> helm install
|
||||
-> first PVC and multiple PVC smoke
|
||||
-> read-only report/dashboard/support bundle
|
||||
-> one upgrade/rollback smoke with existing PVC data check
|
||||
-> helm uninstall + host cleanup verification
|
||||
```
|
||||
|
||||
## User-Visible Additions
|
||||
|
||||
- Helm chart hygiene gate: `helm lint`, `helm template`, chart package, and
|
||||
chart metadata are validated together.
|
||||
- Narrow Helm lifecycle smoke: install, first PVC, upgrade, reader check,
|
||||
rollback, reader check, uninstall.
|
||||
- Multi-volume Day-1 smoke: three PVCs bind, three writers verify data, three
|
||||
readers verify persisted bytes, and `sw-block ops report` lists three
|
||||
ManagedVolume rows.
|
||||
- Support-bundle collector:
|
||||
|
||||
```bash
|
||||
bash scripts/collect-helm-support-bundle.sh "$PWD"
|
||||
```
|
||||
|
||||
It captures Helm metadata, Kubernetes snapshots, logs, iSCSI state, and
|
||||
replayed read-only `sw-block ops report/explain/timeline --from-bundle`
|
||||
artifacts.
|
||||
|
||||
## Validated Gates
|
||||
|
||||
| Gate | Run | Result |
|
||||
|---|---:|---|
|
||||
| Chart release hygiene | `20260522-131641-7a61` | PASS, 15/15 |
|
||||
| Helm upgrade / rollback smoke | `20260522-131951-a6d4` | PASS, 27/27 |
|
||||
| Multi-volume Day-1 smoke | `20260522-152903-1116` | PASS, 29/29 |
|
||||
| Helm support bundle diagnostics | `20260522-153929-93a3` | PASS, 38/38 |
|
||||
|
||||
Published image floor:
|
||||
|
||||
```text
|
||||
ghcr.io/seaweedfs/seaweed-block:sha-d4822bf02617
|
||||
ghcr.io/seaweedfs/seaweed-block-csi:sha-d4822bf02617
|
||||
```
|
||||
|
||||
Published digests:
|
||||
|
||||
```text
|
||||
seaweed-block sha256:72dd6da085bb756d443eebe1dbaec431535ac71f5b99c8cdd98c76aea9d45f8c
|
||||
seaweed-block-csi sha256:bba57b3ea34845511e8ae828248d5461674606c3b0fe97c49fb0986af086d243
|
||||
```
|
||||
|
||||
The mutable `:alpha` tags were also moved to the same images, but release
|
||||
validation should use the immutable `sha-d4822bf02617` tags.
|
||||
|
||||
## Current Claim
|
||||
|
||||
Seaweed Block v0.3.1 alpha provides a Helm-based Kubernetes alpha loop with
|
||||
additional lifecycle confidence:
|
||||
|
||||
- chart renders and packages cleanly,
|
||||
- one existing PVC survives a gated Helm upgrade/rollback smoke,
|
||||
- a small three-PVC workload verifies writer/reader persistence,
|
||||
- read-only report/dashboard/support-bundle evidence can be replayed cold,
|
||||
- blocked ImagePullBackOff evidence explains itself from a saved bundle,
|
||||
- uninstall plus host cleanup leaves no active iSCSI sessions or sw-block
|
||||
processes.
|
||||
|
||||
## Explicit Non-Claims
|
||||
|
||||
- Not production-ready.
|
||||
- No operator lifecycle or CRDs.
|
||||
- No broad upgrade safety beyond the single gated smoke path.
|
||||
- No mutating admin UI workflows such as promote, repair, rebuild, failback,
|
||||
backup, restore, or delete.
|
||||
- Cleanup remains scripted/TestOps, not a dashboard button or operator
|
||||
workflow.
|
||||
- No backup, snapshot, or restore workflow.
|
||||
- No broad distro/kernel/initiator compatibility matrix.
|
||||
- No performance, RTO, or SLO claim.
|
||||
- No new recovery semantics beyond previously closed recovery plans.
|
||||
- No production hosted dashboard; the dashboard is local, read-only, and alpha.
|
||||
@@ -0,0 +1,103 @@
|
||||
# v0.3.2 Alpha - Multi-Volume HA Independence
|
||||
|
||||
## Summary
|
||||
|
||||
Seaweed Block v0.3.2 alpha adds gated multi-volume HA evidence on top of the
|
||||
v0.3 Helm-first Kubernetes path and the v0.3.1 lifecycle hardening work.
|
||||
|
||||
The release boundary is:
|
||||
|
||||
```text
|
||||
Helm install RF=3 sync-quorum stack
|
||||
-> create three PVC-backed volumes
|
||||
-> verify three independent ManagedVolume rows
|
||||
-> prove per-volume CSI reattach recovery
|
||||
-> prove per-volume mounted transparent failover through iSCSI ALUA/dm-multipath
|
||||
-> prove two interleaved volume-primary failures do not disturb the third volume
|
||||
-> cleanup verification
|
||||
```
|
||||
|
||||
This remains an alpha release. The claim is bounded to the gated 3-node lab and
|
||||
N=3 PVCs.
|
||||
|
||||
## User-Visible Additions
|
||||
|
||||
- Multi-volume RF=3 readiness gate: three PVCs bind, write, read, and report as
|
||||
independent ManagedVolume rows.
|
||||
- Per-volume CSI reattach recovery gate: each volume's primary can be stopped
|
||||
and the volume recovers through pod recreate while other volumes remain
|
||||
stable.
|
||||
- Per-volume mounted transparent failover gate: each mounted writer pod keeps
|
||||
the same pod UID and verifies old/new data after failover through
|
||||
dm-multipath.
|
||||
- Interleaved failover gate: two volumes lose primaries within a sub-second
|
||||
window and recover independently while the third mounted volume stays stable
|
||||
and writable.
|
||||
|
||||
## Validated Gates
|
||||
|
||||
| Gate | QA Run | Result |
|
||||
|---|---:|---|
|
||||
| Multi-volume RF=3 readiness | `20260523-094437-c24c` | PASS, 35/35 |
|
||||
| Multi-volume CSI reattach failover | `20260523-094707-bbf5` | PASS, 29/29 |
|
||||
| Multi-volume mounted transparent failover | `20260523-095122-a5c4` | PASS, 47/47 |
|
||||
| Multi-volume interleaved failover | `20260523-095509-4d02` | PASS, 55/55 |
|
||||
|
||||
Total independent QA rerun: 166/166 actions PASS.
|
||||
|
||||
## Current Claim
|
||||
|
||||
Seaweed Block v0.3.2 alpha provides scenario-gated multi-volume HA independence:
|
||||
|
||||
- N=3 PVCs at RF=3 sync-quorum can coexist on a 3-node lab.
|
||||
- Each volume has independent primary / replica / frontend assignment.
|
||||
- CSI reattach failover works per volume without cross-interference.
|
||||
- Mounted transparent failover works per volume without pod recreate when
|
||||
Stage 2 iSCSI ALUA/dm-multipath is enabled.
|
||||
- Two concurrent volume-primary failures within a sub-second window resolve
|
||||
independently while a third volume remains stable and writable.
|
||||
- Stale-primary I/O success count is zero in the gated failover paths. A
|
||||
post-close D5 hardening rerun measures this with a bounded direct-read probe
|
||||
against the old primary by-path, instead of accepting a scripted constant.
|
||||
- iSCSI ALUA path-state evidence is now measured per target volume in the D6
|
||||
hardening rerun: old primary is active/optimized before failover, promoted
|
||||
replica is standby before failover, and promoted replica becomes
|
||||
active/optimized after failover.
|
||||
- A D7 flake-matrix wrapper now exists and has a 3-iteration D4 dev pass with
|
||||
`flake_rate_percent=0`; release-grade stability still requires the planned
|
||||
N>=5 QA/nightly matrix.
|
||||
|
||||
## Explicit Non-Claims
|
||||
|
||||
- Not production-ready.
|
||||
- No N > 3 multi-volume claim.
|
||||
- No arbitrary Kubernetes node-loss claim for multi-volume.
|
||||
- No performance, RTO, or SLO claim.
|
||||
- No NVMe ANA parity for multi-volume mounted failover.
|
||||
- No operator lifecycle or CRDs.
|
||||
- No backup, snapshot, or restore workflow.
|
||||
- No mutating admin UI workflows such as promote, repair, rebuild, failback,
|
||||
backup, restore, or delete.
|
||||
- Cleanup remains scripted/TestOps, not a dashboard button or operator
|
||||
workflow.
|
||||
|
||||
## Known Follow-Up
|
||||
|
||||
QA found two stale dm-multipath maps after all four Phase 27 runs. Active iSCSI
|
||||
sessions, iSCSI node records, Helm resources, Kubernetes pods, Deployments, and
|
||||
product processes were clean, so this did not block Phase 27. It should be
|
||||
closed before widening cleanup claims:
|
||||
|
||||
```text
|
||||
extend scripts/verify-helm-cleanup.sh to assert no sw-block multipath maps
|
||||
remain after mounted failover cleanup
|
||||
```
|
||||
|
||||
## Image Guidance
|
||||
|
||||
Phase 27 QA used locally built TestOps images. For externally consumable
|
||||
immutable GHCR image guidance, use the current validated alpha release note:
|
||||
[v0.3.4-alpha.md](v0.3.4-alpha.md).
|
||||
|
||||
Mutable `:alpha` remains a smoke/demo tag only. Release validation should use
|
||||
immutable `sha-<commit>` tags.
|
||||
@@ -0,0 +1,143 @@
|
||||
# v0.3.3 Alpha - Productized Operations And Read-Only Operator Foundation
|
||||
|
||||
Status: final alpha release note for Phase 28. D12 close passed on
|
||||
2026-05-24. Immutable GHCR image tags for the Phase 28 close commit are
|
||||
published and pinned below. D13 release-path QA passed on 2026-05-24.
|
||||
|
||||
## Summary
|
||||
|
||||
Seaweed Block v0.3.3 alpha is the packaging target for the Phase 28
|
||||
productized operations work.
|
||||
|
||||
The release boundary is:
|
||||
|
||||
```text
|
||||
Helm install
|
||||
-> first PVC and multi-volume smoke
|
||||
-> product-owned ManagedVolume state
|
||||
-> read-only report/dashboard/support bundle
|
||||
-> operator-snapshot.json for future Kubernetes operator status
|
||||
-> cleanup verifier
|
||||
-> QA/PM close
|
||||
```
|
||||
|
||||
This is not a production operator release. The operator foundation is
|
||||
status/read-only only.
|
||||
|
||||
## User-Visible Additions
|
||||
|
||||
- Stable ManagedVolume operations vocabulary shared by report, dashboard,
|
||||
support bundle, explain output, and future operator status.
|
||||
- Kubernetes-native CRD / Condition / Event contract for future status-only
|
||||
operator work.
|
||||
- New read-only operator foundation artifact:
|
||||
|
||||
```text
|
||||
operator-snapshot.json
|
||||
```
|
||||
|
||||
- `sw-block ops report` writes the operator snapshot beside:
|
||||
- `index.html`
|
||||
- `cluster-evidence.json`
|
||||
- `timeline.jsonl`
|
||||
- `summary.txt`
|
||||
- `sw-block ops dashboard` serves:
|
||||
- `/operator-snapshot.json`
|
||||
- Cleanup verifier now covers iSCSI sessions, iSCSI node DB, Kubernetes
|
||||
resources, product processes, dm-multipath maps, and `dmsetup` residue.
|
||||
- Phase 27 mounted/interleaved multi-volume failover gates have Phase 28 N=5
|
||||
flake matrix evidence with `flake_rate_percent=0`.
|
||||
|
||||
## Validated Evidence
|
||||
|
||||
Development-scoped tests:
|
||||
|
||||
```text
|
||||
go test ./core/ops
|
||||
go test ./cmd/sw-block
|
||||
```
|
||||
|
||||
Operational reliability QA:
|
||||
|
||||
| Gate | QA Evidence | Result |
|
||||
|---|---:|---|
|
||||
| Cleanup residue chain | `20260523-210004-bed1` | PASS, 13/13 |
|
||||
| D3 mounted failover flake matrix | N=5 | PASS, 5/5, `flake_rate_percent=0` |
|
||||
| D4 interleaved failover flake matrix | N=5 | PASS, 5/5, `flake_rate_percent=0` |
|
||||
|
||||
D12 productized-operations close QA:
|
||||
|
||||
| Gate | QA Evidence | Result |
|
||||
|---|---:|---|
|
||||
| Helm first-volume via `sw-block` CLI | `20260524-103052-beb2` | PASS |
|
||||
| Helm multi-volume Day-1 | `20260524-103143-7c41` | PASS |
|
||||
| Healthy + blocked support-bundle diagnostics | `20260524-103350-901d` | PASS |
|
||||
| Cleanup residue | `20260524-103511-d329` | PASS |
|
||||
| Operator snapshot + dashboard route | from `20260524-103052-beb2` | PASS |
|
||||
|
||||
D13 published-image release-path QA:
|
||||
|
||||
| Gate | QA Evidence | Result |
|
||||
|---|---:|---|
|
||||
| Helm first-volume via published `sha-6260e46fd3be` images | `20260524-124413-829a` | PASS, 34/34 |
|
||||
|
||||
The detailed Phase 28 QA working notes are intentionally not part of the
|
||||
user-facing release package; the run IDs above are the durable evidence anchors
|
||||
for this release note.
|
||||
|
||||
## Current Claim
|
||||
|
||||
Seaweed Block v0.3.3 alpha may claim:
|
||||
|
||||
- Helm remains the supported alpha Kubernetes install path.
|
||||
- The operations surface has one shared ManagedVolume vocabulary.
|
||||
- `sw-block ops report` and dashboard expose read-only status artifacts,
|
||||
including an operator-oriented snapshot.
|
||||
- Future operator status has a documented CRD/Condition/Event contract.
|
||||
- Cleanup evidence includes multipath and device-mapper residue checks.
|
||||
|
||||
These remain alpha claims: they describe the supported lab path and observed
|
||||
evidence, not production readiness.
|
||||
|
||||
## Explicit Non-Claims
|
||||
|
||||
- Not production-ready.
|
||||
- No production Kubernetes operator.
|
||||
- No installed CRDs or controller-manager lifecycle in this release note unless
|
||||
separately gated later.
|
||||
- No mutating operator actions.
|
||||
- No promote, repair, rebuild, failback, delete, backup, restore, or cleanup
|
||||
mutation through UI/API/operator.
|
||||
- No broad upgrade safety beyond existing gated smoke paths.
|
||||
- No broad platform compatibility matrix.
|
||||
- No performance, RTO, RPO, or SLO claim.
|
||||
- No new NVMe ANA, backup/restore, or returned-replica rebuild capability.
|
||||
|
||||
## Image Guidance
|
||||
|
||||
Release validation must use immutable GHCR tags:
|
||||
|
||||
```text
|
||||
ghcr.io/seaweedfs/seaweed-block:sha-6260e46fd3be
|
||||
ghcr.io/seaweedfs/seaweed-block-csi:sha-6260e46fd3be
|
||||
```
|
||||
|
||||
Published digests:
|
||||
|
||||
```text
|
||||
seaweed-block
|
||||
index: sha256:ef9c60f82c36f22360b10faafd32caf807f98ac0ea86c0365c0d0836e5f67110
|
||||
linux/amd64: sha256:36481cbc1fc98fafdfa386823e0e5906785cb6f35748ef698ff1cec39bb40464
|
||||
seaweed-block-csi
|
||||
index: sha256:b160ceee874dc6743074ef6b6735ccf05914c1de5951972922f6d3779bc73592
|
||||
linux/amd64: sha256:82e41b7ef92ad8db38b6927e334cc1d564b1012ad916e9bde2e882cece680be8
|
||||
```
|
||||
|
||||
Published by GitHub Actions run:
|
||||
|
||||
```text
|
||||
https://github.com/seaweedfs/seaweed-block/actions/runs/26370891528
|
||||
```
|
||||
|
||||
Mutable `:alpha` remains a smoke/demo tag only. Do not use it as release
|
||||
evidence.
|
||||
@@ -0,0 +1,127 @@
|
||||
# v0.3.4 Alpha - Status Surface Hardening And Strict New-User Path
|
||||
|
||||
Status: alpha release note for the Phase 32 status-surface close and the
|
||||
minimal new-user release validation. Runtime pods use the validated
|
||||
`sha-6260e46fd3be` images; the documented uninstall path also requires the
|
||||
repository-side cleanup script fix that scrubs iSCSI node DB records.
|
||||
|
||||
## Summary
|
||||
|
||||
Seaweed Block v0.3.4 alpha tightens the user-visible operations loop:
|
||||
|
||||
```text
|
||||
Helm install
|
||||
-> first PVC writer/reader verification
|
||||
-> read-only report/dashboard/operator snapshot
|
||||
-> negative-first status vocabulary
|
||||
-> support-bundle replay using freshest evidence
|
||||
-> strict uninstall and residue verification
|
||||
```
|
||||
|
||||
This is still an alpha release. It is a stronger user walkthrough and
|
||||
operations-evidence release, not a production operator or broad HA release.
|
||||
|
||||
## User-Visible Additions
|
||||
|
||||
- The documented new-user path now ends with strict cleanup verification.
|
||||
- `scripts/uninstall-k8s-alpha.sh` scrubs Seaweed Block iSCSI node DB records,
|
||||
not only active iSCSI sessions.
|
||||
- `sw-block ops report --from-bundle` prefers the freshest captured cluster
|
||||
evidence, so restart bundles do not replay an older primary when a newer
|
||||
post-restart snapshot exists.
|
||||
- Status surfaces agree across `summary.txt`, `operator-snapshot.json`,
|
||||
dashboard JSON, dashboard HTML, explain output, and support bundles.
|
||||
- Negative-first behavior is explicit:
|
||||
- ready evidence can show `Ready=True reason=first_volume_verified`;
|
||||
- known blockers show `Blocked=True reason=<stable_reason_code>`;
|
||||
- missing or stale evidence shows `Ready=Unknown` / `EvidenceStale=True`
|
||||
instead of a false ready claim.
|
||||
|
||||
## Validated Evidence
|
||||
|
||||
Minimal new-user release validation:
|
||||
|
||||
| Step | Result |
|
||||
|---|---|
|
||||
| Follow documented quickstart literally | PASS |
|
||||
| Generate Helm values with pinned images | PASS |
|
||||
| Helm install | PASS |
|
||||
| First PVC writer/reader loop | PASS |
|
||||
| Five report artifacts present | PASS |
|
||||
| Status surface read-only checks | PASS |
|
||||
| Uninstall + residue verification | PASS after iSCSI node DB scrub fix |
|
||||
|
||||
Optional release-cycle scenarios:
|
||||
|
||||
| Scenario | QA Evidence | Result |
|
||||
|---|---:|---|
|
||||
| Multi-volume RF3 smoke | `20260525-195935-a213` | PASS, 36/36 |
|
||||
| Restart persistence single-node | `20260525-200344-b193` | PASS, 40/40 |
|
||||
| Negative status, CSI image pull blocker | `20260525-200605-2e76` | PASS, 38/38 |
|
||||
| Stale evidence replay | manual replay against `20260525-172250-bf28` | PASS |
|
||||
|
||||
Phase 32 sign-off was completed before this release note was cut. The detailed
|
||||
QA working notes are intentionally not part of the user-facing release package;
|
||||
the run IDs above are the durable evidence anchors for this release.
|
||||
|
||||
## Current Claim
|
||||
|
||||
Seaweed Block v0.3.4 alpha may claim:
|
||||
|
||||
- Helm is the preferred alpha Kubernetes install path.
|
||||
- A supported lab can run the documented path from install to first PVC,
|
||||
writer/reader verification, read-only report/dashboard, and clean uninstall.
|
||||
- The read-only operations surface uses a shared ManagedVolume vocabulary.
|
||||
- Blocked and stale evidence states are visible and do not falsely report
|
||||
ready.
|
||||
- Support bundles can be replayed offline for report, explain, and dashboard.
|
||||
- The documented cleanup path removes Kubernetes resources, active iSCSI
|
||||
sessions, Seaweed Block iSCSI node records, multipath/device-mapper residue,
|
||||
product processes, and hostPath residue.
|
||||
|
||||
These claims are tied to supported alpha labs and QA gates. They are not broad
|
||||
production compatibility or availability commitments.
|
||||
|
||||
## Explicit Non-Claims
|
||||
|
||||
- Not production-ready.
|
||||
- No production Kubernetes operator or controller-manager lifecycle.
|
||||
- No mutating admin/operator/dashboard actions.
|
||||
- No promote, repair, rebuild, failback, delete, backup, restore, or cleanup
|
||||
mutation through UI/API/operator.
|
||||
- No backup/snapshot/restore workflow.
|
||||
- No returned-replica rebuild or automated failback.
|
||||
- No transparent Kubernetes node-loss failover without pod recreate.
|
||||
- No NVMe ANA parity for the transparent failover path.
|
||||
- No broad distro/kernel/initiator compatibility matrix.
|
||||
- No broad upgrade/rollback safety beyond existing gated smoke paths.
|
||||
- No performance, RTO, RPO, or SLO claim.
|
||||
|
||||
## Image Guidance
|
||||
|
||||
Release validation must use immutable GHCR tags:
|
||||
|
||||
```text
|
||||
ghcr.io/seaweedfs/seaweed-block:sha-6260e46fd3be
|
||||
ghcr.io/seaweedfs/seaweed-block-csi:sha-6260e46fd3be
|
||||
```
|
||||
|
||||
Published digests:
|
||||
|
||||
```text
|
||||
seaweed-block
|
||||
index: sha256:ef9c60f82c36f22360b10faafd32caf807f98ac0ea86c0365c0d0836e5f67110
|
||||
linux/amd64: sha256:36481cbc1fc98fafdfa386823e0e5906785cb6f35748ef698ff1cec39bb40464
|
||||
seaweed-block-csi
|
||||
index: sha256:b160ceee874dc6743074ef6b6735ccf05914c1de5951972922f6d3779bc73592
|
||||
linux/amd64: sha256:82e41b7ef92ad8db38b6927e334cc1d564b1012ad916e9bde2e882cece680be8
|
||||
```
|
||||
|
||||
Mutable `:alpha` remains a smoke/demo tag only. Do not use it as release
|
||||
evidence.
|
||||
|
||||
## Non-Blocking Follow-Up
|
||||
|
||||
`sw-block --version` can still report `revision=unknown modified=unknown`
|
||||
after a plain local `go build`. This is release-polish work for a later cycle;
|
||||
it does not affect the Helm/PVC/status/cleanup path.
|
||||
@@ -1,5 +1,10 @@
|
||||
# Seaweed Block Roadmap
|
||||
|
||||
> Document status: public roadmap summary. It is intentionally high level and
|
||||
> may trail the internal execution plan between releases. For current
|
||||
> user-facing claims, use [`quickstart-kubernetes.md`](quickstart-kubernetes.md)
|
||||
> and [`releases/README.md`](releases/README.md).
|
||||
|
||||
This roadmap is intentionally practical. The goal is to make a Kubernetes block
|
||||
service that is easy to try, review, and improve without hiding unfinished
|
||||
storage semantics.
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Runtime State Machines
|
||||
|
||||
> Document status: protocol/model reference. It is useful for reading runtime
|
||||
> code and protocol boundaries, but it is not the source of truth for current
|
||||
> release claims. Use [`quickstart-kubernetes.md`](quickstart-kubernetes.md)
|
||||
> and [`releases/README.md`](releases/README.md) for validated user behavior.
|
||||
|
||||
This is a lightweight map for engineers reading the runtime code for the first
|
||||
time. It is descriptive, not a normative protocol specification.
|
||||
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
# Seaweed Block User Capabilities
|
||||
|
||||
This page describes what a user can do with the current Seaweed Block alpha,
|
||||
what evidence is available, and what is still outside the product boundary.
|
||||
For the exact release evidence, see [`releases/README.md`](releases/README.md).
|
||||
|
||||
## Primary User Loop
|
||||
|
||||
The supported alpha loop is:
|
||||
|
||||
```text
|
||||
Helm install
|
||||
-> create a Kubernetes PVC
|
||||
-> mount the PVC in a writer pod
|
||||
-> verify the same data from a replacement reader pod
|
||||
-> inspect status/report/dashboard/support evidence
|
||||
-> uninstall and verify zero residue
|
||||
```
|
||||
|
||||
The quickstart command path is in
|
||||
[`quickstart-kubernetes.md`](quickstart-kubernetes.md).
|
||||
|
||||
## Core Capabilities
|
||||
|
||||
### Day-1 Helm Install And First PVC
|
||||
|
||||
Users can generate Helm values from the current Kubernetes cluster, install the
|
||||
Seaweed Block alpha stack, create the first PVC, run a writer pod, run a
|
||||
replacement reader pod, and verify persisted data.
|
||||
|
||||
Expected summary fields:
|
||||
|
||||
```text
|
||||
first_volume_status=ok
|
||||
writer_verified=true
|
||||
reader_verified=true
|
||||
inventory_status=ok
|
||||
status_report=status/report/index.html
|
||||
cleanup_status=ok
|
||||
```
|
||||
|
||||
### Standard Kubernetes PVC Workflow
|
||||
|
||||
The normal volume creation path is Kubernetes PVC creation:
|
||||
|
||||
```text
|
||||
kubectl apply -f pvc.yaml
|
||||
-> CSI dynamic provisioning
|
||||
-> iSCSI target
|
||||
-> app pod mounts the PVC through persistentVolumeClaim
|
||||
```
|
||||
|
||||
The current default filesystem path is ext4 through the CSI mount flow.
|
||||
|
||||
### Multi-Volume Lab Path
|
||||
|
||||
The gated lab path validates three RF=3 PVC-backed volumes at the same time:
|
||||
|
||||
- three PVCs bind and mount,
|
||||
- each volume has its own primary and publish target,
|
||||
- ManagedVolume reports each volume independently,
|
||||
- cross-volume authority mixups are rejected by the gate.
|
||||
|
||||
This is a lab-gated capability, not a broad scale claim.
|
||||
|
||||
### Recovery And Failover Gates
|
||||
|
||||
The current alpha has gated recovery evidence for:
|
||||
|
||||
- CSI reattach recovery: primary blockvolume stops, authority promotes a
|
||||
surviving replica, a replacement workload pod reads the same PVC data.
|
||||
- Mounted transparent failover on the proven Stage-2 path: the same mounted
|
||||
writer pod continues through iSCSI ALUA/dm-multipath when the primary path
|
||||
fails.
|
||||
- Interleaved multi-volume failover: two volumes fail over independently while
|
||||
an untouched third volume remains stable.
|
||||
|
||||
The broad claim remains narrow: these are supported lab gates, not production
|
||||
HA or broad RTO/SLO commitments.
|
||||
|
||||
### Restart Persistence
|
||||
|
||||
With the hostPath-backed alpha persistence path, QA gates verify:
|
||||
|
||||
- data written before restart remains readable after k3s/product restart,
|
||||
- a promoted RF=3 primary does not roll back to an old primary after restart,
|
||||
- epoch and publish target do not regress,
|
||||
- multiple volumes remain distinct after restart.
|
||||
|
||||
## Read-Only Operations
|
||||
|
||||
Port-forward blockmaster when reading live state:
|
||||
|
||||
```bash
|
||||
kubectl -n kube-system port-forward deploy/sw-blockmaster 9333:9333
|
||||
```
|
||||
|
||||
| Command | Use |
|
||||
|---|---|
|
||||
| `sw-block ops cluster --master-api 127.0.0.1:9333 -o json` | Cluster snapshot. |
|
||||
| `sw-block ops volumes --master-api 127.0.0.1:9333` | Volume list. |
|
||||
| `sw-block ops status --volume <id> --master <addr> --status-addr <addr> --out <dir>` | Focused live status bundle. |
|
||||
| `sw-block ops describe volume <id> --namespace default --master 127.0.0.1:9333` | Volume detail. |
|
||||
| `sw-block ops timeline volume --from-bundle <dir> <id> -o jsonl` | Volume event timeline from a bundle. |
|
||||
| `sw-block ops explain volume --from-bundle <dir> <id>` | Human-readable explanation and reason code. |
|
||||
| `sw-block ops report --master-api 127.0.0.1:9333 --out <dir>` | Static HTML/JSON/text report. |
|
||||
| `sw-block ops dashboard --master-api 127.0.0.1:9333 --listen 127.0.0.1:9334` | Local read-only dashboard. |
|
||||
| `sw-block ops inventory --namespace default --master 127.0.0.1:9333 --out <dir>` | Replica-level support inventory. |
|
||||
|
||||
Report output includes:
|
||||
|
||||
```text
|
||||
index.html
|
||||
summary.txt
|
||||
cluster-evidence.json
|
||||
timeline.jsonl
|
||||
operator-snapshot.json
|
||||
```
|
||||
|
||||
`operator-snapshot.json` is a read-only status projection for future operator
|
||||
work. It is not a running controller manager and it does not permit mutations.
|
||||
|
||||
## Support Bundle Replay
|
||||
|
||||
Support artifacts can be collected and replayed offline:
|
||||
|
||||
```bash
|
||||
bash scripts/collect-helm-support-bundle.sh "$PWD"
|
||||
sw-block ops report --from-bundle <bundle-or-artifact-dir> --out /tmp/sw-block-report
|
||||
sw-block ops explain volume <volume-id> --from-bundle <bundle-or-artifact-dir>
|
||||
sw-block ops dashboard --from-bundle <bundle-or-artifact-dir> --listen 127.0.0.1:9334
|
||||
```
|
||||
|
||||
This is intended to avoid SSH log spelunking. A cold reviewer should be able to
|
||||
understand cluster state, volume state, conditions, reason codes, and suggested
|
||||
read-only/dry-run actions from the bundle.
|
||||
|
||||
## Status Vocabulary
|
||||
|
||||
The current status model is negative-first:
|
||||
|
||||
- `Ready=True reason=first_volume_verified` means current evidence supports a
|
||||
ready claim.
|
||||
- `Blocked=True reason=csi_node_image_pull_failed` and similar reason codes
|
||||
identify known blockers.
|
||||
- `EvidenceStale=True` or `Ready=Unknown` means evidence is stale, missing, or
|
||||
still reconverging; the product should not claim ready.
|
||||
- Cluster counters include `ready_volume_count`, `blocked_volume_count`, and
|
||||
`stale_volume_count`.
|
||||
|
||||
## Cleanup
|
||||
|
||||
The documented cleanup path is:
|
||||
|
||||
```bash
|
||||
helm uninstall sw-block --namespace kube-system
|
||||
bash scripts/uninstall-k8s-alpha.sh "$PWD"
|
||||
bash scripts/verify-helm-cleanup.sh
|
||||
```
|
||||
|
||||
The verifier checks:
|
||||
|
||||
- Helm and Kubernetes resources,
|
||||
- iSCSI sessions,
|
||||
- iSCSI node DB records,
|
||||
- dm-multipath maps,
|
||||
- `dmsetup` devices,
|
||||
- product processes,
|
||||
- hostPath residue.
|
||||
|
||||
Expected clean shape:
|
||||
|
||||
```text
|
||||
cleanup_status=ok
|
||||
k8s_residue_count=0
|
||||
iscsi_residue_count=0
|
||||
multipath_residue_count=0
|
||||
process_residue_count=0
|
||||
hostpath_residue_count=0
|
||||
```
|
||||
|
||||
## Recommended Learning Path
|
||||
|
||||
1. Run the quickstart: install, first PVC, writer/reader, cleanup.
|
||||
2. Open the local read-only dashboard.
|
||||
3. Create multiple PVCs and inspect `ManagedVolume` entries.
|
||||
4. Collect a support bundle and replay it offline.
|
||||
5. Run restart or failover gates in a lab/TestOps environment if you are
|
||||
evaluating recovery behavior.
|
||||
6. Intentionally break a non-production lab path, such as a bad CSI image tag,
|
||||
and verify the status surface reports `Blocked` instead of false `Ready`.
|
||||
|
||||
## Explicit Non-Claims
|
||||
|
||||
- Not production-ready.
|
||||
- No production-grade operator or controller-manager lifecycle.
|
||||
- No mutating admin/operator/dashboard actions.
|
||||
- No promote, repair, rebuild, failback, delete, backup, restore, or cleanup
|
||||
mutation through UI/API/operator.
|
||||
- No backup/snapshot/restore workflow.
|
||||
- No returned-replica rebuild or automated failback.
|
||||
- No transparent Kubernetes node-loss failover without pod recreate.
|
||||
- No NVMe ANA parity for the transparent failover path.
|
||||
- No broad distro/kernel/initiator compatibility matrix.
|
||||
- No broad upgrade/rollback safety beyond existing gated smoke paths.
|
||||
- No performance, RTO, RPO, or SLO claim.
|
||||
@@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:-$(pwd)}"
|
||||
SOURCE_DIR="${SW_BLOCK_SUPPORT_BUNDLE_SOURCE:-${SW_BLOCK_ARTIFACT_DIR:-/tmp/sw-block-support-bundle}}"
|
||||
ARTIFACT_DIR="${SW_BLOCK_SUPPORT_BUNDLE_OUT:-$SOURCE_DIR/support-bundle}"
|
||||
NAMESPACE="${SW_BLOCK_APP_NAMESPACE:-default}"
|
||||
HELM_RELEASE="${SW_BLOCK_HELM_RELEASE:-sw-block}"
|
||||
HELM_NAMESPACE="${SW_BLOCK_HELM_NAMESPACE:-kube-system}"
|
||||
VOLUME_ID="${SW_BLOCK_VOLUME_ID:-}"
|
||||
|
||||
mkdir -p "$ARTIFACT_DIR"/{helm,k8s,logs,iscsi,replayed-report}
|
||||
SUPPORT_BUNDLE_CAPTURE_FAILED=0
|
||||
|
||||
if [[ -z "${KUBECONFIG:-}" && -f /etc/rancher/k3s/k3s.yaml ]]; then
|
||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
fi
|
||||
|
||||
sw_block_cmd() {
|
||||
if [[ -n "${SW_BLOCK_CLI:-}" ]]; then
|
||||
"$SW_BLOCK_CLI" "$@"
|
||||
elif command -v sw-block >/dev/null 2>&1; then
|
||||
sw-block "$@"
|
||||
elif [[ -x ./sw-block ]]; then
|
||||
./sw-block "$@"
|
||||
elif [[ -x "$ROOT/sw-block" ]]; then
|
||||
"$ROOT/sw-block" "$@"
|
||||
else
|
||||
go run ./cmd/sw-block "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
capture() {
|
||||
local out="$1"
|
||||
shift
|
||||
if ! "$@" >"$out" 2>&1; then
|
||||
SUPPORT_BUNDLE_CAPTURE_FAILED=1
|
||||
{
|
||||
echo
|
||||
echo "[support-bundle] command failed: $*"
|
||||
} >>"$out"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
summary_value() {
|
||||
local value="$1"
|
||||
if [[ -n "$value" ]]; then
|
||||
printf '%s' "$value"
|
||||
else
|
||||
printf 'unknown'
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -z "$VOLUME_ID" && -f "$SOURCE_DIR/first-volume-summary.txt" ]]; then
|
||||
VOLUME_ID="$(sed -n 's/^volume_id=//p' "$SOURCE_DIR/first-volume-summary.txt" | head -1)"
|
||||
fi
|
||||
if [[ -z "$VOLUME_ID" && -f "$SOURCE_DIR/multi-volume-summary.txt" ]]; then
|
||||
VOLUME_ID="$(sed -n 's/^volume_id=//p' "$SOURCE_DIR/multi-volume-summary.txt" | head -1)"
|
||||
fi
|
||||
if [[ -z "$VOLUME_ID" ]]; then
|
||||
VOLUME_ID="$(find "$SOURCE_DIR" -name volume-inventory-summary.txt -print -quit 2>/dev/null \
|
||||
| xargs -r sed -n 's/^volume:.* id=\([^ ]*\).*/\1/p' \
|
||||
| head -1 || true)"
|
||||
fi
|
||||
|
||||
capture "$ARTIFACT_DIR/helm/status.txt" helm status "$HELM_RELEASE" --namespace "$HELM_NAMESPACE" || true
|
||||
capture "$ARTIFACT_DIR/helm/values.txt" helm get values "$HELM_RELEASE" --namespace "$HELM_NAMESPACE" --all || true
|
||||
capture "$ARTIFACT_DIR/helm/manifest.yaml" helm get manifest "$HELM_RELEASE" --namespace "$HELM_NAMESPACE" || true
|
||||
|
||||
capture "$ARTIFACT_DIR/k8s/nodes.txt" kubectl get nodes -o wide || true
|
||||
capture "$ARTIFACT_DIR/k8s/pods.txt" kubectl get pods -A -o wide || true
|
||||
capture "$ARTIFACT_DIR/k8s/pv.txt" kubectl get pv -o wide || true
|
||||
capture "$ARTIFACT_DIR/k8s/pvc.txt" kubectl get pvc -A -o wide || true
|
||||
capture "$ARTIFACT_DIR/k8s/events.txt" kubectl get events -A --sort-by=.lastTimestamp || true
|
||||
capture "$ARTIFACT_DIR/k8s/volumeattachments.txt" kubectl get volumeattachments -o wide || true
|
||||
|
||||
capture "$ARTIFACT_DIR/logs/blockmaster.log" kubectl -n "$HELM_NAMESPACE" logs deploy/sw-blockmaster --all-containers --tail=300 || true
|
||||
capture "$ARTIFACT_DIR/logs/csi-controller.log" kubectl -n "$HELM_NAMESPACE" logs deploy/sw-block-csi-controller --all-containers --tail=300 || true
|
||||
capture "$ARTIFACT_DIR/logs/csi-node.log" kubectl -n "$HELM_NAMESPACE" logs ds/sw-block-csi-node --all-containers --tail=300 || true
|
||||
capture "$ARTIFACT_DIR/logs/blockvolume.log" kubectl -n "$NAMESPACE" logs -l app=sw-blockvolume --all-containers --tail=300 || true
|
||||
|
||||
capture "$ARTIFACT_DIR/iscsi/sessions.txt" sudo -n iscsiadm -m session || true
|
||||
capture "$ARTIFACT_DIR/iscsi/nodes.txt" sudo -n iscsiadm -m node || true
|
||||
|
||||
report_status=ok
|
||||
explain_status=ok
|
||||
timeline_status=ok
|
||||
|
||||
if ! sw_block_cmd ops report --from-bundle "$SOURCE_DIR" --out "$ARTIFACT_DIR/replayed-report" \
|
||||
>"$ARTIFACT_DIR/replayed-report.stdout.txt" 2>"$ARTIFACT_DIR/replayed-report.stderr.txt"; then
|
||||
report_status=failed
|
||||
fi
|
||||
|
||||
if [[ -n "$VOLUME_ID" && "$VOLUME_ID" != "unknown" ]]; then
|
||||
if ! sw_block_cmd ops explain volume --from-bundle "$SOURCE_DIR" "$VOLUME_ID" \
|
||||
>"$ARTIFACT_DIR/explain.txt" 2>"$ARTIFACT_DIR/explain.stderr.txt"; then
|
||||
explain_status=failed
|
||||
fi
|
||||
if ! sw_block_cmd ops timeline volume --from-bundle "$SOURCE_DIR" "$VOLUME_ID" -o jsonl \
|
||||
>"$ARTIFACT_DIR/timeline.replayed.jsonl" 2>"$ARTIFACT_DIR/timeline.stderr.txt"; then
|
||||
timeline_status=failed
|
||||
fi
|
||||
else
|
||||
explain_status=failed
|
||||
timeline_status=failed
|
||||
echo "volume id unavailable" >"$ARTIFACT_DIR/explain.stderr.txt"
|
||||
echo "volume id unavailable" >"$ARTIFACT_DIR/timeline.stderr.txt"
|
||||
fi
|
||||
|
||||
support_bundle_status=ok
|
||||
for required in \
|
||||
"$ARTIFACT_DIR/replayed-report/index.html" \
|
||||
"$ARTIFACT_DIR/replayed-report/cluster-evidence.json" \
|
||||
"$ARTIFACT_DIR/replayed-report/timeline.jsonl" \
|
||||
"$ARTIFACT_DIR/replayed-report/summary.txt" \
|
||||
"$ARTIFACT_DIR/explain.txt" \
|
||||
"$ARTIFACT_DIR/k8s/pods.txt" \
|
||||
"$ARTIFACT_DIR/helm/status.txt"; do
|
||||
if [[ ! -s "$required" ]]; then
|
||||
support_bundle_status=failed
|
||||
fi
|
||||
done
|
||||
if [[ "$SUPPORT_BUNDLE_CAPTURE_FAILED" != "0" || "$report_status" != "ok" || "$explain_status" != "ok" || "$timeline_status" != "ok" ]]; then
|
||||
support_bundle_status=failed
|
||||
fi
|
||||
|
||||
{
|
||||
echo "support_bundle_status=$support_bundle_status"
|
||||
echo "source_bundle=$SOURCE_DIR"
|
||||
echo "volume_id=$(summary_value "$VOLUME_ID")"
|
||||
echo "helm_release=$HELM_RELEASE"
|
||||
echo "helm_namespace=$HELM_NAMESPACE"
|
||||
echo "report_status=$report_status"
|
||||
echo "explain_status=$explain_status"
|
||||
echo "timeline_status=$timeline_status"
|
||||
echo "capture_status=$([[ "$SUPPORT_BUNDLE_CAPTURE_FAILED" == "0" ]] && echo ok || echo failed)"
|
||||
echo "read_only=true"
|
||||
echo "report=replayed-report/index.html"
|
||||
echo "cluster_evidence=replayed-report/cluster-evidence.json"
|
||||
echo "timeline=replayed-report/timeline.jsonl"
|
||||
echo "explain=explain.txt"
|
||||
} >"$ARTIFACT_DIR/support-bundle-summary.txt"
|
||||
|
||||
cat "$ARTIFACT_DIR/support-bundle-summary.txt"
|
||||
test "$support_bundle_status" = "ok"
|
||||
@@ -276,6 +276,7 @@ write_summary() {
|
||||
echo "cluster_evidence=status/cluster-evidence.json"
|
||||
echo "inventory_bundle=status/inventory"
|
||||
echo "status_report=status/report/index.html"
|
||||
echo "operator_snapshot=status/report/operator-snapshot.json"
|
||||
echo "cleanup_status=$CLEANUP_STATUS"
|
||||
} >"$ARTIFACT_DIR/first-volume-summary.txt"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:-$(pwd)}"
|
||||
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-/tmp/sw-block-multi-volume-$(date -u +%Y%m%dT%H%M%SZ)}"
|
||||
NAMESPACE="${SW_BLOCK_APP_NAMESPACE:-default}"
|
||||
VOLUME_COUNT="${SW_BLOCK_MULTI_VOLUME_COUNT:-3}"
|
||||
REPLICATION_FACTOR="${SW_BLOCK_MULTI_VOLUME_RF:-1}"
|
||||
STORAGECLASS_NAME="${SW_BLOCK_MULTI_VOLUME_STORAGECLASS:-sw-block-multi}"
|
||||
PVC_PREFIX="${SW_BLOCK_MULTI_VOLUME_PVC_PREFIX:-sw-block-multi-pvc}"
|
||||
POD_PREFIX="${SW_BLOCK_MULTI_VOLUME_POD_PREFIX:-sw-block-multi}"
|
||||
CHAP_SECRET_NAME="${SW_BLOCK_ISCSI_CHAP_SECRET_NAME:-sw-block-iscsi-chap}"
|
||||
MASTER_PORT="${SW_BLOCK_MASTER_PORT_FORWARD_PORT:-}"
|
||||
CLEANUP_REQUESTED="${SW_BLOCK_MULTI_VOLUME_CLEANUP:-1}"
|
||||
|
||||
MULTI_VOLUME_STATUS="ok"
|
||||
FAILED_PHASE=""
|
||||
CLEANUP_STATUS="external_to_script"
|
||||
if [[ "$CLEANUP_REQUESTED" == "1" || "$CLEANUP_REQUESTED" == "true" ]]; then
|
||||
CLEANUP_STATUS="pending"
|
||||
fi
|
||||
|
||||
mkdir -p "$ARTIFACT_DIR"/{manifests,logs,status}
|
||||
|
||||
if [[ -z "${KUBECONFIG:-}" && -f /etc/rancher/k3s/k3s.yaml ]]; then
|
||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
fi
|
||||
|
||||
log() {
|
||||
printf '[multi-volume] %s\n' "$*" | tee -a "$ARTIFACT_DIR/run.log"
|
||||
}
|
||||
|
||||
require_cmd() {
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
echo "missing required command: $1" >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
safe_capture() {
|
||||
local out="$1"
|
||||
shift
|
||||
"$@" >"$out" 2>&1 || true
|
||||
}
|
||||
|
||||
list_blockvolume_deployments() {
|
||||
kubectl -n "$NAMESPACE" get deploy -l app=sw-blockvolume -o name 2>/dev/null \
|
||||
| awk '/^deployment/ { print }'
|
||||
}
|
||||
|
||||
sw_block_cmd() {
|
||||
if [[ -n "${SW_BLOCK_CLI:-}" ]]; then
|
||||
"$SW_BLOCK_CLI" "$@"
|
||||
elif command -v sw-block >/dev/null 2>&1; then
|
||||
sw-block "$@"
|
||||
else
|
||||
go run ./cmd/sw-block "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
find_free_port() {
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
python3 - <<'PY'
|
||||
import socket
|
||||
s = socket.socket()
|
||||
s.bind(("127.0.0.1", 0))
|
||||
print(s.getsockname()[1])
|
||||
s.close()
|
||||
PY
|
||||
return
|
||||
fi
|
||||
for port in $(seq 29333 29433); do
|
||||
if ! (echo >"/dev/tcp/127.0.0.1/$port") >/dev/null 2>&1; then
|
||||
echo "$port"
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo "9333"
|
||||
}
|
||||
|
||||
wait_for_port() {
|
||||
local port="$1"
|
||||
for _ in $(seq 1 30); do
|
||||
if (echo >"/dev/tcp/127.0.0.1/$port") >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
stop_port_forward() {
|
||||
if [[ -n "${PF_PID:-}" ]]; then
|
||||
kill "$PF_PID" >/dev/null 2>&1 || true
|
||||
wait "$PF_PID" >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
render_storageclass() {
|
||||
local out="$ARTIFACT_DIR/manifests/storageclass.yaml"
|
||||
{
|
||||
echo "apiVersion: storage.k8s.io/v1"
|
||||
echo "kind: StorageClass"
|
||||
echo "metadata:"
|
||||
echo " name: $STORAGECLASS_NAME"
|
||||
echo "provisioner: block.csi.seaweedfs.com"
|
||||
echo "volumeBindingMode: Immediate"
|
||||
echo "allowVolumeExpansion: false"
|
||||
echo "parameters:"
|
||||
echo " replicationFactor: \"$REPLICATION_FACTOR\""
|
||||
if kubectl -n "$NAMESPACE" get secret "$CHAP_SECRET_NAME" >/dev/null 2>&1; then
|
||||
echo " csi.storage.k8s.io/node-stage-secret-name: \"$CHAP_SECRET_NAME\""
|
||||
echo " csi.storage.k8s.io/node-stage-secret-namespace: \"$NAMESPACE\""
|
||||
fi
|
||||
} >"$out"
|
||||
echo "$out"
|
||||
}
|
||||
|
||||
render_pvc() {
|
||||
local idx="$1"
|
||||
local out="$ARTIFACT_DIR/manifests/pvc-$idx.yaml"
|
||||
cat >"$out" <<YAML
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: ${PVC_PREFIX}-${idx}
|
||||
namespace: ${NAMESPACE}
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: ${STORAGECLASS_NAME}
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Mi
|
||||
YAML
|
||||
echo "$out"
|
||||
}
|
||||
|
||||
render_writer() {
|
||||
local idx="$1"
|
||||
local out="$ARTIFACT_DIR/manifests/writer-$idx.yaml"
|
||||
cat >"$out" <<YAML
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: ${POD_PREFIX}-writer-${idx}
|
||||
namespace: ${NAMESPACE}
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: app
|
||||
image: busybox:1.36
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
echo "[writer-$idx] writing through PVC mounted at /data"
|
||||
dd if=/dev/urandom of=/data/demo.bin bs=4096 count=1
|
||||
sha256sum /data/demo.bin > /data/demo.sha256
|
||||
sync
|
||||
sha256sum -c /data/demo.sha256
|
||||
echo "/data/demo.bin: OK"
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: ${PVC_PREFIX}-${idx}
|
||||
YAML
|
||||
echo "$out"
|
||||
}
|
||||
|
||||
render_reader() {
|
||||
local idx="$1"
|
||||
local out="$ARTIFACT_DIR/manifests/reader-$idx.yaml"
|
||||
cat >"$out" <<YAML
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: ${POD_PREFIX}-reader-${idx}
|
||||
namespace: ${NAMESPACE}
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: app
|
||||
image: busybox:1.36
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
echo "[reader-$idx] reading existing data from PVC mounted at /data"
|
||||
test -s /data/demo.bin
|
||||
test -s /data/demo.sha256
|
||||
sha256sum -c /data/demo.sha256
|
||||
echo "/data/demo.bin: OK"
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: ${PVC_PREFIX}-${idx}
|
||||
YAML
|
||||
echo "$out"
|
||||
}
|
||||
|
||||
collect_status_evidence() {
|
||||
local out="$ARTIFACT_DIR/status"
|
||||
local rc=0
|
||||
mkdir -p "$out"
|
||||
kubectl -n kube-system port-forward deploy/sw-blockmaster "${MASTER_PORT}:9333" >"$out/blockmaster-port-forward.log" 2>&1 &
|
||||
PF_PID=$!
|
||||
trap stop_port_forward RETURN
|
||||
if ! wait_for_port "$MASTER_PORT"; then
|
||||
echo "status evidence failed: blockmaster port-forward did not become ready" >"$out/status-evidence-error.txt"
|
||||
rc=1
|
||||
fi
|
||||
if [[ "$rc" -eq 0 ]] && ! sw_block_cmd ops cluster --master-api "127.0.0.1:${MASTER_PORT}" --timeout 30s -o json >"$out/cluster-evidence.json" 2>"$out/cluster-evidence.stderr.txt"; then
|
||||
rc=1
|
||||
fi
|
||||
if [[ "$rc" -eq 0 ]] && ! sw_block_cmd ops inventory --namespace "$NAMESPACE" --master "127.0.0.1:${MASTER_PORT}" --out "$out/inventory" --timeout 30s >"$out/inventory.stdout.txt" 2>"$out/inventory.stderr.txt"; then
|
||||
rc=1
|
||||
fi
|
||||
if [[ "$rc" -eq 0 ]] && ! sw_block_cmd ops report --from-bundle "$ARTIFACT_DIR" --out "$out/report" >"$out/report.stdout.txt" 2>"$out/report.stderr.txt"; then
|
||||
rc=1
|
||||
fi
|
||||
stop_port_forward
|
||||
unset PF_PID
|
||||
trap - RETURN
|
||||
return "$rc"
|
||||
}
|
||||
|
||||
cleanup_multi_volume() {
|
||||
local rc=0
|
||||
local deployments_gone=false
|
||||
for idx in $(seq 1 "$VOLUME_COUNT"); do
|
||||
kubectl -n "$NAMESPACE" delete pod "${POD_PREFIX}-reader-${idx}" "${POD_PREFIX}-writer-${idx}" --ignore-not-found=true --wait=true --timeout=120s || rc=1
|
||||
done
|
||||
for idx in $(seq 1 "$VOLUME_COUNT"); do
|
||||
kubectl -n "$NAMESPACE" delete pvc "${PVC_PREFIX}-${idx}" --ignore-not-found=true --wait=true --timeout=120s || rc=1
|
||||
done
|
||||
# RF>1 creates several generated blockvolume Deployments per PVC. The
|
||||
# launcher removes them asynchronously after PVC deletion; wait before
|
||||
# declaring helper-level cleanup success.
|
||||
local deadline=$((SECONDS + 180))
|
||||
while (( SECONDS <= deadline )); do
|
||||
local remaining
|
||||
remaining="$(list_blockvolume_deployments || true)"
|
||||
if [[ -z "$remaining" ]]; then
|
||||
deployments_gone=true
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
if [[ "$deployments_gone" != "true" ]] && [[ -z "$(list_blockvolume_deployments || true)" ]]; then
|
||||
deployments_gone=true
|
||||
fi
|
||||
if [[ "$deployments_gone" != "true" ]]; then
|
||||
safe_capture "$ARTIFACT_DIR/logs/blockvolume-deployments.cleanup-timeout.txt" kubectl -n "$NAMESPACE" get deploy -l app=sw-blockvolume -o wide
|
||||
rc=1
|
||||
fi
|
||||
kubectl delete storageclass "$STORAGECLASS_NAME" --ignore-not-found=true --wait=true --timeout=120s || rc=1
|
||||
return "$rc"
|
||||
}
|
||||
|
||||
capture_failure_diagnostics() {
|
||||
local phase="$1"
|
||||
local out="$ARTIFACT_DIR/diagnostics/$phase"
|
||||
mkdir -p "$out"
|
||||
safe_capture "$out/pods.txt" kubectl -n "$NAMESPACE" get pods -o wide
|
||||
safe_capture "$out/pvcs.txt" kubectl -n "$NAMESPACE" get pvc -o wide
|
||||
safe_capture "$out/blockvolume-deployments.txt" kubectl -n "$NAMESPACE" get deploy -l app=sw-blockvolume -o wide
|
||||
safe_capture "$out/blockvolume-deployments.yaml" kubectl -n "$NAMESPACE" get deploy -l app=sw-blockvolume -o yaml
|
||||
safe_capture "$out/blockvolume-pods.yaml" kubectl -n "$NAMESPACE" get pods -l app=sw-blockvolume -o yaml
|
||||
safe_capture "$out/volumeattachments.txt" kubectl get volumeattachments -o wide
|
||||
safe_capture "$out/volumeattachments.yaml" kubectl get volumeattachments -o yaml
|
||||
safe_capture "$out/events.txt" kubectl -n "$NAMESPACE" get events --sort-by=.lastTimestamp
|
||||
safe_capture "$out/kube-system.txt" kubectl -n kube-system get pods,deploy,ds,svc -o wide
|
||||
safe_capture "$out/blockmaster.log" kubectl -n kube-system logs deploy/sw-blockmaster --tail=400
|
||||
safe_capture "$out/csi-controller.log" kubectl -n kube-system logs deploy/sw-block-csi-controller --all-containers --tail=400
|
||||
safe_capture "$out/csi-node.log" kubectl -n kube-system logs ds/sw-block-csi-node --all-containers --tail=400
|
||||
safe_capture "$out/blockvolume.log" kubectl -n "$NAMESPACE" logs -l sw-block.seaweedfs.com/volume --all-containers --tail=400
|
||||
safe_capture "$out/iscsi-sessions.txt" sudo -n iscsiadm -m session
|
||||
local diag_port diag_pf_pid
|
||||
diag_port="$(find_free_port)"
|
||||
kubectl -n kube-system port-forward deploy/sw-blockmaster "${diag_port}:9333" >"$out/blockmaster-port-forward.log" 2>&1 &
|
||||
diag_pf_pid=$!
|
||||
if wait_for_port "$diag_port"; then
|
||||
sw_block_cmd ops cluster --master-api "127.0.0.1:${diag_port}" --timeout 30s -o json >"$out/cluster-evidence.json" 2>"$out/cluster-evidence.stderr.txt" || true
|
||||
sw_block_cmd ops inventory --namespace "$NAMESPACE" --master "127.0.0.1:${diag_port}" --out "$out/inventory" --timeout 30s >"$out/inventory.stdout.txt" 2>"$out/inventory.stderr.txt" || true
|
||||
fi
|
||||
kill "$diag_pf_pid" >/dev/null 2>&1 || true
|
||||
wait "$diag_pf_pid" >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
write_summary() {
|
||||
local writer_count reader_count managed_count inventory_status
|
||||
writer_count="$(grep -R -l '/data/demo.bin: OK' "$ARTIFACT_DIR/logs"/writer-*.log 2>/dev/null | wc -l | tr -d ' ')"
|
||||
reader_count="$(grep -R -l '/data/demo.bin: OK' "$ARTIFACT_DIR/logs"/reader-*.log 2>/dev/null | wc -l | tr -d ' ')"
|
||||
managed_count="$(grep -c '^managed_volume=' "$ARTIFACT_DIR/status/report/summary.txt" 2>/dev/null || true)"
|
||||
inventory_status="$(sed -n 's/^inventory_status: //p' "$ARTIFACT_DIR/status/inventory/volume-inventory-summary.txt" 2>/dev/null | head -1)"
|
||||
{
|
||||
echo "multi_volume_status=$MULTI_VOLUME_STATUS"
|
||||
if [[ -n "$FAILED_PHASE" ]]; then
|
||||
echo "failed_phase=$FAILED_PHASE"
|
||||
fi
|
||||
echo "namespace=$NAMESPACE"
|
||||
echo "storageclass=$STORAGECLASS_NAME"
|
||||
echo "requested_volume_count=$VOLUME_COUNT"
|
||||
echo "replication_factor=$REPLICATION_FACTOR"
|
||||
echo "writer_verified_count=$writer_count"
|
||||
echo "reader_verified_count=$reader_count"
|
||||
echo "managed_volume_count=$managed_count"
|
||||
echo "inventory_status=${inventory_status:-unknown}"
|
||||
echo "status_report=status/report/index.html"
|
||||
echo "cleanup_status=$CLEANUP_STATUS"
|
||||
} >"$ARTIFACT_DIR/multi-volume-summary.txt"
|
||||
}
|
||||
|
||||
require_cmd kubectl
|
||||
if [[ "$NAMESPACE" != "default" ]]; then
|
||||
echo "SW_BLOCK_APP_NAMESPACE=$NAMESPACE is not supported by this helper; use default" >&2
|
||||
exit 2
|
||||
fi
|
||||
case "$VOLUME_COUNT" in
|
||||
''|*[!0-9]*|0)
|
||||
echo "SW_BLOCK_MULTI_VOLUME_COUNT must be a positive integer; got: $VOLUME_COUNT" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
if [[ -z "$MASTER_PORT" ]]; then
|
||||
MASTER_PORT="$(find_free_port)"
|
||||
fi
|
||||
|
||||
log "artifact_dir=$ARTIFACT_DIR"
|
||||
log "namespace=$NAMESPACE"
|
||||
log "volume_count=$VOLUME_COUNT"
|
||||
log "master_port=$MASTER_PORT"
|
||||
|
||||
kubectl apply -f "$(render_storageclass)" | tee "$ARTIFACT_DIR/apply-storageclass.log"
|
||||
|
||||
for idx in $(seq 1 "$VOLUME_COUNT"); do
|
||||
log "create pvc $idx"
|
||||
kubectl apply -f "$(render_pvc "$idx")" | tee "$ARTIFACT_DIR/logs/apply-pvc-$idx.log"
|
||||
kubectl -n "$NAMESPACE" wait --for=jsonpath='{.status.phase}'=Bound "pvc/${PVC_PREFIX}-${idx}" --timeout=180s | tee "$ARTIFACT_DIR/logs/wait-pvc-$idx.log"
|
||||
safe_capture "$ARTIFACT_DIR/logs/pvc-$idx.after-bound.txt" kubectl -n "$NAMESPACE" get pvc "${PVC_PREFIX}-${idx}" -o wide
|
||||
done
|
||||
|
||||
for idx in $(seq 1 "$VOLUME_COUNT"); do
|
||||
log "writer $idx"
|
||||
kubectl apply -f "$(render_writer "$idx")" | tee "$ARTIFACT_DIR/logs/apply-writer-$idx.log"
|
||||
if ! kubectl -n "$NAMESPACE" wait --for=jsonpath='{.status.phase}'=Succeeded "pod/${POD_PREFIX}-writer-${idx}" --timeout=240s | tee "$ARTIFACT_DIR/logs/wait-writer-$idx.log"; then
|
||||
safe_capture "$ARTIFACT_DIR/logs/writer-$idx.describe.txt" kubectl -n "$NAMESPACE" describe pod "${POD_PREFIX}-writer-${idx}"
|
||||
capture_failure_diagnostics "writer-$idx"
|
||||
exit 1
|
||||
fi
|
||||
kubectl -n "$NAMESPACE" logs "${POD_PREFIX}-writer-${idx}" >"$ARTIFACT_DIR/logs/writer-$idx.log"
|
||||
grep -q '/data/demo.bin: OK' "$ARTIFACT_DIR/logs/writer-$idx.log"
|
||||
kubectl -n "$NAMESPACE" delete pod "${POD_PREFIX}-writer-${idx}" --wait=true --timeout=120s | tee "$ARTIFACT_DIR/logs/delete-writer-$idx.log"
|
||||
done
|
||||
|
||||
for idx in $(seq 1 "$VOLUME_COUNT"); do
|
||||
log "reader $idx"
|
||||
kubectl apply -f "$(render_reader "$idx")" | tee "$ARTIFACT_DIR/logs/apply-reader-$idx.log"
|
||||
if ! kubectl -n "$NAMESPACE" wait --for=jsonpath='{.status.phase}'=Succeeded "pod/${POD_PREFIX}-reader-${idx}" --timeout=240s | tee "$ARTIFACT_DIR/logs/wait-reader-$idx.log"; then
|
||||
safe_capture "$ARTIFACT_DIR/logs/reader-$idx.describe.txt" kubectl -n "$NAMESPACE" describe pod "${POD_PREFIX}-reader-${idx}"
|
||||
capture_failure_diagnostics "reader-$idx"
|
||||
exit 1
|
||||
fi
|
||||
kubectl -n "$NAMESPACE" logs "${POD_PREFIX}-reader-${idx}" >"$ARTIFACT_DIR/logs/reader-$idx.log"
|
||||
grep -q '/data/demo.bin: OK' "$ARTIFACT_DIR/logs/reader-$idx.log"
|
||||
done
|
||||
|
||||
log "collect status evidence"
|
||||
if ! collect_status_evidence; then
|
||||
MULTI_VOLUME_STATUS="failed"
|
||||
FAILED_PHASE="status_evidence"
|
||||
fi
|
||||
|
||||
if [[ "$CLEANUP_REQUESTED" == "1" || "$CLEANUP_REQUESTED" == "true" ]]; then
|
||||
log "cleanup multi-volume resources"
|
||||
if cleanup_multi_volume; then
|
||||
CLEANUP_STATUS="ok"
|
||||
else
|
||||
CLEANUP_STATUS="failed"
|
||||
MULTI_VOLUME_STATUS="failed"
|
||||
if [[ -z "$FAILED_PHASE" ]]; then
|
||||
FAILED_PHASE="cleanup"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
write_summary
|
||||
cat "$ARTIFACT_DIR/multi-volume-summary.txt"
|
||||
|
||||
if [[ "$MULTI_VOLUME_STATUS" != "ok" ]]; then
|
||||
log "FAIL: multi-volume loop incomplete"
|
||||
exit 1
|
||||
fi
|
||||
log "PASS: multi-volume loop complete"
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,333 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:-$(pwd)}"
|
||||
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-/tmp/sw-block-multi-volume-reattach-$(date -u +%Y%m%dT%H%M%SZ)}"
|
||||
NAMESPACE="${SW_BLOCK_APP_NAMESPACE:-default}"
|
||||
VOLUME_COUNT="${SW_BLOCK_MULTI_VOLUME_COUNT:-3}"
|
||||
REPLICATION_FACTOR="${SW_BLOCK_MULTI_VOLUME_RF:-3}"
|
||||
PVC_PREFIX="${SW_BLOCK_MULTI_VOLUME_PVC_PREFIX:-sw-block-multi-pvc}"
|
||||
POD_PREFIX="${SW_BLOCK_MULTI_VOLUME_POD_PREFIX:-sw-block-multi}"
|
||||
MASTER_PORT="${SW_BLOCK_MASTER_PORT_FORWARD_PORT:-}"
|
||||
|
||||
STATUS="ok"
|
||||
FAILED_PHASE=""
|
||||
|
||||
mkdir -p "$ARTIFACT_DIR"/{setup,failover,status,logs,manifests}
|
||||
|
||||
if [[ -z "${KUBECONFIG:-}" && -f /etc/rancher/k3s/k3s.yaml ]]; then
|
||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
fi
|
||||
|
||||
log() {
|
||||
printf '[multi-volume-reattach] %s\n' "$*" | tee -a "$ARTIFACT_DIR/run.log"
|
||||
}
|
||||
|
||||
sw_block_cmd() {
|
||||
if [[ -n "${SW_BLOCK_CLI:-}" ]]; then
|
||||
"$SW_BLOCK_CLI" "$@"
|
||||
elif command -v sw-block >/dev/null 2>&1; then
|
||||
sw-block "$@"
|
||||
else
|
||||
go run ./cmd/sw-block "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
find_free_port() {
|
||||
python3 - <<'PY'
|
||||
import socket
|
||||
s = socket.socket()
|
||||
s.bind(("127.0.0.1", 0))
|
||||
print(s.getsockname()[1])
|
||||
s.close()
|
||||
PY
|
||||
}
|
||||
|
||||
wait_for_port() {
|
||||
local port="$1"
|
||||
for _ in $(seq 1 30); do
|
||||
if (echo >"/dev/tcp/127.0.0.1/$port") >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
start_master_port_forward() {
|
||||
if [[ -z "$MASTER_PORT" ]]; then
|
||||
MASTER_PORT="$(find_free_port)"
|
||||
fi
|
||||
kubectl -n kube-system port-forward deploy/sw-blockmaster "${MASTER_PORT}:9333" >"$ARTIFACT_DIR/status/blockmaster-port-forward.log" 2>&1 &
|
||||
PF_PID=$!
|
||||
wait_for_port "$MASTER_PORT"
|
||||
}
|
||||
|
||||
stop_master_port_forward() {
|
||||
if [[ -n "${PF_PID:-}" ]]; then
|
||||
kill "$PF_PID" >/dev/null 2>&1 || true
|
||||
wait "$PF_PID" >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
collect_cluster() {
|
||||
local out="$1"
|
||||
mkdir -p "$(dirname "$out")"
|
||||
sw_block_cmd ops cluster --master-api "127.0.0.1:${MASTER_PORT}" --timeout 30s -o json >"$out"
|
||||
test -s "$out"
|
||||
}
|
||||
|
||||
render_reader() {
|
||||
local idx="$1"
|
||||
local name="$2"
|
||||
local pvc="$3"
|
||||
local out="$ARTIFACT_DIR/manifests/${name}.yaml"
|
||||
cat >"$out" <<YAML
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: ${name}
|
||||
namespace: ${NAMESPACE}
|
||||
labels:
|
||||
sw-block-test: multi-volume-reattach
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: app
|
||||
image: busybox:1.36
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
set -eu
|
||||
echo "[reader-$idx] reading existing data from PVC mounted at /data"
|
||||
test -s /data/demo.bin
|
||||
test -s /data/demo.sha256
|
||||
sha256sum -c /data/demo.sha256
|
||||
echo "/data/demo.bin: OK"
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: ${pvc}
|
||||
YAML
|
||||
echo "$out"
|
||||
}
|
||||
|
||||
extract_plan() {
|
||||
local cluster_json="$1"
|
||||
local deploy_json="$2"
|
||||
local out="$3"
|
||||
python3 - "$cluster_json" "$deploy_json" "$out" <<'PY'
|
||||
import json, sys
|
||||
cluster = json.load(open(sys.argv[1]))
|
||||
deploys = json.load(open(sys.argv[2])).get("items", [])
|
||||
out = sys.argv[3]
|
||||
vols = sorted(cluster.get("volumes", []), key=lambda v: v.get("pvc_name") or v.get("volume_id"))
|
||||
deploy_by_slot = {}
|
||||
for d in deploys:
|
||||
labels = d.get("metadata", {}).get("labels", {}) or {}
|
||||
key = (labels.get("sw-block.seaweedfs.com/volume"), labels.get("sw-block.seaweedfs.com/replica"))
|
||||
if key[0] and key[1]:
|
||||
deploy_by_slot[key] = d.get("metadata", {}).get("name", "")
|
||||
with open(out, "w", encoding="utf-8") as f:
|
||||
for idx, v in enumerate(vols, 1):
|
||||
vid = v.get("volume_id", "")
|
||||
primary = v.get("primary_replica", "")
|
||||
deploy = deploy_by_slot.get((vid, primary), "")
|
||||
f.write("\t".join([
|
||||
str(idx),
|
||||
vid,
|
||||
v.get("pvc_name", ""),
|
||||
primary,
|
||||
v.get("primary_node", ""),
|
||||
v.get("publish_target", ""),
|
||||
deploy,
|
||||
]) + "\n")
|
||||
PY
|
||||
}
|
||||
|
||||
volume_field() {
|
||||
local cluster_json="$1"
|
||||
local volume_id="$2"
|
||||
local field="$3"
|
||||
python3 - "$cluster_json" "$volume_id" "$field" <<'PY'
|
||||
import json, sys
|
||||
doc=json.load(open(sys.argv[1]))
|
||||
vid=sys.argv[2]
|
||||
field=sys.argv[3]
|
||||
for v in doc.get("volumes", []):
|
||||
if v.get("volume_id") == vid:
|
||||
print(v.get(field, ""))
|
||||
break
|
||||
PY
|
||||
}
|
||||
|
||||
assert_non_target_stable() {
|
||||
local before="$1"
|
||||
local after="$2"
|
||||
local target_vid="$3"
|
||||
python3 - "$before" "$after" "$target_vid" <<'PY'
|
||||
import json, sys
|
||||
before=json.load(open(sys.argv[1]))
|
||||
after=json.load(open(sys.argv[2]))
|
||||
target=sys.argv[3]
|
||||
after_by={v.get("volume_id"):v for v in after.get("volumes", [])}
|
||||
bad=[]
|
||||
for v in before.get("volumes", []):
|
||||
vid=v.get("volume_id")
|
||||
if not vid or vid == target:
|
||||
continue
|
||||
av=after_by.get(vid, {})
|
||||
for field in ("primary_replica","primary_node","publish_target"):
|
||||
if v.get(field) != av.get(field):
|
||||
bad.append(f"{vid}:{field}:{v.get(field)}->{av.get(field)}")
|
||||
if bad:
|
||||
raise SystemExit("non_target_changed=" + ",".join(bad))
|
||||
PY
|
||||
}
|
||||
|
||||
write_summary() {
|
||||
{
|
||||
echo "multi_volume_reattach_status=$STATUS"
|
||||
if [[ -n "$FAILED_PHASE" ]]; then
|
||||
echo "failed_phase=$FAILED_PHASE"
|
||||
fi
|
||||
echo "requested_volume_count=$VOLUME_COUNT"
|
||||
echo "replication_factor=$REPLICATION_FACTOR"
|
||||
echo "recovered_volume_count=$(grep -h '^target_recovered=true$' "$ARTIFACT_DIR"/failover/volume-*/summary.txt 2>/dev/null | wc -l | tr -d '[:space:]')"
|
||||
echo "cross_interference_observed=$(grep -R '^cross_interference_observed=true$' "$ARTIFACT_DIR"/failover/volume-*/summary.txt >/dev/null 2>&1 && echo true || echo false)"
|
||||
echo "cleanup_status=external_to_script"
|
||||
} >"$ARTIFACT_DIR/multi-volume-reattach-summary.txt"
|
||||
}
|
||||
|
||||
trap 'stop_master_port_forward || true' EXIT
|
||||
|
||||
if [[ "$NAMESPACE" != "default" ]]; then
|
||||
echo "only default namespace is supported by this helper" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [[ "$REPLICATION_FACTOR" != "3" ]]; then
|
||||
echo "D2 expects SW_BLOCK_MULTI_VOLUME_RF=3; got $REPLICATION_FACTOR" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log "setup RF=$REPLICATION_FACTOR volumes=$VOLUME_COUNT"
|
||||
(
|
||||
cd "$ROOT"
|
||||
SW_BLOCK_ARTIFACT_DIR="$ARTIFACT_DIR/setup" \
|
||||
SW_BLOCK_MULTI_VOLUME_COUNT="$VOLUME_COUNT" \
|
||||
SW_BLOCK_MULTI_VOLUME_RF="$REPLICATION_FACTOR" \
|
||||
SW_BLOCK_MULTI_VOLUME_CLEANUP=0 \
|
||||
SW_BLOCK_CLI="${SW_BLOCK_CLI:-}" \
|
||||
bash scripts/run-multi-volume-example.sh "$ROOT"
|
||||
)
|
||||
|
||||
for idx in $(seq 1 "$VOLUME_COUNT"); do
|
||||
kubectl -n "$NAMESPACE" delete pod "${POD_PREFIX}-reader-${idx}" --ignore-not-found=true --wait=true --timeout=120s
|
||||
done
|
||||
|
||||
start_master_port_forward
|
||||
collect_cluster "$ARTIFACT_DIR/status/cluster-before.json"
|
||||
kubectl -n "$NAMESPACE" get deploy -l app=sw-blockvolume -o json >"$ARTIFACT_DIR/status/deployments-before.json"
|
||||
extract_plan "$ARTIFACT_DIR/status/cluster-before.json" "$ARTIFACT_DIR/status/deployments-before.json" "$ARTIFACT_DIR/status/failover-plan.tsv"
|
||||
|
||||
while IFS=$'\t' read -r idx vid pvc primary node frontend deploy; do
|
||||
test -n "$vid"
|
||||
test -n "$primary"
|
||||
test -n "$deploy"
|
||||
dir="$ARTIFACT_DIR/failover/volume-${idx}"
|
||||
mkdir -p "$dir"
|
||||
collect_cluster "$dir/before.json"
|
||||
{
|
||||
echo "target_index=$idx"
|
||||
echo "volume_id=$vid"
|
||||
echo "pvc=$pvc"
|
||||
echo "before_primary=$primary"
|
||||
echo "before_primary_node=$node"
|
||||
echo "before_publish_target=$frontend"
|
||||
echo "target_deployment=$deploy"
|
||||
} >"$dir/summary.txt"
|
||||
|
||||
log "target volume $idx primary=$primary deploy=$deploy"
|
||||
kubectl -n "$NAMESPACE" scale "deploy/${deploy}" --replicas=0 | tee "$dir/scale-primary-zero.log"
|
||||
for _ in $(seq 1 60); do
|
||||
ready="$(kubectl -n "$NAMESPACE" get "deploy/${deploy}" -o jsonpath='{.status.readyReplicas}' 2>/dev/null || true)"
|
||||
[[ -z "$ready" || "$ready" == "0" ]] && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
promoted=""
|
||||
for _ in $(seq 1 120); do
|
||||
collect_cluster "$dir/after-poll.json" || true
|
||||
after_primary="$(volume_field "$dir/after-poll.json" "$vid" "primary_replica" || true)"
|
||||
if [[ -n "$after_primary" && "$after_primary" != "$primary" ]]; then
|
||||
promoted="$after_primary"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
if [[ -f "$dir/after-poll.json" ]]; then
|
||||
cp "$dir/after-poll.json" "$dir/after.json"
|
||||
else
|
||||
STATUS="failed"
|
||||
FAILED_PHASE="promotion_volume_${idx}"
|
||||
echo "target_recovered=false" >>"$dir/summary.txt"
|
||||
echo "reason=promotion_poll_missing" >>"$dir/summary.txt"
|
||||
write_summary
|
||||
exit 1
|
||||
fi
|
||||
if [[ -z "$promoted" ]]; then
|
||||
STATUS="failed"
|
||||
FAILED_PHASE="promotion_volume_${idx}"
|
||||
echo "target_recovered=false" >>"$dir/summary.txt"
|
||||
echo "reason=promotion_not_observed" >>"$dir/summary.txt"
|
||||
write_summary
|
||||
exit 1
|
||||
fi
|
||||
after_frontend="$(volume_field "$dir/after.json" "$vid" "publish_target")"
|
||||
primary_count="$(python3 - "$dir/after.json" "$vid" <<'PY'
|
||||
import json, sys
|
||||
doc=json.load(open(sys.argv[1])); vid=sys.argv[2]
|
||||
for v in doc.get("volumes", []):
|
||||
if v.get("volume_id")==vid:
|
||||
print(sum(1 for r in v.get("replicas", []) if r.get("role")=="primary"))
|
||||
break
|
||||
PY
|
||||
)"
|
||||
assert_non_target_stable "$dir/before.json" "$dir/after.json" "$vid" && cross=false || cross=true
|
||||
|
||||
reader="${POD_PREFIX}-reattach-reader-${idx}"
|
||||
kubectl -n "$NAMESPACE" delete pod "$reader" --ignore-not-found=true --wait=true --timeout=120s
|
||||
kubectl apply -f "$(render_reader "$idx" "$reader" "$pvc")" | tee "$dir/apply-reader.log"
|
||||
kubectl -n "$NAMESPACE" wait --for=jsonpath='{.status.phase}'=Succeeded "pod/${reader}" --timeout=240s | tee "$dir/wait-reader.log"
|
||||
kubectl -n "$NAMESPACE" logs "$reader" >"$dir/reader.log"
|
||||
grep -q '/data/demo.bin: OK' "$dir/reader.log"
|
||||
kubectl -n "$NAMESPACE" delete pod "$reader" --ignore-not-found=true --wait=true --timeout=120s
|
||||
|
||||
{
|
||||
echo "failover_status=promoted"
|
||||
echo "promoted_replica=$promoted"
|
||||
echo "after_publish_target=$after_frontend"
|
||||
echo "post_failure_primary_count=$primary_count"
|
||||
echo "reader_verified=true"
|
||||
echo "pod_recreate_used=true"
|
||||
echo "target_recovered=true"
|
||||
echo "cross_interference_observed=$cross"
|
||||
} >>"$dir/summary.txt"
|
||||
if [[ "$primary_count" != "1" || "$cross" != "false" ]]; then
|
||||
STATUS="failed"
|
||||
FAILED_PHASE="isolation_volume_${idx}"
|
||||
write_summary
|
||||
exit 1
|
||||
fi
|
||||
done <"$ARTIFACT_DIR/status/failover-plan.tsv"
|
||||
|
||||
write_summary
|
||||
cat "$ARTIFACT_DIR/multi-volume-reattach-summary.txt"
|
||||
if [[ "$STATUS" != "ok" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
log "PASS: multi-volume reattach recovery complete"
|
||||
@@ -88,13 +88,47 @@ log "delete blockmaster stack"
|
||||
|
||||
kubectl -n kube-system get pods,deploy -o wide >"$ARTIFACT_DIR/kube-system.after-delete.txt" 2>&1 || true
|
||||
kubectl -n "$NAMESPACE" get pods,deploy,pvc,pv -o wide >"$ARTIFACT_DIR/app-namespace.after-delete.txt" 2>&1 || true
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
sudo iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.after-delete.txt" 2>&1 || true
|
||||
if command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then
|
||||
sudo -n iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.after-delete.txt" 2>&1 || true
|
||||
elif command -v iscsiadm >/dev/null 2>&1; then
|
||||
iscsiadm -m session >"$ARTIFACT_DIR/iscsi-sessions.after-delete.txt" 2>&1 || true
|
||||
else
|
||||
echo "iscsiadm unavailable" >"$ARTIFACT_DIR/iscsi-sessions.after-delete.txt"
|
||||
fi
|
||||
|
||||
log "delete stale Seaweed Block iSCSI node records"
|
||||
if command -v iscsiadm >/dev/null 2>&1; then
|
||||
if command -v sudo >/dev/null 2>&1 && sudo -n true >/dev/null 2>&1; then
|
||||
ISCSIADM=(sudo -n iscsiadm)
|
||||
else
|
||||
ISCSIADM=(iscsiadm)
|
||||
fi
|
||||
"${ISCSIADM[@]}" -m node >"$ARTIFACT_DIR/iscsi-nodes.before-scrub.txt" 2>&1 || true
|
||||
scrub_failed=0
|
||||
while read -r portal target; do
|
||||
if [[ -z "$portal" || -z "$target" ]]; then
|
||||
continue
|
||||
fi
|
||||
{
|
||||
echo "portal=$portal target=$target"
|
||||
if ! "${ISCSIADM[@]}" -m node -T "$target" -p "$portal" --logout; then
|
||||
echo "logout_failed=true"
|
||||
fi
|
||||
if ! "${ISCSIADM[@]}" -m node -T "$target" -p "$portal" -o delete; then
|
||||
echo "delete_failed=true"
|
||||
scrub_failed=1
|
||||
fi
|
||||
} >>"$ARTIFACT_DIR/delete-iscsi-node-records.log" 2>&1
|
||||
done < <(awk '/io\.seaweedfs/ {print $1, $2}' "$ARTIFACT_DIR/iscsi-nodes.before-scrub.txt")
|
||||
"${ISCSIADM[@]}" -m node >"$ARTIFACT_DIR/iscsi-nodes.after-scrub.txt" 2>&1 || true
|
||||
if [[ "$scrub_failed" != "0" ]]; then
|
||||
echo "one or more iSCSI node records could not be deleted; see $ARTIFACT_DIR/delete-iscsi-node-records.log" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "iscsiadm unavailable" >"$ARTIFACT_DIR/iscsi-nodes.before-scrub.txt"
|
||||
echo "iscsiadm unavailable" >"$ARTIFACT_DIR/iscsi-nodes.after-scrub.txt"
|
||||
fi
|
||||
|
||||
log "PASS: seaweed-block alpha stack uninstall requested"
|
||||
log "artifacts=$ARTIFACT_DIR"
|
||||
@@ -0,0 +1,47 @@
|
||||
package scripts_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUninstallK8sAlphaDeletesSeaweedISCSINodeRecords(t *testing.T) {
|
||||
root := repoRoot(t)
|
||||
raw, err := os.ReadFile(filepath.Join(root, "scripts", "uninstall-k8s-alpha.sh"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
script := string(raw)
|
||||
for _, want := range []string{
|
||||
"delete stale Seaweed Block iSCSI node records",
|
||||
"iscsi-nodes.before-scrub.txt",
|
||||
"iscsi-nodes.after-scrub.txt",
|
||||
"delete-iscsi-node-records.log",
|
||||
"awk '/io\\.seaweedfs/ {print $1, $2}'",
|
||||
"-m node -T \"$target\" -p \"$portal\" -o delete",
|
||||
} {
|
||||
if !strings.Contains(script, want) {
|
||||
t.Fatalf("uninstall script missing %q", want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func repoRoot(t *testing.T) string {
|
||||
t.Helper()
|
||||
dir, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for {
|
||||
if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
|
||||
return dir
|
||||
}
|
||||
parent := filepath.Dir(dir)
|
||||
if parent == dir {
|
||||
t.Fatal("go.mod not found")
|
||||
}
|
||||
dir = parent
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:-$(pwd)}"
|
||||
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-/tmp/sw-block-basic-app-existing-$(date -u +%Y%m%dT%H%M%SZ)}"
|
||||
NAMESPACE="${SW_BLOCK_APP_NAMESPACE:-default}"
|
||||
PVC_NAME="${SW_BLOCK_BASIC_APP_PVC:-sw-block-example-pvc}"
|
||||
READER_POD="${SW_BLOCK_BASIC_APP_READER:-sw-block-example-reader}"
|
||||
EXAMPLE_DIR="$ROOT/examples/kubernetes/basic-app"
|
||||
BASIC_APP_NODE_SELECTOR="${SW_BLOCK_BASIC_APP_NODE_SELECTOR:-}"
|
||||
|
||||
mkdir -p "$ARTIFACT_DIR"
|
||||
|
||||
if [[ -z "${KUBECONFIG:-}" && -f /etc/rancher/k3s/k3s.yaml ]]; then
|
||||
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||
fi
|
||||
|
||||
log() {
|
||||
printf '[basic-app-existing] %s\n' "$*" | tee -a "$ARTIFACT_DIR/run.log"
|
||||
}
|
||||
|
||||
safe_capture() {
|
||||
local out="$1"
|
||||
shift
|
||||
"$@" >"$out" 2>&1 || true
|
||||
}
|
||||
|
||||
render_pod_manifest() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
if [[ -z "$BASIC_APP_NODE_SELECTOR" ]]; then
|
||||
cp "$input" "$output"
|
||||
return
|
||||
fi
|
||||
awk -v node="$BASIC_APP_NODE_SELECTOR" '
|
||||
/^spec:[[:space:]]*$/ {
|
||||
print
|
||||
print " nodeSelector:"
|
||||
print " kubernetes.io/hostname: \"" node "\""
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
' "$input" >"$output"
|
||||
}
|
||||
|
||||
if [[ "$NAMESPACE" != "default" ]]; then
|
||||
echo "SW_BLOCK_APP_NAMESPACE=$NAMESPACE is not supported by the static basic-app manifests; use default" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ! -f "$EXAMPLE_DIR/reader-pod.yaml" ]]; then
|
||||
echo "reader manifest missing: $EXAMPLE_DIR/reader-pod.yaml" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
log "artifact_dir=$ARTIFACT_DIR"
|
||||
log "namespace=$NAMESPACE"
|
||||
log "pvc=$PVC_NAME"
|
||||
log "app_node_selector=${BASIC_APP_NODE_SELECTOR:-none}"
|
||||
|
||||
safe_capture "$ARTIFACT_DIR/pvc.before-reader.txt" kubectl -n "$NAMESPACE" get pvc "$PVC_NAME" -o wide
|
||||
pvc_phase="$(kubectl -n "$NAMESPACE" get pvc "$PVC_NAME" -o jsonpath='{.status.phase}' 2>/dev/null || true)"
|
||||
pv_name="$(kubectl -n "$NAMESPACE" get pvc "$PVC_NAME" -o jsonpath='{.spec.volumeName}' 2>/dev/null || true)"
|
||||
if [[ "$pvc_phase" != "Bound" || -z "$pv_name" ]]; then
|
||||
{
|
||||
echo "existing_pvc_status=failed"
|
||||
echo "failed_phase=pvc_not_bound"
|
||||
echo "pvc=$PVC_NAME"
|
||||
echo "pvc_phase=${pvc_phase:-unknown}"
|
||||
echo "pv=${pv_name:-unknown}"
|
||||
} >"$ARTIFACT_DIR/existing-pvc-summary.txt"
|
||||
cat "$ARTIFACT_DIR/existing-pvc-summary.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
reader_manifest="$ARTIFACT_DIR/reader-pod.rendered.yaml"
|
||||
render_pod_manifest "$EXAMPLE_DIR/reader-pod.yaml" "$reader_manifest"
|
||||
|
||||
log "replace reader pod and verify existing data"
|
||||
kubectl -n "$NAMESPACE" delete pod "$READER_POD" --ignore-not-found=true --wait=true --timeout=120s | tee "$ARTIFACT_DIR/delete-reader.log"
|
||||
kubectl apply -f "$reader_manifest" | tee "$ARTIFACT_DIR/apply-reader.log"
|
||||
if ! kubectl -n "$NAMESPACE" wait --for=jsonpath='{.status.phase}'=Succeeded "pod/${READER_POD}" --timeout=240s | tee "$ARTIFACT_DIR/wait-reader.log"; then
|
||||
safe_capture "$ARTIFACT_DIR/reader-describe.txt" kubectl -n "$NAMESPACE" describe pod "$READER_POD"
|
||||
safe_capture "$ARTIFACT_DIR/events.txt" kubectl -n "$NAMESPACE" get events --sort-by=.lastTimestamp
|
||||
exit 1
|
||||
fi
|
||||
kubectl -n "$NAMESPACE" logs "$READER_POD" >"$ARTIFACT_DIR/reader.log"
|
||||
grep -q '/data/demo.bin: OK' "$ARTIFACT_DIR/reader.log"
|
||||
|
||||
{
|
||||
echo "existing_pvc_status=ok"
|
||||
echo "pvc=$PVC_NAME"
|
||||
echo "pvc_phase=$pvc_phase"
|
||||
echo "pv=$pv_name"
|
||||
echo "volume_id=$pv_name"
|
||||
echo "reader_verified=true"
|
||||
} >"$ARTIFACT_DIR/existing-pvc-summary.txt"
|
||||
|
||||
cat "$ARTIFACT_DIR/existing-pvc-summary.txt"
|
||||
log "PASS: existing PVC reader verified persisted data"
|
||||
@@ -6,6 +6,8 @@ HELM_RELEASE="${SW_BLOCK_HELM_RELEASE:-sw-block}"
|
||||
HELM_NAMESPACE="${SW_BLOCK_HELM_NAMESPACE:-kube-system}"
|
||||
IQN_SUBSTR="${SW_BLOCK_CLEANUP_IQN_SUBSTR:-io.seaweedfs}"
|
||||
HOSTPATH_PREFIX="${SW_BLOCK_CLEANUP_HOSTPATH_PREFIX:-}"
|
||||
MULTIPATH_ORPHAN_PATTERN="${SW_BLOCK_CLEANUP_MULTIPATH_ORPHAN_PATTERN:-^mpath[^[:space:]]*[[:space:]].*##,##}"
|
||||
MULTIPATH_FLUSH="${SW_BLOCK_CLEANUP_MULTIPATH_FLUSH:-0}"
|
||||
|
||||
mkdir -p "$ARTIFACT_DIR"
|
||||
|
||||
@@ -39,11 +41,23 @@ require_cmd() {
|
||||
fi
|
||||
}
|
||||
|
||||
count_file_matches() {
|
||||
local path="$1"
|
||||
local pattern="$2"
|
||||
if [[ ! -f "$path" ]]; then
|
||||
echo 0
|
||||
return
|
||||
fi
|
||||
grep -c "$pattern" "$path" 2>/dev/null || true
|
||||
}
|
||||
|
||||
log "artifact_dir=$ARTIFACT_DIR"
|
||||
log "helm_release=$HELM_RELEASE"
|
||||
log "helm_namespace=$HELM_NAMESPACE"
|
||||
log "iqn_substr=$IQN_SUBSTR"
|
||||
log "hostpath_prefix=${HOSTPATH_PREFIX:-none}"
|
||||
log "multipath_orphan_pattern=$MULTIPATH_ORPHAN_PATTERN"
|
||||
log "multipath_flush=$MULTIPATH_FLUSH"
|
||||
|
||||
require_cmd kubectl || true
|
||||
require_cmd iscsiadm || true
|
||||
@@ -101,18 +115,88 @@ fi
|
||||
if grep -q "$IQN_SUBSTR" "$ARTIFACT_DIR/iscsi-nodes.after-cleanup.txt"; then
|
||||
mark_fail "iscsi_node_records_present"
|
||||
fi
|
||||
ISCSI_RESIDUE_COUNT=$(( \
|
||||
$(count_file_matches "$ARTIFACT_DIR/iscsi-sessions.after-cleanup.txt" "$IQN_SUBSTR") + \
|
||||
$(count_file_matches "$ARTIFACT_DIR/iscsi-nodes.after-cleanup.txt" "$IQN_SUBSTR") \
|
||||
))
|
||||
|
||||
if command -v multipath >/dev/null 2>&1; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
capture "multipath.after-cleanup.txt" sudo -n multipath -ll
|
||||
capture_multipath_state() {
|
||||
if command -v multipath >/dev/null 2>&1; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
capture "multipath.after-cleanup.txt" sudo -n multipath -ll
|
||||
else
|
||||
capture "multipath.after-cleanup.txt" multipath -ll
|
||||
fi
|
||||
else
|
||||
capture "multipath.after-cleanup.txt" multipath -ll
|
||||
echo "multipath unavailable" >"$ARTIFACT_DIR/multipath.after-cleanup.txt"
|
||||
fi
|
||||
if grep -Eiq '(io\.seaweedfs|SeaweedF|BlockVol)' "$ARTIFACT_DIR/multipath.after-cleanup.txt"; then
|
||||
mark_fail "multipath_maps_present"
|
||||
|
||||
if command -v dmsetup >/dev/null 2>&1; then
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
capture "dmsetup.after-cleanup.txt" sudo -n dmsetup ls --tree
|
||||
else
|
||||
capture "dmsetup.after-cleanup.txt" dmsetup ls --tree
|
||||
fi
|
||||
else
|
||||
echo "dmsetup unavailable" >"$ARTIFACT_DIR/dmsetup.after-cleanup.txt"
|
||||
fi
|
||||
else
|
||||
echo "multipath unavailable" >"$ARTIFACT_DIR/multipath.after-cleanup.txt"
|
||||
}
|
||||
|
||||
collect_multipath_residue() {
|
||||
local out="$1"
|
||||
: >"$out"
|
||||
grep -Ei "(io\.seaweedfs|SeaweedF|BlockVol|$MULTIPATH_ORPHAN_PATTERN)" "$ARTIFACT_DIR/multipath.after-cleanup.txt" >>"$out" 2>/dev/null || true
|
||||
grep -E '^mpath[^[:space:]]*[[:space:]]' "$ARTIFACT_DIR/dmsetup.after-cleanup.txt" >>"$out" 2>/dev/null || true
|
||||
}
|
||||
|
||||
capture_multipath_state
|
||||
collect_multipath_residue "$ARTIFACT_DIR/multipath-residue.before-flush.txt"
|
||||
|
||||
if [[ "$MULTIPATH_FLUSH" == "1" && -s "$ARTIFACT_DIR/multipath-residue.before-flush.txt" ]]; then
|
||||
log "multipath_flush_attempt=1"
|
||||
capture "kubelet-mounts.before-multipath-flush.txt" findmnt -R /var/lib/kubelet -o TARGET,SOURCE,FSTYPE,OPTIONS
|
||||
while read -r map rest; do
|
||||
[[ "$map" == mpath* ]] || continue
|
||||
dm="$(printf '%s\n' "${rest:-}" | grep -o 'dm-[0-9]\+' | head -1 || true)"
|
||||
log "multipath_flush_map=$map dm=${dm:-unknown}"
|
||||
{
|
||||
findmnt -rn -S "/dev/mapper/$map" -o TARGET 2>/dev/null || true
|
||||
if [[ "$dm" == dm-* ]]; then
|
||||
findmnt -rn -S "/dev/$dm" -o TARGET 2>/dev/null || true
|
||||
fi
|
||||
lsblk -nr -o MOUNTPOINT "/dev/mapper/$map" 2>/dev/null || \
|
||||
lsblk -nr -o MOUNTPOINTS "/dev/mapper/$map" 2>/dev/null | sed 's/\\x0a/\n/g' || true
|
||||
} | awk 'NF {print}' | sort -u | while read -r mountpoint; do
|
||||
[[ "$mountpoint" == /var/lib/kubelet/* ]] || continue
|
||||
log "unmount_stale_kubelet_path=$mountpoint"
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
sudo -n umount -fl "$mountpoint" >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
else
|
||||
umount -fl "$mountpoint" >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
fi
|
||||
done
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
sudo -n multipath -f "$map" >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
sudo -n dmsetup remove -f "$map" >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
else
|
||||
multipath -f "$map" >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
dmsetup remove -f "$map" >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
fi
|
||||
done <"$ARTIFACT_DIR/multipath-residue.before-flush.txt"
|
||||
if command -v sudo >/dev/null 2>&1; then
|
||||
sudo -n multipath -F >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
sudo -n udevadm settle >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
else
|
||||
multipath -F >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
udevadm settle >>"$ARTIFACT_DIR/multipath-flush.log" 2>&1 || true
|
||||
fi
|
||||
capture "kubelet-mounts.after-multipath-flush.txt" findmnt -R /var/lib/kubelet -o TARGET,SOURCE,FSTYPE,OPTIONS
|
||||
capture_multipath_state
|
||||
fi
|
||||
|
||||
collect_multipath_residue "$ARTIFACT_DIR/multipath-residue.after-cleanup.txt"
|
||||
if [[ -s "$ARTIFACT_DIR/multipath-residue.after-cleanup.txt" ]]; then
|
||||
mark_fail "multipath_maps_present"
|
||||
fi
|
||||
|
||||
capture "processes.after-cleanup.txt" ps -eo pid,args
|
||||
@@ -145,7 +229,9 @@ fi
|
||||
echo "helm_namespace=$HELM_NAMESPACE"
|
||||
echo "iqn_substr=$IQN_SUBSTR"
|
||||
echo "k8s_residue_count=$(wc -l <"$ARTIFACT_DIR/k8s-residue.after-cleanup.txt")"
|
||||
echo "iscsi_residue_count=$ISCSI_RESIDUE_COUNT"
|
||||
echo "process_residue_count=$(wc -l <"$ARTIFACT_DIR/process-residue.after-cleanup.txt")"
|
||||
echo "multipath_residue_count=$(wc -l <"$ARTIFACT_DIR/multipath-residue.after-cleanup.txt")"
|
||||
echo "hostpath_residue_count=$(wc -l <"$ARTIFACT_DIR/hostpath-residue.after-cleanup.txt")"
|
||||
echo "failure_count=$failures"
|
||||
} >"$ARTIFACT_DIR/cleanup-summary.txt"
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="${1:-$(pwd)}"
|
||||
VALUES_FILE="${SW_BLOCK_HELM_VALUES_FILE:-}"
|
||||
OUT_DIR="${SW_BLOCK_ARTIFACT_DIR:-"$ROOT/tmp/helm-release-hygiene"}"
|
||||
RELEASE_NAME="${SW_BLOCK_HELM_RELEASE:-sw-block}"
|
||||
NAMESPACE="${SW_BLOCK_HELM_NAMESPACE:-kube-system}"
|
||||
CHART_DIR="$ROOT/charts/seaweed-block"
|
||||
|
||||
require_cmd() {
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
echo "missing required command: $1" >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
chart_field() {
|
||||
local field="$1"
|
||||
awk -F: -v key="$field" '$1 == key {gsub(/^[ \t"]+|[ \t"]+$/, "", $2); print $2; exit}' "$CHART_DIR/Chart.yaml"
|
||||
}
|
||||
|
||||
require_cmd helm
|
||||
require_cmd awk
|
||||
require_cmd grep
|
||||
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
if [[ ! -f "$CHART_DIR/Chart.yaml" ]]; then
|
||||
echo "helm_hygiene_status=failed"
|
||||
echo "failed_phase=chart_missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chart_name="$(chart_field name)"
|
||||
chart_version="$(chart_field version)"
|
||||
chart_app_version="$(chart_field appVersion)"
|
||||
|
||||
if [[ -z "$chart_name" || -z "$chart_version" || -z "$chart_app_version" ]]; then
|
||||
{
|
||||
echo "helm_hygiene_status=failed"
|
||||
echo "failed_phase=chart_metadata"
|
||||
echo "chart_name=$chart_name"
|
||||
echo "chart_version=$chart_version"
|
||||
echo "chart_app_version=$chart_app_version"
|
||||
} | tee "$OUT_DIR/helm-release-hygiene-summary.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
helm_args=()
|
||||
if [[ -n "$VALUES_FILE" ]]; then
|
||||
if [[ ! -f "$VALUES_FILE" ]]; then
|
||||
{
|
||||
echo "helm_hygiene_status=failed"
|
||||
echo "failed_phase=values_missing"
|
||||
echo "values_file=$VALUES_FILE"
|
||||
} | tee "$OUT_DIR/helm-release-hygiene-summary.txt"
|
||||
exit 1
|
||||
fi
|
||||
helm_args=(-f "$VALUES_FILE")
|
||||
fi
|
||||
|
||||
helm lint "$CHART_DIR" "${helm_args[@]}" >"$OUT_DIR/helm-lint.txt"
|
||||
helm template "$RELEASE_NAME" "$CHART_DIR" \
|
||||
--namespace "$NAMESPACE" \
|
||||
"${helm_args[@]}" >"$OUT_DIR/helm-template.yaml"
|
||||
helm package "$CHART_DIR" --destination "$OUT_DIR" >"$OUT_DIR/helm-package.txt"
|
||||
|
||||
package_file="$OUT_DIR/$chart_name-$chart_version.tgz"
|
||||
if [[ ! -s "$package_file" ]]; then
|
||||
{
|
||||
echo "helm_hygiene_status=failed"
|
||||
echo "failed_phase=package_missing"
|
||||
echo "package_file=$package_file"
|
||||
} | tee "$OUT_DIR/helm-release-hygiene-summary.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rendered_storageclass_count="$(grep -c '^kind: StorageClass$' "$OUT_DIR/helm-template.yaml" || true)"
|
||||
rendered_csidriver_count="$(grep -c '^kind: CSIDriver$' "$OUT_DIR/helm-template.yaml" || true)"
|
||||
rendered_master_count="$(grep -c 'name: sw-blockmaster' "$OUT_DIR/helm-template.yaml" || true)"
|
||||
|
||||
{
|
||||
echo "helm_hygiene_status=ok"
|
||||
echo "chart_name=$chart_name"
|
||||
echo "chart_version=$chart_version"
|
||||
echo "chart_app_version=$chart_app_version"
|
||||
echo "values_file=${VALUES_FILE:-default}"
|
||||
echo "lint=helm-lint.txt"
|
||||
echo "template=helm-template.yaml"
|
||||
echo "package=$(basename "$package_file")"
|
||||
echo "rendered_storageclass_count=$rendered_storageclass_count"
|
||||
echo "rendered_csidriver_count=$rendered_csidriver_count"
|
||||
echo "rendered_master_count=$rendered_master_count"
|
||||
} | tee "$OUT_DIR/helm-release-hygiene-summary.txt"
|
||||
@@ -34,13 +34,16 @@ phases:
|
||||
cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/uninstall /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build"
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "cd {{ product_root }} && git rev-parse HEAD > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build/git.sha && git status --porcelain > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build/git.status && test ! -s /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build/git.status"
|
||||
cmd: "cd {{ product_root }} && if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then git rev-parse HEAD > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build/git.sha && git status --porcelain > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build/git.status && test ! -s /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build/git.status; else echo no-git-worktree > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build/git.sha; : > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/pin_build/git.status; fi"
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "command -v iscsiadm >/dev/null && (sudo -n iscsiadm -m session > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/iscsi-sessions.after-cleanup.txt 2>&1 || grep -q 'No active sessions' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/iscsi-sessions.after-cleanup.txt)"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/verify-cleanup bash scripts/verify-helm-cleanup.sh {{ product_root }}"
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "sudo nvme list-subsys -o json > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/nvme-list-subsys.after-cleanup.json 2> /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/nvme-list-subsys.after-cleanup.err && ! grep -Ei 'nqn\\.[^[:space:]\"}]*seaweedfs|nqn\\.[^[:space:]\"}]*sw-block|nqn\\.[^[:space:]\"}]*weedblock' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-cleanup-residue/nvme-list-subsys.after-cleanup.json"
|
||||
|
||||
@@ -20,8 +20,8 @@ env:
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "ghcr.io/seaweedfs/seaweed-block:sha-28a99ce4f644"
|
||||
sw_block_csi_image: "ghcr.io/seaweedfs/seaweed-block-csi:sha-28a99ce4f644"
|
||||
sw_block_image: "ghcr.io/seaweedfs/seaweed-block:sha-6260e46fd3be"
|
||||
sw_block_csi_image: "ghcr.io/seaweedfs/seaweed-block-csi:sha-6260e46fd3be"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
@@ -161,6 +161,51 @@ phases:
|
||||
- action: assert_greater
|
||||
actual: "{{ report_html_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-cli-first-volume/basic-app/first-volume-summary.txt"
|
||||
pattern: "^operator_snapshot=status/report/operator-snapshot.json$"
|
||||
save_as: operator_snapshot_summary_count
|
||||
- action: assert_greater
|
||||
actual: "{{ operator_snapshot_summary_count }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 1m
|
||||
cmd: |
|
||||
set -e;
|
||||
out=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-cli-first-volume/basic-app/status/report/dashboard-route;
|
||||
mkdir -p "$out";
|
||||
port=$(python3 - <<'PY'
|
||||
import socket
|
||||
s = socket.socket()
|
||||
s.bind(("127.0.0.1", 0))
|
||||
print(s.getsockname()[1])
|
||||
s.close()
|
||||
PY
|
||||
);
|
||||
echo "$port" > "$out/dashboard.port";
|
||||
/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-cli-first-volume/bin/sw-block ops dashboard --from-bundle /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-cli-first-volume/basic-app --listen 127.0.0.1:${port} > "$out/dashboard.stdout.txt" 2> "$out/dashboard.stderr.txt" &
|
||||
pid=$!;
|
||||
trap 'kill $pid >/dev/null 2>&1 || true; wait $pid >/dev/null 2>&1 || true' EXIT;
|
||||
for i in $(seq 1 100); do
|
||||
code=$(curl -s -o "$out/operator-snapshot.json" -w '%{http_code}' "http://127.0.0.1:${port}/operator-snapshot.json" || true);
|
||||
if [ "$code" = "200" ] && python3 - "$out/operator-snapshot.json" <<'PY'
|
||||
import json, sys
|
||||
doc = json.load(open(sys.argv[1]))
|
||||
if doc.get("read_only") is not True:
|
||||
raise SystemExit(1)
|
||||
if (doc.get("mutation") or {}).get("mutation_allowed") is not False:
|
||||
raise SystemExit(1)
|
||||
PY
|
||||
then
|
||||
exit 0;
|
||||
fi;
|
||||
sleep 0.2;
|
||||
done;
|
||||
echo "operator-snapshot route failed" >&2;
|
||||
cat "$out/dashboard.stderr.txt" >&2 || true;
|
||||
exit 1
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
# Runner-native Phase 26 D2 gate: Helm install / upgrade / rollback lifecycle.
|
||||
#
|
||||
# Goal:
|
||||
# Prove the chart handles a narrow release lifecycle smoke:
|
||||
# generate values
|
||||
# -> helm install
|
||||
# -> first PVC writer/reader, keep PVC
|
||||
# -> helm upgrade with the same chart/values
|
||||
# -> verify existing PVC data
|
||||
# -> helm rollback to revision 1
|
||||
# -> verify existing PVC data again
|
||||
# -> helm uninstall and strict cleanup
|
||||
|
||||
name: helm-lifecycle-upgrade-rollback-chain
|
||||
timeout: 32m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "ghcr.io/seaweedfs/seaweed-block:sha-6260e46fd3be"
|
||||
sw_block_csi_image: "ghcr.io/seaweedfs/seaweed-block-csi:sha-6260e46fd3be"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s || true; kubectl -n default delete pod sw-block-example-reader sw-block-example-writer --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-example-pvc --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-example --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/first-volume /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/upgrade /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/after-upgrade /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/rollback /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/after-rollback /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values/generate.stdout.txt && cd {{ product_root }} && bash scripts/verify-helm-release-hygiene.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values/hygiene"
|
||||
env.SW_BLOCK_HELM_VALUES_FILE: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values/values.day1.yaml"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values/values.day1.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/install/helm-install.txt && helm history {{ helm_release }} --namespace {{ helm_namespace }} > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/install/helm-history.after-install.txt && kubectl -n {{ helm_namespace }} get deploy,ds,pods,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/install/kube-system.after-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: first_volume_keep_pvc
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-basic-app-example.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/first-volume"
|
||||
env.SW_BLOCK_BASIC_APP_CLEANUP: "0"
|
||||
env.SW_BLOCK_INSTALL_MODE: "helm-lifecycle"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_HELM_VALUES_FILE: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values/values.day1.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/first-volume/first-volume-summary.txt"
|
||||
pattern: "^first_volume_status=ok$"
|
||||
save_as: first_volume_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ first_volume_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_upgrade_and_verify
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm upgrade {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/values/values.day1.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/upgrade/helm-upgrade.txt && helm history {{ helm_release }} --namespace {{ helm_namespace }} > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/upgrade/helm-history.after-upgrade.txt && bash scripts/verify-basic-app-existing-pvc.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/after-upgrade"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/after-upgrade/existing-pvc-summary.txt"
|
||||
pattern: "^existing_pvc_status=ok$"
|
||||
save_as: after_upgrade_reader_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ after_upgrade_reader_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/upgrade/helm-history.after-upgrade.txt"
|
||||
pattern: "superseded"
|
||||
save_as: helm_superseded_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_superseded_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_rollback_and_verify
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "helm rollback {{ helm_release }} 1 --namespace {{ helm_namespace }} --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/rollback/helm-rollback.txt && helm history {{ helm_release }} --namespace {{ helm_namespace }} > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/rollback/helm-history.after-rollback.txt && cd {{ product_root }} && bash scripts/verify-basic-app-existing-pvc.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/after-rollback"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/after-rollback/existing-pvc-summary.txt"
|
||||
pattern: "^existing_pvc_status=ok$"
|
||||
save_as: after_rollback_reader_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ after_rollback_reader_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/rollback/helm-history.after-rollback.txt"
|
||||
pattern: "deployed"
|
||||
save_as: helm_deployed_after_rollback_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_after_rollback_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/cleanup/helm-uninstall.txt || true; kubectl -n default delete pod sw-block-example-reader sw-block-example-writer --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-example-pvc --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-example --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-lifecycle/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
@@ -0,0 +1,172 @@
|
||||
# Runner-native Phase 26 D3 gate: multi-volume Day-1 smoke.
|
||||
#
|
||||
# Goal:
|
||||
# Prove the Helm-installed StorageClass can handle a small multi-PVC user
|
||||
# shape and that ops report/dashboard evidence distinguishes each volume.
|
||||
|
||||
name: helm-multi-volume-day1-chain
|
||||
timeout: 34m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase26-d3"
|
||||
sw_block_csi_image: "sw-block-csi:phase26-d3"
|
||||
volume_count: "3"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s || true; kubectl -n default delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-writer-$i sw-block-multi-reader-$i --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-$i --ignore-not-found=true --wait=true --timeout=120s; done; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/multi-volume /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/build/alpha-images.env"
|
||||
pattern: "SW_BLOCK_IMAGE={{ sw_block_image }}"
|
||||
save_as: local_image_built_count
|
||||
- action: assert_greater
|
||||
actual: "{{ local_image_built_count }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/values/generate.stdout.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm lint charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/values/values.day1.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/install/helm-lint.txt && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/values/values.day1.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/install/helm-install.txt && kubectl -n {{ helm_namespace }} get deploy,ds,pods,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/install/kube-system.after-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: multi_volume_user_loop
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 12m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-multi-volume-example.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/multi-volume"
|
||||
env.SW_BLOCK_MULTI_VOLUME_COUNT: "{{ volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_CLEANUP: "1"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^multi_volume_status=ok$"
|
||||
save_as: multi_volume_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ multi_volume_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: multi_volume_asserts
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^writer_verified_count=3$"
|
||||
save_as: writer_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ writer_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^reader_verified_count=3$"
|
||||
save_as: reader_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ reader_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^managed_volume_count=3$"
|
||||
save_as: managed_volume_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ managed_volume_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/multi-volume/status/report/summary.txt"
|
||||
pattern: "^volumes=3$"
|
||||
save_as: report_volume_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ report_volume_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "for i in $(seq 1 60); do out=$(kubectl -n default get deploy -l app=sw-blockvolume -o name 2>/dev/null); if [ -z \"$out\" ]; then exit 0; fi; sleep 2; done; echo \"timeout: launcher-rendered deployments still present\" >&2; kubectl -n default get deploy -l app=sw-blockvolume -o wide >&2; exit 1"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/cleanup/helm-uninstall.txt || true; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-writer-$i sw-block-multi-reader-$i --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-$i --ignore-not-found=true --wait=true --timeout=120s; done; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
@@ -0,0 +1,247 @@
|
||||
# Phase 27 D8: multi-volume RF=3 mounted failover with app pods spread across nodes.
|
||||
#
|
||||
# Pass = three RF=3 PVCs are mounted by long-running writer pods distributed
|
||||
# across m01/m02/tp01, each target volume's current primary is stopped in turn,
|
||||
# the same writer pod UID verifies old data and writes new data through
|
||||
# dm-multipath, and cleanup is clean.
|
||||
|
||||
name: helm-multi-volume-rf3-app-spread-failover-chain
|
||||
timeout: 52m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase27-d8"
|
||||
sw_block_csi_image: "sw-block-csi:phase27-d8"
|
||||
volume_count: "3"
|
||||
replication_factor: "3"
|
||||
app_nodes: "m01,m02,tp01"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: |
|
||||
set -e
|
||||
helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s >/dev/null 2>&1 || true
|
||||
kubectl -n default delete pod -l sw-block-test=multi-volume-mounted-failover --ignore-not-found=true --wait=true --timeout=180s
|
||||
for i in 1 2 3; do
|
||||
kubectl -n default delete pod sw-block-multi-mounted-writer-$i --ignore-not-found=true --wait=true --timeout=180s
|
||||
kubectl -n default delete pvc sw-block-multi-mounted-pvc-$i --ignore-not-found=true --wait=true --timeout=180s
|
||||
done
|
||||
kubectl delete storageclass sw-block-multi-mounted sw-block-dynamic --ignore-not-found=true --wait=true --timeout=180s
|
||||
kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true
|
||||
for ip in 192.168.1.181 192.168.1.184 192.168.1.188; do
|
||||
if [ "$ip" = "192.168.1.184" ]; then runner="bash -lc"; else runner="ssh -i /opt/work/testdev_key -o StrictHostKeyChecking=no testdev@$ip"; fi
|
||||
$runner 'sudo -n iscsiadm -m node 2>/dev/null | awk '"'"'/io.seaweedfs/ {print $1, $2}'"'"' | while read portal target; do sudo -n iscsiadm -m node -T "$target" -p "$portal" --logout >/dev/null 2>&1 || true; sudo -n iscsiadm -m node -T "$target" -p "$portal" -o delete >/dev/null 2>&1 || true; done; sudo -n multipath -F >/dev/null 2>&1 || true'
|
||||
done
|
||||
rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover
|
||||
mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/recovery /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/cleanup
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/preclean/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLEANUP_MULTIPATH_FLUSH: "1"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
|
||||
- name: preflight
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "kubectl get nodes -o wide | tee /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/preflight-nodes.txt && kubectl get nodes --no-headers | awk '$2==\"Ready\"{c++} END{if(c<3){exit 1}}'"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/preflight-nodes.txt"
|
||||
pattern: "Ready"
|
||||
save_as: ready_node_count
|
||||
- action: assert_greater
|
||||
actual: "{{ ready_node_count }}"
|
||||
threshold: "2"
|
||||
|
||||
- name: host_multipath_prereq
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: |
|
||||
set -e
|
||||
B=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover
|
||||
: > "$B/multipath-prereq.txt"
|
||||
for spec in m01:192.168.1.181 m02:192.168.1.184 tp01:192.168.1.188; do
|
||||
name="${spec%%:*}"
|
||||
ip="${spec#*:}"
|
||||
if [ "$ip" = "192.168.1.184" ]; then runner="bash -lc"; else runner="ssh -i /opt/work/testdev_key -o StrictHostKeyChecking=no testdev@$ip"; fi
|
||||
$runner 'set -e; command -v iscsiadm >/dev/null; command -v multipath >/dev/null; command -v sg_rtpg >/dev/null; sudo modprobe iscsi_tcp; sudo modprobe dm_multipath; sudo modprobe scsi_dh_alua; test -d /sys/module/iscsi_tcp; test -d /sys/module/dm_multipath; test -d /sys/module/scsi_dh_alua; sudo multipath -t >/tmp/sw-block-multipath-prereq.config.txt 2>&1'
|
||||
echo "node=${name} multipath_prereq=pass" >> "$B/multipath-prereq.txt"
|
||||
done
|
||||
echo multipath_prereq=pass >> "$B/multipath-prereq.txt"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/multipath-prereq.txt"
|
||||
pattern: "multipath_prereq=pass"
|
||||
save_as: multipath_prereq_count
|
||||
- action: assert_greater
|
||||
actual: "{{ multipath_prereq_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} --replication-factor {{ replication_factor }} --ack-profile sync-quorum --stage2-multipath > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/values/generate.stdout.txt && python3 - <<'PY'\nfrom pathlib import Path\np=Path('/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/values/values.day1.yaml')\ns=p.read_text()\ns=s.replace('launcherReplicationAckFlag: false','launcherReplicationAckFlag: true')\np.write_text(s)\nPY"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: |
|
||||
set -e
|
||||
B=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover
|
||||
cd {{ product_root }}
|
||||
helm lint charts/seaweed-block -f "$B/values/values.day1.yaml" > "$B/install/helm-lint.txt"
|
||||
helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f "$B/values/values.day1.yaml" --wait --timeout 10m > "$B/install/helm-install.txt"
|
||||
kubectl -n {{ helm_namespace }} rollout status deploy/sw-blockmaster --timeout=180s > "$B/install/rollout-blockmaster.txt"
|
||||
kubectl -n {{ helm_namespace }} rollout status deploy/sw-block-csi-controller --timeout=180s > "$B/install/rollout-csi-controller.txt"
|
||||
kubectl -n {{ helm_namespace }} rollout status ds/sw-block-csi-node --timeout=180s > "$B/install/rollout-csi-node.txt"
|
||||
helm get values {{ helm_release }} --namespace {{ helm_namespace }} --all > "$B/install/helm-values.applied.yaml"
|
||||
helm get manifest {{ helm_release }} --namespace {{ helm_namespace }} > "$B/install/helm-manifest.yaml"
|
||||
kubectl -n {{ helm_namespace }} get pods,deploy,ds,svc -o wide > "$B/install/kube-system.after-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/install/helm-manifest.yaml"
|
||||
pattern: "sw-block:phase27-d8"
|
||||
save_as: helm_manifest_phase_image_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_manifest_phase_image_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: app_spread_mounted_failover
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 34m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-multi-volume-mounted-failover.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/recovery"
|
||||
env.SW_BLOCK_MULTI_VOLUME_COUNT: "{{ volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_RF: "{{ replication_factor }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_APP_NODE: "{{ app_nodes }}"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^multi_volume_mounted_failover_status=ok$"
|
||||
save_as: mounted_failover_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ mounted_failover_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: app_spread_asserts
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^app_node_distribution_count=3$"
|
||||
save_as: app_spread_count
|
||||
- action: assert_greater
|
||||
actual: "{{ app_spread_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^recovered_volume_count=3$"
|
||||
save_as: recovered_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ recovered_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 2m
|
||||
cmd: "B=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/recovery/failover; grep -q '^writer_node=m01$' \"$B/volume-1/summary.txt\"; grep -q '^writer_node=m02$' \"$B/volume-2/summary.txt\"; grep -q '^writer_node=tp01$' \"$B/volume-3/summary.txt\"; for i in 1 2 3; do S=$B/volume-$i/summary.txt; grep -q '^failover_status=promoted$' \"$S\"; grep -q '^target_recovered=true$' \"$S\"; grep -q '^pod_recreate_used=false$' \"$S\"; grep -q '^rtpg_transition_verified=true$' \"$S\"; grep -q '^old_primary_stale_io_success_count=0$' \"$S\"; done"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: |
|
||||
helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/cleanup/helm-uninstall.txt || true
|
||||
kubectl -n default delete pod -l sw-block-test=multi-volume-mounted-failover --ignore-not-found=true --force --grace-period=0 --wait=false
|
||||
for i in 1 2 3; do kubectl -n default delete pvc sw-block-multi-mounted-pvc-$i --ignore-not-found=true --wait=false; done
|
||||
kubectl delete storageclass sw-block-multi-mounted sw-block-dynamic --ignore-not-found=true --wait=false
|
||||
kubectl -n default delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=false
|
||||
for ip in 192.168.1.181 192.168.1.184 192.168.1.188; do
|
||||
if [ "$ip" = "192.168.1.184" ]; then runner="bash -lc"; else runner="ssh -i /opt/work/testdev_key -o StrictHostKeyChecking=no testdev@$ip"; fi
|
||||
$runner 'sudo -n iscsiadm -m node 2>/dev/null | awk '"'"'/io.seaweedfs/ {print $1, $2}'"'"' | while read portal target; do sudo -n iscsiadm -m node -T "$target" -p "$portal" --logout >/dev/null 2>&1 || true; sudo -n iscsiadm -m node -T "$target" -p "$portal" -o delete >/dev/null 2>&1 || true; done; sudo -n multipath -F >/dev/null 2>&1 || true'
|
||||
done
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/cleanup/verify SW_BLOCK_HELM_RELEASE={{ helm_release }} SW_BLOCK_HELM_NAMESPACE={{ helm_namespace }} SW_BLOCK_CLEANUP_MULTIPATH_FLUSH=1 bash scripts/verify-helm-cleanup.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "(blockmaster|blockvolume|blockcsi|iscsi-target)"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-app-spread-failover/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
# Phase 27 D4: multi-volume RF=3 interleaved mounted failover.
|
||||
#
|
||||
# Pass = three RF=3 PVCs are mounted by long-running writer pods on the same
|
||||
# kubelet, two target volumes have their current primaries stopped in one bounded window, the same
|
||||
# writer pod UID verifies old data and writes new data through dm-multipath,
|
||||
# non-target mounted workloads keep working, and cleanup is clean.
|
||||
|
||||
name: helm-multi-volume-rf3-interleaved-failover-chain
|
||||
timeout: 52m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase27-d4"
|
||||
sw_block_csi_image: "sw-block-csi:phase27-d4"
|
||||
volume_count: "3"
|
||||
target_volume_count: "2"
|
||||
replication_factor: "3"
|
||||
app_node: "m02"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s || true; kubectl -n default delete pod -l sw-block-test=multi-volume-mounted-failover --ignore-not-found=true --wait=true --timeout=180s; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-mounted-writer-$i --ignore-not-found=true --wait=true --timeout=180s; kubectl -n default delete pvc sw-block-multi-mounted-pvc-$i --ignore-not-found=true --wait=true --timeout=180s; done; kubectl delete storageclass sw-block-multi-mounted sw-block-dynamic --ignore-not-found=true --wait=true --timeout=180s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n multipath -F >/dev/null 2>&1 || true; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/preclean/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLEANUP_MULTIPATH_FLUSH: "1"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
|
||||
- name: preflight
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "cd {{ product_root }} && bash scripts/preflight-k8s-alpha.sh --local-k3s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/preflight.txt 2>&1"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/preflight.txt"
|
||||
pattern: "summary status=PASS"
|
||||
save_as: preflight_count
|
||||
- action: assert_greater
|
||||
actual: "{{ preflight_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: host_multipath_prereq
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "set -e; B=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover; { echo stage2_protocol=iscsi-alua; command -v iscsiadm >/dev/null && echo command_iscsiadm=present; command -v multipath >/dev/null && echo command_multipath=present; command -v sg_rtpg >/dev/null && echo command_sg_rtpg=present; sudo modprobe iscsi_tcp; sudo modprobe dm_multipath; sudo modprobe scsi_dh_alua; test -d /sys/module/iscsi_tcp && echo module_iscsi_tcp=loaded; test -d /sys/module/dm_multipath && echo module_dm_multipath=loaded; test -d /sys/module/scsi_dh_alua && echo module_scsi_dh_alua=loaded; sudo multipath -t > \"$B/multipath-prereq.config.txt\" 2>&1; echo multipath_prereq=pass; } > \"$B/multipath-prereq.txt\" 2>&1"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/multipath-prereq.txt"
|
||||
pattern: "multipath_prereq=pass"
|
||||
save_as: multipath_prereq_count
|
||||
- action: assert_greater
|
||||
actual: "{{ multipath_prereq_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} --replication-factor {{ replication_factor }} --ack-profile sync-quorum --stage2-multipath > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/generate.stdout.txt && python3 - <<'PY'\nfrom pathlib import Path\np=Path('/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/values.day1.yaml')\ns=p.read_text()\ns=s.replace('launcherReplicationAckFlag: false','launcherReplicationAckFlag: true')\np.write_text(s)\nPY"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/values.day1.yaml"
|
||||
pattern: "replicationFactor: 3"
|
||||
save_as: rf3_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ rf3_in_values }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/values.day1.yaml"
|
||||
pattern: "ackProfile: sync-quorum"
|
||||
save_as: sync_quorum_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ sync_quorum_in_values }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/values.day1.yaml"
|
||||
pattern: "enabled: true"
|
||||
save_as: stage2_enabled_count
|
||||
- action: assert_greater
|
||||
actual: "{{ stage2_enabled_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/values.day1.yaml"
|
||||
pattern: "launcherReplicationAckFlag: true"
|
||||
save_as: ack_flag_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ ack_flag_in_values }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm lint charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/values.day1.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/install/helm-lint.txt && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/values/values.day1.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/install/helm-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: multi_volume_interleaved_failover
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 34m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-multi-volume-mounted-failover.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery"
|
||||
env.SW_BLOCK_MULTI_VOLUME_COUNT: "{{ volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_RF: "{{ replication_factor }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_FAILOVER_MODE: "interleaved"
|
||||
env.SW_BLOCK_MULTI_VOLUME_TARGET_COUNT: "{{ target_volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_APP_NODE: "{{ app_node }}"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^multi_volume_interleaved_failover_status=ok$"
|
||||
save_as: interleaved_failover_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ interleaved_failover_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: interleaved_failover_asserts
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^recovered_volume_count=2$"
|
||||
save_as: recovered_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ recovered_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^mounted_workload_checksum_passed_count=2$"
|
||||
save_as: mounted_workload_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ mounted_workload_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^failover_mode=interleaved$"
|
||||
save_as: interleaved_mode_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ interleaved_mode_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^target_volume_count=2$"
|
||||
save_as: target_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ target_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^untouched_volume_stable=true$"
|
||||
save_as: untouched_stable_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ untouched_stable_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^untouched_workload_ok=true$"
|
||||
save_as: untouched_workload_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ untouched_workload_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^pod_recreate_used=false$"
|
||||
save_as: no_pod_recreate
|
||||
- action: assert_greater
|
||||
actual: "{{ no_pod_recreate }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^cross_interference_observed=false$"
|
||||
save_as: no_cross_interference
|
||||
- action: assert_greater
|
||||
actual: "{{ no_cross_interference }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/host/multipath.before.txt"
|
||||
pattern: "hwhandler='1 alua'"
|
||||
save_as: multipath_alua_count
|
||||
- action: assert_greater
|
||||
actual: "{{ multipath_alua_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/host/sg-rtpg.before.txt"
|
||||
pattern: "asymmetric access state"
|
||||
save_as: rtpg_before_count
|
||||
- action: assert_greater
|
||||
actual: "{{ rtpg_before_count }}"
|
||||
threshold: "2"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 2m
|
||||
cmd: "for i in 1 2; do D=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/failover/volume-$i; S=$D/summary.txt; P=$D/stale-primary-probe.log; B=$D/rtpg-before-states.txt; A=$D/rtpg-after-states.txt; grep -q '^interleaved_fault=true$' \"$S\"; grep -q '^failover_status=promoted$' \"$S\"; grep -q '^target_recovered=true$' \"$S\"; grep -q '^pod_recreate_used=false$' \"$S\"; grep -q '^data_check_after_failover=mounted_workload_checksum_passed$' \"$S\"; grep -q '^post_failure_primary_count=1$' \"$S\"; grep -q '^stale_primary_probe=direct_read$' \"$S\"; grep -q '^old_primary_stale_io_success_count=0$' \"$S\"; test -s \"$P\"; grep -q '^stale_primary_probe=direct_read$' \"$P\"; grep -q '^old_primary_stale_io_success_count=0$' \"$P\"; test -s \"$B\"; test -s \"$A\"; grep -q '^rtpg_before_old_primary_aas=0x00$' \"$S\"; grep -q '^rtpg_after_promoted_aas=0x00$' \"$S\"; grep -q '^rtpg_transition_verified=true$' \"$S\"; grep -q '^cross_interference_observed=false$' \"$S\"; done; grep -q '^non_target_workload_ok$' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/recovery/failover/untouched-volume-3.log"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/cleanup/helm-uninstall.txt || true; kubectl -n default delete pod -l sw-block-test=multi-volume-mounted-failover --ignore-not-found=true --force --grace-period=0 --wait=false; for i in 1 2 3; do kubectl -n default delete pvc sw-block-multi-mounted-pvc-$i --ignore-not-found=true --wait=false; done; kubectl delete storageclass sw-block-multi-mounted sw-block-dynamic --ignore-not-found=true --wait=false; kubectl -n default delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=false"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "for _ in $(seq 1 60); do if ! sudo -n iscsiadm -m session 2>/dev/null | grep -q io.seaweedfs; then break; fi; sudo -n iscsiadm -m session 2>/dev/null | awk '/io.seaweedfs/ {print $3, $4}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" --logout || true; done; sleep 2; done; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n multipath -F >/dev/null 2>&1 || true"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLEANUP_MULTIPATH_FLUSH: "1"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-interleaved-failover/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
@@ -0,0 +1,268 @@
|
||||
# Phase 27 D3: multi-volume RF=3 mounted transparent failover.
|
||||
#
|
||||
# Pass = three RF=3 PVCs are mounted by long-running writer pods on the same
|
||||
# kubelet, each target volume's current primary is stopped in turn, the same
|
||||
# writer pod UID verifies old data and writes new data through dm-multipath,
|
||||
# non-target mounted workloads keep working, and cleanup is clean.
|
||||
|
||||
name: helm-multi-volume-rf3-mounted-failover-chain
|
||||
timeout: 52m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase27-d3"
|
||||
sw_block_csi_image: "sw-block-csi:phase27-d3"
|
||||
volume_count: "3"
|
||||
replication_factor: "3"
|
||||
app_node: "m02"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s || true; kubectl -n default delete pod -l sw-block-test=multi-volume-mounted-failover --ignore-not-found=true --wait=true --timeout=180s; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-mounted-writer-$i --ignore-not-found=true --wait=true --timeout=180s; kubectl -n default delete pvc sw-block-multi-mounted-pvc-$i --ignore-not-found=true --wait=true --timeout=180s; done; kubectl delete storageclass sw-block-multi-mounted sw-block-dynamic --ignore-not-found=true --wait=true --timeout=180s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n multipath -F >/dev/null 2>&1 || true; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/preclean/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLEANUP_MULTIPATH_FLUSH: "1"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
|
||||
- name: preflight
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "cd {{ product_root }} && bash scripts/preflight-k8s-alpha.sh --local-k3s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/preflight.txt 2>&1"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/preflight.txt"
|
||||
pattern: "summary status=PASS"
|
||||
save_as: preflight_count
|
||||
- action: assert_greater
|
||||
actual: "{{ preflight_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: host_multipath_prereq
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "set -e; B=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover; { echo stage2_protocol=iscsi-alua; command -v iscsiadm >/dev/null && echo command_iscsiadm=present; command -v multipath >/dev/null && echo command_multipath=present; command -v sg_rtpg >/dev/null && echo command_sg_rtpg=present; sudo modprobe iscsi_tcp; sudo modprobe dm_multipath; sudo modprobe scsi_dh_alua; test -d /sys/module/iscsi_tcp && echo module_iscsi_tcp=loaded; test -d /sys/module/dm_multipath && echo module_dm_multipath=loaded; test -d /sys/module/scsi_dh_alua && echo module_scsi_dh_alua=loaded; sudo multipath -t > \"$B/multipath-prereq.config.txt\" 2>&1; echo multipath_prereq=pass; } > \"$B/multipath-prereq.txt\" 2>&1"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/multipath-prereq.txt"
|
||||
pattern: "multipath_prereq=pass"
|
||||
save_as: multipath_prereq_count
|
||||
- action: assert_greater
|
||||
actual: "{{ multipath_prereq_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} --replication-factor {{ replication_factor }} --ack-profile sync-quorum --stage2-multipath > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/generate.stdout.txt && python3 - <<'PY'\nfrom pathlib import Path\np=Path('/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/values.day1.yaml')\ns=p.read_text()\ns=s.replace('launcherReplicationAckFlag: false','launcherReplicationAckFlag: true')\np.write_text(s)\nPY"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/values.day1.yaml"
|
||||
pattern: "replicationFactor: 3"
|
||||
save_as: rf3_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ rf3_in_values }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/values.day1.yaml"
|
||||
pattern: "ackProfile: sync-quorum"
|
||||
save_as: sync_quorum_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ sync_quorum_in_values }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/values.day1.yaml"
|
||||
pattern: "enabled: true"
|
||||
save_as: stage2_enabled_count
|
||||
- action: assert_greater
|
||||
actual: "{{ stage2_enabled_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/values.day1.yaml"
|
||||
pattern: "launcherReplicationAckFlag: true"
|
||||
save_as: ack_flag_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ ack_flag_in_values }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm lint charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/values.day1.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/install/helm-lint.txt && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/values/values.day1.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/install/helm-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: multi_volume_mounted_failover
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 34m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-multi-volume-mounted-failover.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery"
|
||||
env.SW_BLOCK_MULTI_VOLUME_COUNT: "{{ volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_RF: "{{ replication_factor }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_APP_NODE: "{{ app_node }}"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^multi_volume_mounted_failover_status=ok$"
|
||||
save_as: mounted_failover_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ mounted_failover_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: mounted_failover_asserts
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^recovered_volume_count=3$"
|
||||
save_as: recovered_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ recovered_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^mounted_workload_checksum_passed_count=3$"
|
||||
save_as: mounted_workload_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ mounted_workload_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^pod_recreate_used=false$"
|
||||
save_as: no_pod_recreate
|
||||
- action: assert_greater
|
||||
actual: "{{ no_pod_recreate }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery/multi-volume-mounted-failover-summary.txt"
|
||||
pattern: "^cross_interference_observed=false$"
|
||||
save_as: no_cross_interference
|
||||
- action: assert_greater
|
||||
actual: "{{ no_cross_interference }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery/host/multipath.before.txt"
|
||||
pattern: "hwhandler='1 alua'"
|
||||
save_as: multipath_alua_count
|
||||
- action: assert_greater
|
||||
actual: "{{ multipath_alua_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery/host/sg-rtpg.before.txt"
|
||||
pattern: "asymmetric access state"
|
||||
save_as: rtpg_before_count
|
||||
- action: assert_greater
|
||||
actual: "{{ rtpg_before_count }}"
|
||||
threshold: "2"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 2m
|
||||
cmd: "for i in 1 2 3; do D=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/recovery/failover/volume-$i; S=$D/summary.txt; P=$D/stale-primary-probe.log; B=$D/rtpg-before-states.txt; A=$D/rtpg-after-states.txt; grep -q '^failover_status=promoted$' \"$S\"; grep -q '^target_recovered=true$' \"$S\"; grep -q '^pod_recreate_used=false$' \"$S\"; grep -q '^data_check_after_failover=mounted_workload_checksum_passed$' \"$S\"; grep -q '^post_failure_primary_count=1$' \"$S\"; grep -q '^stale_primary_probe=direct_read$' \"$S\"; grep -q '^old_primary_stale_io_success_count=0$' \"$S\"; test -s \"$P\"; grep -q '^stale_primary_probe=direct_read$' \"$P\"; grep -q '^old_primary_stale_io_success_count=0$' \"$P\"; test -s \"$B\"; test -s \"$A\"; grep -q '^rtpg_before_old_primary_aas=0x00$' \"$S\"; grep -q '^rtpg_after_promoted_aas=0x00$' \"$S\"; grep -q '^rtpg_transition_verified=true$' \"$S\"; grep -q '^cross_interference_observed=false$' \"$S\"; done"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/cleanup/helm-uninstall.txt || true; kubectl -n default delete pod -l sw-block-test=multi-volume-mounted-failover --ignore-not-found=true --force --grace-period=0 --wait=false; for i in 1 2 3; do kubectl -n default delete pvc sw-block-multi-mounted-pvc-$i --ignore-not-found=true --wait=false; done; kubectl delete storageclass sw-block-multi-mounted sw-block-dynamic --ignore-not-found=true --wait=false; kubectl -n default delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=false"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "for _ in $(seq 1 60); do if ! sudo -n iscsiadm -m session 2>/dev/null | grep -q io.seaweedfs; then break; fi; sudo -n iscsiadm -m session 2>/dev/null | awk '/io.seaweedfs/ {print $3, $4}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" --logout || true; done; sleep 2; done; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n multipath -F >/dev/null 2>&1 || true"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLEANUP_MULTIPATH_FLUSH: "1"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-mounted-failover/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
@@ -0,0 +1,205 @@
|
||||
# Phase 27 D1 spike: multi-volume Day-1 at RF=3, no fault injection.
|
||||
#
|
||||
# Goal:
|
||||
# First signal on whether the v0.3.1 placement / port-assignment scheme can
|
||||
# actually host N concurrent RF=3 volumes (N=3 PVCs => 9 blockvolume pods
|
||||
# total, 3 per node on a 3-node lab). This is the lowest-bar readiness gate
|
||||
# for the multi-volume HA independence track; it does NOT inject faults.
|
||||
#
|
||||
# Pass = 3 PVCs bind, 3 writers verify, 3 readers verify, report shows
|
||||
# replication_factor=3 and three ManagedVolumes, cleanup is clean.
|
||||
# Fail = first signal that the port / placement scheme needs more work before
|
||||
# multi-volume HA gates can even be authored.
|
||||
|
||||
name: helm-multi-volume-rf3-readiness-chain
|
||||
timeout: 34m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase27-rf3"
|
||||
sw_block_csi_image: "sw-block-csi:phase27-rf3"
|
||||
volume_count: "3"
|
||||
replication_factor: "3"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s || true; kubectl -n default delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-writer-$i sw-block-multi-reader-$i --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-$i --ignore-not-found=true --wait=true --timeout=120s; done; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3 && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/build/alpha-images.env"
|
||||
pattern: "SW_BLOCK_IMAGE={{ sw_block_image }}"
|
||||
save_as: local_image_built_count
|
||||
- action: assert_greater
|
||||
actual: "{{ local_image_built_count }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} --replication-factor {{ replication_factor }} > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/values/generate.stdout.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/values/values.day1.yaml"
|
||||
pattern: "replicationFactor: 3"
|
||||
save_as: rf3_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ rf3_in_values }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm lint charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/values/values.day1.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/install/helm-lint.txt && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/values/values.day1.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/install/helm-install.txt && kubectl -n {{ helm_namespace }} get deploy,ds,pods,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/install/kube-system.after-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: multi_volume_user_loop
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 18m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-multi-volume-example.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume"
|
||||
env.SW_BLOCK_MULTI_VOLUME_COUNT: "{{ volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_RF: "{{ replication_factor }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_CLEANUP: "1"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^multi_volume_status=ok$"
|
||||
save_as: multi_volume_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ multi_volume_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: multi_volume_rf3_asserts
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^replication_factor=3$"
|
||||
save_as: rf3_in_summary
|
||||
- action: assert_greater
|
||||
actual: "{{ rf3_in_summary }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^writer_verified_count=3$"
|
||||
save_as: writer_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ writer_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^reader_verified_count=3$"
|
||||
save_as: reader_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ reader_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^managed_volume_count=3$"
|
||||
save_as: managed_volume_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ managed_volume_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume/status/report/summary.txt"
|
||||
pattern: "^volumes=3$"
|
||||
save_as: report_volume_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ report_volume_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/multi-volume/status/report/summary.txt"
|
||||
pattern: "rf=3"
|
||||
save_as: rf3_in_report
|
||||
- action: assert_greater
|
||||
actual: "{{ rf3_in_report }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "for i in $(seq 1 60); do out=$(kubectl -n default get deploy -l app=sw-blockvolume -o name 2>/dev/null); if [ -z \"$out\" ]; then exit 0; fi; sleep 2; done; echo \"timeout: launcher-rendered deployments still present\" >&2; kubectl -n default get deploy -l app=sw-blockvolume -o wide >&2; exit 1"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/cleanup/helm-uninstall.txt || true; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-writer-$i sw-block-multi-reader-$i --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-$i --ignore-not-found=true --wait=true --timeout=120s; done; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
@@ -0,0 +1,174 @@
|
||||
# Phase 27 D2: multi-volume RF=3 CSI reattach recovery.
|
||||
#
|
||||
# Pass = three RF=3 PVCs are ready, then each volume's current primary is
|
||||
# stopped in turn; only the target volume changes primary, a replacement
|
||||
# reader verifies persisted data through CSI/pod recreate, and cleanup is
|
||||
# clean.
|
||||
|
||||
name: helm-multi-volume-rf3-reattach-recovery-chain
|
||||
timeout: 48m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase27-d2"
|
||||
sw_block_csi_image: "sw-block-csi:phase27-d2"
|
||||
volume_count: "3"
|
||||
replication_factor: "3"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s || true; kubectl -n default delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pod -l sw-block-test=multi-volume-reattach --ignore-not-found=true --wait=true --timeout=120s; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-writer-$i sw-block-multi-reader-$i sw-block-multi-reattach-reader-$i --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-$i --ignore-not-found=true --wait=true --timeout=120s; done; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/recovery /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} --replication-factor {{ replication_factor }} --ack-profile sync-quorum > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/generate.stdout.txt && python3 - <<'PY'\nfrom pathlib import Path\np=Path('/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/values.day1.yaml')\ns=p.read_text()\ns=s.replace('launcherReplicationAckFlag: false','launcherReplicationAckFlag: true')\np.write_text(s)\nPY"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/values.day1.yaml"
|
||||
pattern: "replicationFactor: 3"
|
||||
save_as: rf3_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ rf3_in_values }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/values.day1.yaml"
|
||||
pattern: "ackProfile: sync-quorum"
|
||||
save_as: sync_quorum_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ sync_quorum_in_values }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/values.day1.yaml"
|
||||
pattern: "launcherReplicationAckFlag: true"
|
||||
save_as: ack_flag_in_values
|
||||
- action: assert_greater
|
||||
actual: "{{ ack_flag_in_values }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm lint charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/values.day1.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/install/helm-lint.txt && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/values/values.day1.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/install/helm-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: multi_volume_reattach_recovery
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 26m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-multi-volume-reattach-recovery.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/recovery"
|
||||
env.SW_BLOCK_MULTI_VOLUME_COUNT: "{{ volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_RF: "{{ replication_factor }}"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/recovery/multi-volume-reattach-summary.txt"
|
||||
pattern: "^multi_volume_reattach_status=ok$"
|
||||
save_as: recovery_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ recovery_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: recovery_asserts
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/recovery/multi-volume-reattach-summary.txt"
|
||||
pattern: "^recovered_volume_count=3$"
|
||||
save_as: recovered_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ recovered_count_ok }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/recovery/multi-volume-reattach-summary.txt"
|
||||
pattern: "^cross_interference_observed=false$"
|
||||
save_as: no_cross_interference
|
||||
- action: assert_greater
|
||||
actual: "{{ no_cross_interference }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 2m
|
||||
cmd: "for i in 1 2 3; do S=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/recovery/failover/volume-$i/summary.txt; grep -q '^failover_status=promoted$' \"$S\"; grep -q '^target_recovered=true$' \"$S\"; grep -q '^reader_verified=true$' \"$S\"; grep -q '^pod_recreate_used=true$' \"$S\"; grep -q '^post_failure_primary_count=1$' \"$S\"; grep -q '^cross_interference_observed=false$' \"$S\"; done"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/cleanup/helm-uninstall.txt || true; kubectl -n default delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pod -l sw-block-test=multi-volume-reattach --ignore-not-found=true --wait=true --timeout=120s; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-writer-$i sw-block-multi-reader-$i sw-block-multi-reattach-reader-$i --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-$i --ignore-not-found=true --wait=true --timeout=120s; done; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-reattach/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
@@ -0,0 +1,212 @@
|
||||
# Phase 31 D5: multi-volume RF3 restart smoke.
|
||||
#
|
||||
# Goal:
|
||||
# Prove a Helm-installed RF=3 sync-quorum stack with hostPath restart
|
||||
# persistence can restart k3s/product and keep three independent PVCs readable
|
||||
# without mixing per-volume authority or publish targets.
|
||||
#
|
||||
# Product boundary:
|
||||
# Three PVCs, RF=3, sync-quorum, no injected primary failure. This is restart
|
||||
# persistence smoke, not rebuild/failback or physical-host-loss recovery.
|
||||
|
||||
name: helm-multi-volume-rf3-restart-smoke-chain
|
||||
timeout: 42m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase31-d5"
|
||||
sw_block_csi_image: "sw-block-csi:phase31-d5"
|
||||
volume_count: "3"
|
||||
replication_factor: "3"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "sudo -n chmod 644 /etc/rancher/k3s/k3s.yaml || true; helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s || true; kubectl -n default delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-writer-$i sw-block-multi-reader-$i --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-$i --ignore-not-found=true --wait=true --timeout=120s; done; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n rm -rf /var/lib/sw-block/testops-{{ run_id }}-rf3-restart-smoke; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/multi-volume /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/after-restart /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/values.restart.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} --replication-factor {{ replication_factor }} --ack-profile sync-quorum --restart-persistence hostpath --state-hostpath /var/lib/sw-block/testops-{{ run_id }}-rf3-restart-smoke > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/generate.stdout.txt && python3 - <<'PY'\nfrom pathlib import Path\np=Path('/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/values.restart.yaml')\ns=p.read_text()\ns=s.replace('launcherReplicationAckFlag: false','launcherReplicationAckFlag: true')\np.write_text(s)\nPY"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/generate.stdout.txt"
|
||||
pattern: "^restart_persistence_mode=hostpath$"
|
||||
save_as: restart_mode_count
|
||||
- action: assert_greater
|
||||
actual: "{{ restart_mode_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/values.restart.yaml"
|
||||
pattern: "replicationFactor: 3"
|
||||
save_as: rf3_values_count
|
||||
- action: assert_greater
|
||||
actual: "{{ rf3_values_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/values.restart.yaml"
|
||||
pattern: "ackProfile: sync-quorum"
|
||||
save_as: sync_quorum_values_count
|
||||
- action: assert_greater
|
||||
actual: "{{ sync_quorum_values_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm lint charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/values.restart.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/install/helm-lint.txt && helm template {{ helm_release }} charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/values.restart.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/install/helm-template.yaml && grep -q -- '--launcher-state-hostpath=/var/lib/sw-block/testops-{{ run_id }}-rf3-restart-smoke' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/install/helm-template.yaml && grep -q -- '--launcher-replication-ack=sync-quorum' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/install/helm-template.yaml && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/values/values.restart.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/install/helm-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: multi_volume_before_restart
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 16m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-multi-volume-example.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/multi-volume"
|
||||
env.SW_BLOCK_MULTI_VOLUME_COUNT: "{{ volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_RF: "{{ replication_factor }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_CLEANUP: "0"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^writer_verified_count=3$"
|
||||
save_as: writer_before_count
|
||||
- action: assert_greater
|
||||
actual: "{{ writer_before_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/multi-volume/multi-volume-summary.txt"
|
||||
pattern: "^reader_verified_count=3$"
|
||||
save_as: reader_before_count
|
||||
- action: assert_greater
|
||||
actual: "{{ reader_before_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/multi-volume/status/cluster-evidence.json"
|
||||
pattern: "\"volumes\""
|
||||
save_as: cluster_before_count
|
||||
- action: assert_greater
|
||||
actual: "{{ cluster_before_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: restart_k3s_and_compare_volumes
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "set -e; cp /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/multi-volume/status/cluster-evidence.json /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/cluster-before-restart.json; date -u > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/restart-start.txt; sudo -n systemctl restart k3s; for i in $(seq 1 180); do if sudo -n k3s kubectl get nodes >/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/nodes.wait.txt 2>&1; then break; fi; sleep 2; done; sudo -n chmod 644 /etc/rancher/k3s/k3s.yaml; kubectl wait --for=condition=Ready node/m02 --timeout=300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/wait-node-ready.txt; kubectl -n {{ helm_namespace }} rollout status deploy/sw-blockmaster --timeout=300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/wait-blockmaster.txt; kubectl -n {{ helm_namespace }} rollout status deploy/sw-block-csi-controller --timeout=300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/wait-csi-controller.txt; kubectl -n {{ helm_namespace }} rollout status ds/sw-block-csi-node --timeout=300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/wait-csi-node.txt; for d in $(kubectl -n default get deploy -l app=sw-blockvolume -o name); do kubectl -n default rollout status \"$d\" --timeout=300s; done > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/wait-blockvolumes.txt; port=$(/usr/bin/python3 - <<'PY'\nimport socket\ns=socket.socket(); s.bind(('127.0.0.1',0)); print(s.getsockname()[1]); s.close()\nPY\n); kubectl -n {{ helm_namespace }} port-forward deploy/sw-blockmaster ${port}:9333 > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/blockmaster-port-forward.log 2>&1 & pf=$!; trap 'kill $pf >/dev/null 2>&1 || true; wait $pf >/dev/null 2>&1 || true' EXIT; for i in $(seq 1 60); do if (echo >/dev/tcp/127.0.0.1/$port) >/dev/null 2>&1; then break; fi; sleep 1; done; /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/bin/sw-block ops cluster --master-api 127.0.0.1:${port} --timeout 30s -o json > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/cluster-after-restart.json; /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/bin/sw-block ops report --master-api 127.0.0.1:${port} --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/report > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/report.stdout.txt; python3 - /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/cluster-before-restart.json /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/cluster-after-restart.json /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/multi-volume-restart-summary.txt <<'PY'\nimport json, sys\nbefore=json.load(open(sys.argv[1])); after=json.load(open(sys.argv[2])); out=sys.argv[3]\ndef by_id(doc):\n return {v.get('volume_id'): v for v in doc.get('volumes', []) if v.get('volume_id')}\nb=by_id(before); a=by_id(after)\nstatus='ok'; reasons=[]\nif len(b)!=3 or len(a)!=3:\n status='failed'; reasons.append(f'volume_count_before_{len(b)}_after_{len(a)}')\nfor vid, bv in b.items():\n av=a.get(vid)\n if not av:\n status='failed'; reasons.append(f'missing_{vid}'); continue\n for field in ('primary_replica','publish_target'):\n if bv.get(field) != av.get(field):\n status='failed'; reasons.append(f'{vid}_{field}_changed')\n be=int(bv.get('epoch') or bv.get('authority_epoch') or 0)\n ae=int(av.get('epoch') or av.get('authority_epoch') or 0)\n if ae < be:\n status='failed'; reasons.append(f'{vid}_epoch_rollback')\npublish=[v.get('publish_target') for v in a.values() if v.get('publish_target')]\nduplicate=len(publish)!=len(set(publish))\nif duplicate:\n status='failed'; reasons.append('duplicate_publish_target_for_distinct_volume')\nwith open(out,'w',encoding='utf-8') as f:\n f.write(f'multi_volume_restart_status={status}\\n')\n f.write(f'before_volume_count={len(b)}\\n')\n f.write(f'after_volume_count={len(a)}\\n')\n f.write('reader_verified_count=pending\\n')\n f.write(f'managed_volume_count={sum(1 for line in open(sys.argv[3].replace(\"multi-volume-restart-summary.txt\",\"report/summary.txt\"), encoding=\"utf-8\") if line.startswith(\"managed_volume=\"))}\\n')\n f.write(f'duplicate_publish_target_for_distinct_volume={str(duplicate).lower()}\\n')\n f.write(f'cross_volume_authority_mixup={\"true\" if status != \"ok\" else \"false\"}\\n')\n f.write(f'reason={\",\".join(reasons) if reasons else \"all_volumes_persisted\"}\\n')\nif status!='ok':\n raise SystemExit(','.join(reasons))\nPY"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/multi-volume-restart-summary.txt"
|
||||
pattern: "^multi_volume_restart_status=ok$"
|
||||
save_as: restart_status_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ restart_status_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/multi-volume-restart-summary.txt"
|
||||
pattern: "^managed_volume_count=3$"
|
||||
save_as: managed_volume_after_count
|
||||
- action: assert_greater
|
||||
actual: "{{ managed_volume_after_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: readers_after_restart
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 14m
|
||||
cmd: "set -e; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-reader-$i --ignore-not-found=true --wait=true --timeout=120s; kubectl apply -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/multi-volume/manifests/reader-$i.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/after-restart/apply-reader-$i.log; kubectl -n default wait --for=jsonpath='{.status.phase}'=Succeeded pod/sw-block-multi-reader-$i --timeout=240s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/after-restart/wait-reader-$i.log; kubectl -n default logs sw-block-multi-reader-$i > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/after-restart/reader-$i.log; grep -q '/data/demo.bin: OK' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/after-restart/reader-$i.log; done; count=$(grep -l '/data/demo.bin: OK' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/after-restart/reader-*.log | wc -l | tr -d ' '); echo \"reader_verified_count=$count\" >> /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/multi-volume-restart-summary.txt; test \"$count\" = \"3\""
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/restart/multi-volume-restart-summary.txt"
|
||||
pattern: "^reader_verified_count=3$"
|
||||
save_as: reader_count_ok
|
||||
- action: assert_greater
|
||||
actual: "{{ reader_count_ok }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 9m
|
||||
cmd: "mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/cleanup/diagnostics; for n in $(seq 1 90); do kubectl get nodes >/dev/null 2>&1 && break; sleep 2; done; kubectl -n {{ helm_namespace }} get pods,deploy,ds,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/cleanup/diagnostics/kube-system.before-cleanup.txt 2>&1 || true; helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/cleanup/helm-uninstall.txt || true; kubectl -n default delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=180s || true; for i in 1 2 3; do kubectl -n default delete pod sw-block-multi-writer-$i sw-block-multi-reader-$i sw-block-multi-reattach-reader-$i --ignore-not-found=true --wait=true --timeout=120s || true; kubectl -n default delete pvc sw-block-multi-pvc-$i --ignore-not-found=true --wait=true --timeout=120s || true; done; kubectl -n default delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=true --timeout=180s || true; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s || true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n rm -rf /var/lib/sw-block/testops-{{ run_id }}-rf3-restart-smoke; cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLEANUP_HOSTPATH_PREFIX: "testops-{{ run_id }}-rf3-restart-smoke"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: collect_path
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-multi-volume-rf3-restart"
|
||||
name: "remote-phases"
|
||||
ignore_error: true
|
||||
@@ -0,0 +1,112 @@
|
||||
# Runner-native Phase 26 D1 gate: Helm release hygiene.
|
||||
#
|
||||
# Goal:
|
||||
# Prove the chart is a repeatable release artifact before running heavier
|
||||
# lifecycle gates:
|
||||
# build sw-block CLI
|
||||
# -> generate Day-1 values from the live cluster
|
||||
# -> helm lint
|
||||
# -> helm template
|
||||
# -> helm package
|
||||
# -> assert rendered release-critical resources exist
|
||||
|
||||
name: helm-release-hygiene-chain
|
||||
timeout: 12m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "ghcr.io/seaweedfs/seaweed-block:sha-28a99ce4f644"
|
||||
sw_block_csi_image: "ghcr.io/seaweedfs/seaweed-block-csi:sha-28a99ce4f644"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
|
||||
- name: build_sw_block_cli
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/bin/sw-block --version > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/bin/sw-block.version.txt"
|
||||
|
||||
- name: generate_day1_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "helm version --short > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/values/helm-version.txt && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/values/generate.stdout.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_release_hygiene
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && bash scripts/verify-helm-release-hygiene.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene"
|
||||
env.SW_BLOCK_HELM_VALUES_FILE: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/values/values.day1.yaml"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
|
||||
- name: helm_release_hygiene_asserts
|
||||
actions:
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene/helm-release-hygiene-summary.txt"
|
||||
pattern: "^helm_hygiene_status=ok$"
|
||||
save_as: hygiene_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ hygiene_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene/helm-release-hygiene-summary.txt"
|
||||
pattern: "^rendered_storageclass_count=1$"
|
||||
save_as: rendered_sc_count
|
||||
- action: assert_greater
|
||||
actual: "{{ rendered_sc_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene/helm-release-hygiene-summary.txt"
|
||||
pattern: "^rendered_csidriver_count=1$"
|
||||
save_as: rendered_csidriver_count
|
||||
- action: assert_greater
|
||||
actual: "{{ rendered_csidriver_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene/helm-release-hygiene-summary.txt"
|
||||
pattern: "^rendered_master_count=1$"
|
||||
save_as: rendered_master_count
|
||||
- action: assert_greater
|
||||
actual: "{{ rendered_master_count }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 1m
|
||||
cmd: "ls /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene/*.tgz >/dev/null && test -s /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene/helm-template.yaml && test -s /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-release-hygiene/hygiene/helm-lint.txt"
|
||||
@@ -0,0 +1,296 @@
|
||||
# Phase 31 D4: RF3 promotion state survives Kubernetes restart.
|
||||
#
|
||||
# Goal:
|
||||
# Prove that after an RF=3 sync-quorum volume promotes a surviving replica,
|
||||
# a k3s/product restart does not resurrect the old primary or roll authority
|
||||
# back to the pre-promotion target.
|
||||
#
|
||||
# Product boundary:
|
||||
# One PVC, RF=3, sync-quorum, CSI/pod recreate recovery after failover, then
|
||||
# CSI/pod recreate after k3s restart. This is not backup/restore, returned
|
||||
# replica rebuild/failback, or physical host loss.
|
||||
|
||||
name: helm-rf3-promotion-restart-persistence-chain
|
||||
timeout: 44m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase31-d4"
|
||||
sw_block_csi_image: "sw-block-csi:phase31-d4"
|
||||
volume_count: "1"
|
||||
replication_factor: "3"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "sudo -n chmod 644 /etc/rancher/k3s/k3s.yaml || true; helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s || true; kubectl -n default delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pod -l sw-block-test=multi-volume-reattach --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pod sw-block-multi-writer-1 sw-block-multi-reader-1 sw-block-multi-reattach-reader-1 --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-1 --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete deploy -l app=sw-blockvolume --ignore-not-found=true --wait=true --timeout=180s; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n rm -rf /var/lib/sw-block/testops-{{ run_id }}-rf3-promotion-restart; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/recovery /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/restart /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/after-restart /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/cleanup; leftover=$(kubectl -n default get deploy -l app=sw-blockvolume -o name 2>/dev/null || true); if [ -n \"$leftover\" ]; then echo \"$leftover\" > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/pre-clean-blockvolume-leftover.txt; exit 3; fi"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/values.restart.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} --replication-factor {{ replication_factor }} --ack-profile sync-quorum --restart-persistence hostpath --state-hostpath /var/lib/sw-block/testops-{{ run_id }}-rf3-promotion-restart > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/generate.stdout.txt && python3 - <<'PY'\nfrom pathlib import Path\np=Path('/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/values.restart.yaml')\ns=p.read_text()\ns=s.replace('launcherReplicationAckFlag: false','launcherReplicationAckFlag: true')\np.write_text(s)\nPY"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/generate.stdout.txt"
|
||||
pattern: "^restart_persistence_mode=hostpath$"
|
||||
save_as: restart_mode_count
|
||||
- action: assert_greater
|
||||
actual: "{{ restart_mode_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/values.restart.yaml"
|
||||
pattern: "ackProfile: sync-quorum"
|
||||
save_as: sync_quorum_values_count
|
||||
- action: assert_greater
|
||||
actual: "{{ sync_quorum_values_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/values.restart.yaml"
|
||||
pattern: "launcherReplicationAckFlag: true"
|
||||
save_as: ack_flag_values_count
|
||||
- action: assert_greater
|
||||
actual: "{{ ack_flag_values_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm lint charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/values.restart.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/install/helm-lint.txt && helm template {{ helm_release }} charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/values.restart.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/install/helm-template.yaml && grep -q -- '--launcher-state-hostpath=/var/lib/sw-block/testops-{{ run_id }}-rf3-promotion-restart' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/install/helm-template.yaml && grep -q -- '--launcher-replication-ack=sync-quorum' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/install/helm-template.yaml && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/values/values.restart.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/install/helm-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: promote_and_reattach
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 22m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-multi-volume-reattach-recovery.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/recovery"
|
||||
env.SW_BLOCK_MULTI_VOLUME_COUNT: "{{ volume_count }}"
|
||||
env.SW_BLOCK_MULTI_VOLUME_RF: "{{ replication_factor }}"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/recovery/multi-volume-reattach-summary.txt"
|
||||
pattern: "^multi_volume_reattach_status=ok$"
|
||||
save_as: recovery_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ recovery_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/recovery/failover/volume-1/summary.txt"
|
||||
pattern: "^failover_status=promoted$"
|
||||
save_as: promoted_count
|
||||
- action: assert_greater
|
||||
actual: "{{ promoted_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: restart_k3s_and_verify_authority
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 9m
|
||||
cmd: |
|
||||
set -e
|
||||
out=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/restart
|
||||
date -u > "$out/restart-start.txt"
|
||||
sudo -n systemctl restart k3s
|
||||
for i in $(seq 1 180); do
|
||||
if sudo -n k3s kubectl get nodes > "$out/nodes.wait.txt" 2>&1; then break; fi
|
||||
sleep 2
|
||||
done
|
||||
sudo -n chmod 644 /etc/rancher/k3s/k3s.yaml
|
||||
kubectl wait --for=condition=Ready node/m02 --timeout=300s > "$out/wait-node-ready.txt"
|
||||
kubectl -n {{ helm_namespace }} rollout status deploy/sw-blockmaster --timeout=300s > "$out/wait-blockmaster.txt"
|
||||
kubectl -n {{ helm_namespace }} rollout status deploy/sw-block-csi-controller --timeout=300s > "$out/wait-csi-controller.txt"
|
||||
kubectl -n {{ helm_namespace }} rollout status ds/sw-block-csi-node --timeout=300s > "$out/wait-csi-node.txt"
|
||||
for d in $(kubectl -n default get deploy -l app=sw-blockvolume -o name); do
|
||||
kubectl -n default rollout status "$d" --timeout=300s
|
||||
done > "$out/wait-blockvolumes.txt"
|
||||
port=$(/usr/bin/python3 - <<'PY'
|
||||
import socket
|
||||
s=socket.socket(); s.bind(('127.0.0.1',0)); print(s.getsockname()[1]); s.close()
|
||||
PY
|
||||
)
|
||||
pf=''
|
||||
cluster_ready=false
|
||||
for attempt in $(seq 1 10); do
|
||||
pod=$(kubectl -n {{ helm_namespace }} get pods -l app.kubernetes.io/component=blockmaster --field-selector=status.phase=Running -o name 2>/dev/null | head -1 || true)
|
||||
if [ -z "$pod" ]; then
|
||||
pod=$(kubectl -n {{ helm_namespace }} get pods -o name 2>/dev/null | grep '/sw-blockmaster-' | head -1 || true)
|
||||
fi
|
||||
if [ -z "$pod" ]; then sleep 2; continue; fi
|
||||
echo "$pod" > "$out/blockmaster-port-forward-pod.txt"
|
||||
kubectl -n {{ helm_namespace }} wait --for=condition=Ready "$pod" --timeout=30s >> "$out/wait-blockmaster-pod.txt" 2>&1 || { sleep 2; continue; }
|
||||
kubectl -n {{ helm_namespace }} port-forward "$pod" "${port}:9333" > "$out/blockmaster-port-forward.log" 2>&1 &
|
||||
pf=$!
|
||||
sleep 2
|
||||
if /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/bin/sw-block ops cluster --master-api "127.0.0.1:${port}" --timeout 30s -o json > "$out/cluster-after-restart.json.tmp" 2> "$out/cluster-after-restart.stderr.txt"; then
|
||||
mv "$out/cluster-after-restart.json.tmp" "$out/cluster-after-restart.json"
|
||||
cluster_ready=true
|
||||
break
|
||||
fi
|
||||
kill "$pf" >/dev/null 2>&1 || true
|
||||
wait "$pf" >/dev/null 2>&1 || true
|
||||
sleep 2
|
||||
done
|
||||
test "$cluster_ready" = true
|
||||
trap 'kill "$pf" >/dev/null 2>&1 || true; wait "$pf" >/dev/null 2>&1 || true' EXIT
|
||||
python3 - /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/recovery/failover/volume-1/summary.txt /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/recovery/failover/volume-1/after.json "$out/cluster-after-restart.json" "$out/restart-promotion-summary.txt" <<'PY'
|
||||
import json, sys
|
||||
summary_path, before_json, after_json, out_path = sys.argv[1:]
|
||||
summary = {}
|
||||
for line in open(summary_path, encoding='utf-8'):
|
||||
if '=' in line:
|
||||
k, v = line.strip().split('=', 1)
|
||||
summary[k] = v
|
||||
volume_id = summary['volume_id']
|
||||
promoted = summary['promoted_replica']
|
||||
target = summary['after_publish_target']
|
||||
before = json.load(open(before_json))
|
||||
after = json.load(open(after_json))
|
||||
def find(doc):
|
||||
for v in doc.get('volumes', []):
|
||||
if v.get('volume_id') == volume_id:
|
||||
return v
|
||||
raise SystemExit('volume_not_found')
|
||||
b = find(before)
|
||||
a = find(after)
|
||||
before_epoch = int(b.get('epoch') or b.get('authority_epoch') or 0)
|
||||
after_epoch = int(a.get('epoch') or a.get('authority_epoch') or 0)
|
||||
primary_count = sum(1 for r in a.get('replicas', []) if r.get('role') == 'primary')
|
||||
status = 'ok'
|
||||
reasons = []
|
||||
if a.get('primary_replica') != promoted:
|
||||
status = 'failed'; reasons.append('primary_rolled_back')
|
||||
if a.get('publish_target') != target:
|
||||
status = 'failed'; reasons.append('publish_target_changed')
|
||||
if after_epoch < before_epoch:
|
||||
status = 'failed'; reasons.append('epoch_rolled_back')
|
||||
if primary_count != 1:
|
||||
status = 'failed'; reasons.append('primary_count_not_one')
|
||||
with open(out_path, 'w', encoding='utf-8') as f:
|
||||
f.write(f'restart_promotion_status={status}\n')
|
||||
f.write(f'volume_id={volume_id}\n')
|
||||
f.write(f'before_restart_primary={promoted}\n')
|
||||
f.write(f'after_restart_primary={a.get("primary_replica", "")}\n')
|
||||
f.write(f'before_restart_publish_target={target}\n')
|
||||
f.write(f'after_restart_publish_target={a.get("publish_target", "")}\n')
|
||||
f.write(f'before_restart_epoch={before_epoch}\n')
|
||||
f.write(f'after_restart_epoch={after_epoch}\n')
|
||||
f.write(f'post_restart_primary_count={primary_count}\n')
|
||||
f.write(f'reason={",".join(reasons) if reasons else "authority_persisted"}\n')
|
||||
if status != 'ok':
|
||||
raise SystemExit(','.join(reasons))
|
||||
PY
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/restart/restart-promotion-summary.txt"
|
||||
pattern: "^restart_promotion_status=ok$"
|
||||
save_as: restart_promotion_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ restart_promotion_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/restart/restart-promotion-summary.txt"
|
||||
pattern: "^reason=authority_persisted$"
|
||||
save_as: authority_persisted_count
|
||||
- action: assert_greater
|
||||
actual: "{{ authority_persisted_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: reader_after_restart
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "set -e; kubectl -n default delete pod sw-block-multi-reattach-reader-1 --ignore-not-found=true --wait=true --timeout=120s; kubectl apply -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/recovery/manifests/sw-block-multi-reattach-reader-1.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/after-restart/apply-reader-after-restart.log; kubectl -n default wait --for=jsonpath='{.status.phase}'=Succeeded pod/sw-block-multi-reattach-reader-1 --timeout=240s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/after-restart/wait-reader-after-restart.log; kubectl -n default logs sw-block-multi-reattach-reader-1 > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/after-restart/reader-after-restart.log; grep -q '/data/demo.bin: OK' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/after-restart/reader-after-restart.log"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/after-restart/reader-after-restart.log"
|
||||
pattern: "/data/demo.bin: OK"
|
||||
save_as: reader_after_restart_count
|
||||
- action: assert_greater
|
||||
actual: "{{ reader_after_restart_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 9m
|
||||
cmd: "mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/cleanup/diagnostics; kubectl -n {{ helm_namespace }} get pods,deploy,ds,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/cleanup/diagnostics/kube-system.before-cleanup.txt 2>&1 || true; helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/cleanup/helm-uninstall.txt || true; kubectl -n default delete pod -l sw-block-test=multi-volume --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pod -l sw-block-test=multi-volume-reattach --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pod sw-block-multi-writer-1 sw-block-multi-reader-1 sw-block-multi-reattach-reader-1 --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-multi-pvc-1 --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-multi sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n rm -rf /var/lib/sw-block/testops-{{ run_id }}-rf3-promotion-restart; cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLEANUP_HOSTPATH_PREFIX: "testops-{{ run_id }}-rf3-promotion-restart"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: collect_path
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-rf3-promotion-restart"
|
||||
name: "remote-phases"
|
||||
ignore_error: true
|
||||
@@ -0,0 +1,234 @@
|
||||
# Phase 31 D3: Helm single-node restart persistence gate.
|
||||
#
|
||||
# Goal:
|
||||
# Prove the smallest Kubernetes user path survives a k3s/product restart when
|
||||
# Helm is installed with explicit hostPath restart persistence.
|
||||
#
|
||||
# Product boundary:
|
||||
# RF=1 / single selected Kubernetes node / loopback iSCSI / pod recreate
|
||||
# after restart. This is not an HA, node-loss, or disaster-recovery claim.
|
||||
|
||||
name: helm-single-node-restart-persistence-chain
|
||||
timeout: 30m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
single_node: "m02"
|
||||
sw_block_image: "sw-block:local"
|
||||
sw_block_csi_image: "sw-block-csi:local"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s || true; kubectl -n default delete pod sw-block-example-reader sw-block-example-writer --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-example-pvc --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-example --ignore-not-found=true --wait=true --timeout=120s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n rm -rf /var/lib/sw-block/testops-{{ run_id }}-restart-persistence; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/basic-app /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
|
||||
- name: build_sw_block_cli
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/bin/sw-block --version > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/bin/sw-block.version.txt"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/bin/sw-block.version.txt"
|
||||
pattern: "sw-block"
|
||||
save_as: sw_block_version_count
|
||||
- action: assert_greater
|
||||
actual: "{{ sw_block_version_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: pin_build_alpha_images
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.SW_BLOCK_IMPORT_K3S: "1"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/pin_build"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/pin_build/alpha-images.env"
|
||||
pattern: "SW_BLOCK_IMAGE_ID="
|
||||
save_as: pin_image_id_count
|
||||
- action: assert_greater
|
||||
actual: "{{ pin_image_id_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: generate_restart_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 3m
|
||||
cmd: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/values.restart.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} --target-node {{ single_node }} --node-limit 1 --restart-persistence hostpath --state-hostpath /var/lib/sw-block/testops-{{ run_id }}-restart-persistence > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/generate.stdout.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/generate.stdout.txt"
|
||||
pattern: "^restart_persistence_mode=hostpath$"
|
||||
save_as: restart_mode_count
|
||||
- action: assert_greater
|
||||
actual: "{{ restart_mode_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/generate.stdout.txt"
|
||||
pattern: "^state_hostpath=/var/lib/sw-block/testops-{{ run_id }}-restart-persistence$"
|
||||
save_as: state_hostpath_stdout_count
|
||||
- action: assert_greater
|
||||
actual: "{{ state_hostpath_stdout_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/values.restart.yaml"
|
||||
pattern: "stateHostPath: /var/lib/sw-block/testops-{{ run_id }}-restart-persistence"
|
||||
save_as: state_hostpath_values_count
|
||||
- action: assert_greater
|
||||
actual: "{{ state_hostpath_values_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm lint charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/values.restart.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/install/helm-lint.txt && helm template {{ helm_release }} charts/seaweed-block -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/values.restart.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/install/helm-template.yaml && grep -q -- '--launcher-state-hostpath=/var/lib/sw-block/testops-{{ run_id }}-restart-persistence' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/install/helm-template.yaml && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/values.restart.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/install/helm-install.txt && kubectl -n {{ helm_namespace }} rollout status deploy/sw-blockmaster --timeout=180s && kubectl -n {{ helm_namespace }} rollout status deploy/sw-block-csi-controller --timeout=180s && kubectl -n {{ helm_namespace }} rollout status ds/sw-block-csi-node --timeout=180s && kubectl -n {{ helm_namespace }} get deploy,ds,pods,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/install/kube-system.after-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: first_volume_before_restart
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-basic-app-example.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/basic-app"
|
||||
env.SW_BLOCK_BASIC_APP_CLEANUP: "0"
|
||||
env.SW_BLOCK_BASIC_APP_NODE_SELECTOR: "{{ single_node }}"
|
||||
env.SW_BLOCK_INSTALL_MODE: "helm-single-node-restart-persistence"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_HELM_VALUES_FILE: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/values/values.restart.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/basic-app/first-volume-summary.txt"
|
||||
pattern: "^first_volume_status=ok$"
|
||||
save_as: first_volume_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ first_volume_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/basic-app/reader.log"
|
||||
pattern: "/data/demo.bin: OK"
|
||||
save_as: reader_before_restart_count
|
||||
- action: assert_greater
|
||||
actual: "{{ reader_before_restart_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: restart_k3s_and_verify
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "set -e; date -u > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/restart-start.txt; sudo -n systemctl restart k3s; for i in $(seq 1 180); do if sudo -n k3s kubectl get nodes >/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/nodes.wait.txt 2>&1; then break; fi; sleep 2; done; sudo -n chmod 644 /etc/rancher/k3s/k3s.yaml; kubectl wait --for=condition=Ready node/{{ single_node }} --timeout=300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/wait-node-ready.txt; kubectl -n {{ helm_namespace }} rollout status deploy/sw-blockmaster --timeout=300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/wait-blockmaster.txt; kubectl -n {{ helm_namespace }} rollout status deploy/sw-block-csi-controller --timeout=300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/wait-csi-controller.txt; kubectl -n {{ helm_namespace }} rollout status ds/sw-block-csi-node --timeout=300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/wait-csi-node.txt; for d in $(kubectl -n default get deploy -l app=sw-blockvolume -o name); do kubectl -n default rollout status \"$d\" --timeout=300s; done > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/wait-blockvolumes.txt; kubectl -n {{ helm_namespace }} get pods,deploy,ds,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/kube-system.after-restart.txt; kubectl -n default get pods,pvc,pv,deploy -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/default.after-restart.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/restart/wait-blockmaster.txt"
|
||||
pattern: "successfully rolled out"
|
||||
save_as: blockmaster_restart_ready_count
|
||||
- action: assert_greater
|
||||
actual: "{{ blockmaster_restart_ready_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: reader_after_restart
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "set -e; kubectl -n default delete pod sw-block-example-reader --ignore-not-found=true --wait=true --timeout=120s; kubectl apply -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/basic-app/reader-pod.rendered.yaml > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/apply-reader-after-restart.log; kubectl -n default wait --for=jsonpath='{.status.phase}'=Succeeded pod/sw-block-example-reader --timeout=240s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/wait-reader-after-restart.log; kubectl -n default logs sw-block-example-reader > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/reader-after-restart.log; grep -q '/data/demo.bin: OK' /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/reader-after-restart.log; port=$(/usr/bin/python3 - <<'PY'\nimport socket\ns=socket.socket(); s.bind(('127.0.0.1',0)); print(s.getsockname()[1]); s.close()\nPY\n); kubectl -n {{ helm_namespace }} port-forward deploy/sw-blockmaster ${port}:9333 > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/blockmaster-port-forward.log 2>&1 & pf=$!; trap 'kill $pf >/dev/null 2>&1 || true; wait $pf >/dev/null 2>&1 || true' EXIT; for i in $(seq 1 60); do if (echo >/dev/tcp/127.0.0.1/$port) >/dev/null 2>&1; then break; fi; sleep 1; done; /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/bin/sw-block ops cluster --master-api 127.0.0.1:${port} --timeout 30s -o json > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/cluster-after-restart.json; /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/bin/sw-block ops report --master-api 127.0.0.1:${port} --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/report > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/report.stdout.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/reader-after-restart.log"
|
||||
pattern: "/data/demo.bin: OK"
|
||||
save_as: reader_after_restart_count
|
||||
- action: assert_greater
|
||||
actual: "{{ reader_after_restart_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/after-restart/report/summary.txt"
|
||||
pattern: "managed_volume=.*status=ready"
|
||||
save_as: managed_volume_ready_count
|
||||
- action: assert_greater
|
||||
actual: "{{ managed_volume_ready_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/cleanup/diagnostics; kubectl -n {{ helm_namespace }} get pods,deploy,ds,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/cleanup/diagnostics/kube-system.before-cleanup.txt 2>&1 || true; kubectl -n {{ helm_namespace }} logs deploy/sw-blockmaster --all-containers=true --tail=200 > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/cleanup/diagnostics/blockmaster.before-cleanup.log 2>&1 || true; kubectl -n {{ helm_namespace }} get events --sort-by=.lastTimestamp > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/cleanup/diagnostics/events.before-cleanup.txt 2>&1 || true; helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 300s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/cleanup/helm-uninstall.txt || true; kubectl -n default delete pod sw-block-example-reader sw-block-example-writer --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-example-pvc --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-example --ignore-not-found=true --wait=true --timeout=120s; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; sudo -n rm -rf /var/lib/sw-block/testops-{{ run_id }}-restart-persistence; cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLEANUP_HOSTPATH_PREFIX: "testops-{{ run_id }}-restart-persistence"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: exec
|
||||
node: m02
|
||||
cmd: "test ! -e /var/lib/sw-block/testops-{{ run_id }}-restart-persistence"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: collect_path
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-single-node-restart"
|
||||
name: "remote-phases"
|
||||
ignore_error: true
|
||||
@@ -0,0 +1,221 @@
|
||||
# Runner-native Phase 26 D4 gate: Helm support bundle diagnostics.
|
||||
#
|
||||
# Goal:
|
||||
# Prove a Helm-installed first-volume run produces a cold, read-only support
|
||||
# bundle that can be consumed later by sw-block ops report/explain/timeline.
|
||||
# Also prove a blocked ImagePullBackOff bundle explains itself without a live
|
||||
# cluster.
|
||||
|
||||
name: helm-support-bundle-diagnostics-chain
|
||||
timeout: 30m
|
||||
|
||||
env:
|
||||
product_root: "/tmp/seaweed_block"
|
||||
ssh_key: "C:\\work\\dev_server\\testdev_key"
|
||||
helm_release: "sw-block"
|
||||
helm_namespace: "kube-system"
|
||||
sw_block_image: "sw-block:phase26-d4"
|
||||
sw_block_csi_image: "sw-block-csi:phase26-d4"
|
||||
|
||||
topology:
|
||||
nodes:
|
||||
m02:
|
||||
host: 192.168.1.184
|
||||
user: testdev
|
||||
key: "{{ ssh_key }}"
|
||||
|
||||
phases:
|
||||
- name: pre_clean
|
||||
actions:
|
||||
- action: pre_run_cleanup
|
||||
node: m02
|
||||
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
|
||||
nvme_disconnect: "true"
|
||||
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 180s || true; kubectl -n default delete pod sw-block-example-reader sw-block-example-writer --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-example-pvc --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-example sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; kubectl delete clusterrole/sw-block-csi clusterrolebinding/sw-block-csi --ignore-not-found=true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/bin /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/values /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/install /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/blocked-bundle/demo /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/cleanup"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
|
||||
- name: build_and_generate_values
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "cd {{ product_root }} && SW_BLOCK_IMAGE={{ sw_block_image }} SW_BLOCK_CSI_IMAGE={{ sw_block_csi_image }} SW_BLOCK_IMPORT_K3S=1 SW_BLOCK_IMPORT_K3S_NODES='192.168.1.181,192.168.1.188' SW_BLOCK_IMPORT_K3S_SSH_USER=testdev SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/build bash scripts/build-alpha-images.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/build/alpha-images.env"
|
||||
pattern: "SW_BLOCK_IMAGE={{ sw_block_image }}"
|
||||
save_as: local_image_built_count
|
||||
- action: assert_greater
|
||||
actual: "{{ local_image_built_count }}"
|
||||
threshold: "0"
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 6m
|
||||
cmd: "cd {{ product_root }} && go build -o /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/bin/sw-block ./cmd/sw-block && /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/bin/sw-block ops generate-helm-values --kubeconfig /etc/rancher/k3s/k3s.yaml --out /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/values/values.day1.yaml --image {{ sw_block_image }} --csi-image {{ sw_block_csi_image }} > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/values/generate.stdout.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/values/generate.stdout.txt"
|
||||
pattern: "helm_values_status=ok"
|
||||
save_as: generator_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ generator_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_install_stack
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && helm install {{ helm_release }} charts/seaweed-block --namespace {{ helm_namespace }} --create-namespace -f /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/values/values.day1.yaml --wait --timeout 10m > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/install/helm-install.txt && kubectl -n {{ helm_namespace }} get deploy,ds,pods,svc -o wide > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/install/kube-system.after-install.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/install/helm-install.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_deployed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_deployed_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: first_volume_kept_for_bundle
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 10m
|
||||
cmd: "cd {{ product_root }} && bash scripts/run-basic-app-example.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app"
|
||||
env.SW_BLOCK_BASIC_APP_CLEANUP: "0"
|
||||
env.SW_BLOCK_INSTALL_MODE: "helm"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_HELM_VALUES_FILE: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/values/values.day1.yaml"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app/first-volume-summary.txt"
|
||||
pattern: "^first_volume_status=ok$"
|
||||
save_as: first_volume_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ first_volume_ok_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: collect_support_bundle
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 5m
|
||||
cmd: "cd {{ product_root }} && bash scripts/collect-helm-support-bundle.sh {{ product_root }}"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_SUPPORT_BUNDLE_SOURCE: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app"
|
||||
env.SW_BLOCK_SUPPORT_BUNDLE_OUT: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app/support-bundle"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
env.SW_BLOCK_CLI: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/bin/sw-block"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app/support-bundle/support-bundle-summary.txt"
|
||||
pattern: "^support_bundle_status=ok$"
|
||||
save_as: support_bundle_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ support_bundle_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app/support-bundle/support-bundle-summary.txt"
|
||||
pattern: "^read_only=true$"
|
||||
save_as: support_bundle_readonly_count
|
||||
- action: assert_greater
|
||||
actual: "{{ support_bundle_readonly_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app/support-bundle/replayed-report/summary.txt"
|
||||
pattern: "^status=ok$"
|
||||
save_as: replayed_report_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ replayed_report_ok_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app/support-bundle/explain.txt"
|
||||
pattern: "managed_volume "
|
||||
save_as: explain_managed_count
|
||||
- action: assert_greater
|
||||
actual: "{{ explain_managed_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app/support-bundle/helm/status.txt"
|
||||
pattern: "STATUS: deployed"
|
||||
save_as: helm_status_bundle_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_status_bundle_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/basic-app/support-bundle/k8s/pods.txt"
|
||||
pattern: "sw-block"
|
||||
save_as: k8s_pods_bundle_count
|
||||
- action: assert_greater
|
||||
actual: "{{ k8s_pods_bundle_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: blocked_bundle_asserts
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 2m
|
||||
cmd: "cat > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/blocked-bundle/demo/kube-system-pods-deploys.txt <<'EOF'\nNAME READY STATUS RESTARTS AGE IP NODE\npod/sw-block-csi-node-n948t 0/2 ImagePullBackOff 0 2m3s 192.168.1.184 m02\ndeployment.apps/sw-block-csi-controller 1/1 1 1 2m3s block-csi sw-block-csi:local\nEOF\n/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/bin/sw-block ops explain volume --from-bundle /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/blocked-bundle pvc-blocked > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/blocked-bundle/explain.txt"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/blocked-bundle/explain.txt"
|
||||
pattern: "reason=csi_node_image_pull_failed"
|
||||
save_as: blocked_reason_count
|
||||
- action: assert_greater
|
||||
actual: "{{ blocked_reason_count }}"
|
||||
threshold: "0"
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/blocked-bundle/explain.txt"
|
||||
pattern: "ImagePullBackOff"
|
||||
save_as: blocked_image_pull_count
|
||||
- action: assert_greater
|
||||
actual: "{{ blocked_image_pull_count }}"
|
||||
threshold: "0"
|
||||
|
||||
- name: helm_uninstall_cleanup
|
||||
always: true
|
||||
actions:
|
||||
- action: exec
|
||||
node: m02
|
||||
timeout: 8m
|
||||
cmd: "kubectl -n default delete pod sw-block-example-reader sw-block-example-writer --ignore-not-found=true --wait=true --timeout=120s; kubectl -n default delete pvc sw-block-example-pvc --ignore-not-found=true --wait=true --timeout=120s; kubectl delete storageclass sw-block-example sw-block-dynamic --ignore-not-found=true --wait=true --timeout=120s; helm status {{ helm_release }} --namespace {{ helm_namespace }} >/dev/null 2>&1 && helm uninstall {{ helm_release }} --namespace {{ helm_namespace }} --wait --timeout 240s > /mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/cleanup/helm-uninstall.txt || true; sudo -n iscsiadm -m node 2>/dev/null | awk '/io.seaweedfs/ {print $1, $2}' | while read portal target; do sudo -n iscsiadm -m node -T \"$target\" -p \"$portal\" -o delete || true; done; cd {{ product_root }} && bash scripts/verify-helm-cleanup.sh"
|
||||
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
|
||||
env.SW_BLOCK_ARTIFACT_DIR: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/cleanup/verify"
|
||||
env.SW_BLOCK_HELM_RELEASE: "{{ helm_release }}"
|
||||
env.SW_BLOCK_HELM_NAMESPACE: "{{ helm_namespace }}"
|
||||
- action: assert_no_active_iscsi_sessions
|
||||
node: m02
|
||||
iqn_substr: "io.seaweedfs"
|
||||
- action: assert_no_processes
|
||||
node: m02
|
||||
pattern: "[/]blockmaster --|[/]blockvolume --|[/]blockcsi |[/]iscsi-target |^blockmaster |^blockvolume |^blockcsi |^iscsi-target "
|
||||
- action: grep_log
|
||||
node: m02
|
||||
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-helm-support-bundle/cleanup/verify/cleanup-summary.txt"
|
||||
pattern: "^cleanup_status=ok$"
|
||||
save_as: helm_cleanup_ok_count
|
||||
- action: assert_greater
|
||||
actual: "{{ helm_cleanup_ok_count }}"
|
||||
threshold: "0"
|
||||
Reference in new issue
Block a user