mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
phase35: add crd status writer
This commit is contained in:
1 parent
9a15a67842
commit
010fe95038
8 files changed
+380
-39
No files matched your search
@@ -1,6 +1,3 @@
|
||||
{{- if and .Values.operatorStatus.create (not .Values.operatorStatus.dryRun) -}}
|
||||
{{- fail "operatorStatus.create=true currently requires operatorStatus.dryRun=true; real CRD status writes are not wired yet" -}}
|
||||
{{- end -}}
|
||||
{{- if .Values.operatorStatus.create }}
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -34,7 +31,9 @@ spec:
|
||||
args:
|
||||
- "ops"
|
||||
- "operator-status"
|
||||
{{- if .Values.operatorStatus.dryRun }}
|
||||
- "--dry-run"
|
||||
{{- end }}
|
||||
- "--master-api={{ include "seaweed-block.blockmasterAddress" . }}"
|
||||
- "--namespace={{ .Release.Namespace }}"
|
||||
- "--cluster-name={{ .Values.operatorStatus.clusterName }}"
|
||||
|
||||
@@ -115,8 +115,9 @@ rbac:
|
||||
|
||||
operatorStatus:
|
||||
# Phase 35 read-only operator foundation. When enabled, this installs the
|
||||
# status service account/RBAC plus a dry-run status projection Deployment.
|
||||
# Real CRD status writes are intentionally not wired yet.
|
||||
# status service account/RBAC plus a status projection Deployment. dryRun
|
||||
# logs the projection only. dryRun=false patches existing SwBlockCluster /
|
||||
# SwBlockVolume .status subresources and does not create CR objects.
|
||||
create: false
|
||||
dryRun: true
|
||||
interval: 30s
|
||||
|
||||
@@ -31,6 +31,9 @@ var (
|
||||
opsStatusRunCommand = ops.DefaultRunCommand
|
||||
opsInventoryRunCommand = ops.DefaultRunCommand
|
||||
opsGenerateHelmValuesRunCommand = ops.DefaultRunCommand
|
||||
opsOperatorStatusWriterFactory = func() (ops.OperatorStatusWriter, error) {
|
||||
return ops.NewInClusterKubernetesStatusClient()
|
||||
}
|
||||
)
|
||||
|
||||
func run(args []string, stdout, stderr io.Writer) int {
|
||||
@@ -116,11 +119,6 @@ func runOpsOperatorStatus(args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stderr, "sw-block ops operator-status: unexpected args %s\n", strings.Join(fs.Args(), " "))
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
if !dryRun {
|
||||
fmt.Fprintln(stderr, "sw-block ops operator-status: real Kubernetes status writes are not wired yet; rerun with --dry-run")
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
|
||||
runOnce := func() int {
|
||||
clusterArgs := []string{"--namespace", namespace, "--timeout", timeout.String()}
|
||||
if fromBundle != "" {
|
||||
@@ -145,8 +143,21 @@ func runOpsOperatorStatus(args []string, stdout, stderr io.Writer) int {
|
||||
if code != ops.VolumeStatusExitOK {
|
||||
return code
|
||||
}
|
||||
writer := &operatorStatusDryRunWriter{}
|
||||
events := &operatorStatusDryRunEventSink{}
|
||||
mode := "write_status"
|
||||
var writer ops.OperatorStatusWriter
|
||||
var events ops.OperatorEventSink
|
||||
if dryRun {
|
||||
mode = "dry_run"
|
||||
writer = &operatorStatusDryRunWriter{}
|
||||
events = &operatorStatusDryRunEventSink{}
|
||||
} else {
|
||||
var err error
|
||||
writer, err = opsOperatorStatusWriterFactory()
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "sw-block ops operator-status: %v\n", err)
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
}
|
||||
result, err := (ops.OperatorStatusReconciler{
|
||||
Namespace: namespace,
|
||||
ClusterName: clusterName,
|
||||
@@ -158,23 +169,26 @@ func runOpsOperatorStatus(args []string, stdout, stderr io.Writer) int {
|
||||
fmt.Fprintf(stderr, "sw-block ops operator-status: %v\n", err)
|
||||
return ops.VolumeStatusExitInvalid
|
||||
}
|
||||
fmt.Fprintf(stdout, "operator_status=dry_run cluster=%s/%s volumes=%d events=%d mutation_allowed=false\n",
|
||||
fmt.Fprintf(stdout, "operator_status=%s cluster=%s/%s volumes=%d events=%d mutation_allowed=false\n",
|
||||
mode,
|
||||
result.ClusterRef.Namespace,
|
||||
result.ClusterRef.Name,
|
||||
len(result.VolumeRefs),
|
||||
result.EventCount)
|
||||
fmt.Fprintf(stdout, "cluster_status volumes=%d ready=%d blocked=%d stale=%d\n",
|
||||
writer.cluster.VolumeCount,
|
||||
writer.cluster.ReadyVolumeCount,
|
||||
writer.cluster.BlockedVolumeCount,
|
||||
writer.cluster.StaleVolumeCount)
|
||||
for _, volume := range writer.volumes {
|
||||
fmt.Fprintf(stdout, "volume_status name=%s volume_id=%s pvc=%s status=%s reason=%s\n",
|
||||
volume.ref.Name,
|
||||
emptyCLI(volume.status.VolumeID),
|
||||
emptyCLI(volume.status.PVCName),
|
||||
emptyCLI(volume.status.Status),
|
||||
emptyCLI(volume.status.ReasonCode))
|
||||
if dryWriter, ok := writer.(*operatorStatusDryRunWriter); ok {
|
||||
fmt.Fprintf(stdout, "cluster_status volumes=%d ready=%d blocked=%d stale=%d\n",
|
||||
dryWriter.cluster.VolumeCount,
|
||||
dryWriter.cluster.ReadyVolumeCount,
|
||||
dryWriter.cluster.BlockedVolumeCount,
|
||||
dryWriter.cluster.StaleVolumeCount)
|
||||
for _, volume := range dryWriter.volumes {
|
||||
fmt.Fprintf(stdout, "volume_status name=%s volume_id=%s pvc=%s status=%s reason=%s\n",
|
||||
volume.ref.Name,
|
||||
emptyCLI(volume.status.VolumeID),
|
||||
emptyCLI(volume.status.PVCName),
|
||||
emptyCLI(volume.status.Status),
|
||||
emptyCLI(volume.status.ReasonCode))
|
||||
}
|
||||
}
|
||||
return ops.VolumeStatusExitOK
|
||||
}
|
||||
|
||||
@@ -283,15 +283,88 @@ func TestOpsOperatorStatusDryRunFromBundle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpsOperatorStatusRequiresDryRunUntilWriterIsWired(t *testing.T) {
|
||||
func TestOpsOperatorStatusWritesCRDStatusWhenDryRunDisabled(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
cluster := ops.NewClusterEvidence(time.Date(2026, 6, 3, 10, 30, 0, 0, time.UTC))
|
||||
cluster.ManagedVolumes = []ops.ManagedVolumeProjection{ops.ProjectManagedVolume(ops.ManagedVolumeFacts{
|
||||
VolumeID: "pvc-write",
|
||||
PVCName: "write-pvc",
|
||||
PVC: &ops.PVCFact{Phase: "Bound"},
|
||||
Authority: &ops.AuthorityFact{
|
||||
PrimaryReplica: "r1",
|
||||
PublishTarget: "192.168.1.184:3260",
|
||||
},
|
||||
Replicas: []ops.ReplicaFact{{
|
||||
ReplicaID: "r1",
|
||||
KubernetesNode: "m02",
|
||||
Role: "primary",
|
||||
Observed: true,
|
||||
}},
|
||||
CSIStages: []ops.CSIStageFact{{NodeName: "m02", Target: "192.168.1.184:3260"}},
|
||||
Workload: &ops.WorkloadCheckFact{WriterVerified: true, ReaderVerified: true},
|
||||
})}
|
||||
raw, err := ops.MarshalObservationJSON(cluster)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, ops.ClusterEvidenceArtifact), raw, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
writer := &operatorStatusTestWriter{}
|
||||
oldFactory := opsOperatorStatusWriterFactory
|
||||
opsOperatorStatusWriterFactory = func() (ops.OperatorStatusWriter, error) {
|
||||
return writer, nil
|
||||
}
|
||||
t.Cleanup(func() { opsOperatorStatusWriterFactory = oldFactory })
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
code := run([]string{"ops", "operator-status", "--from-bundle", t.TempDir()}, &stdout, &stderr)
|
||||
if code != ops.VolumeStatusExitInvalid {
|
||||
t.Fatalf("exit=%d want invalid stdout=%s stderr=%s", code, stdout.String(), stderr.String())
|
||||
if code == ops.VolumeStatusExitOK {
|
||||
t.Fatalf("empty bundle unexpectedly succeeded stdout=%s stderr=%s", stdout.String(), stderr.String())
|
||||
}
|
||||
if !strings.Contains(stderr.String(), "rerun with --dry-run") {
|
||||
t.Fatalf("stderr=%s", stderr.String())
|
||||
|
||||
stdout.Reset()
|
||||
stderr.Reset()
|
||||
code = run([]string{"ops", "operator-status", "--from-bundle", dir, "--namespace", "kube-system"}, &stdout, &stderr)
|
||||
if code != ops.VolumeStatusExitOK {
|
||||
t.Fatalf("exit=%d stderr=%s stdout=%s", code, stderr.String(), stdout.String())
|
||||
}
|
||||
if writer.cluster.VolumeCount != 1 || len(writer.volumes) != 1 {
|
||||
t.Fatalf("writer cluster=%+v volumes=%+v", writer.cluster, writer.volumes)
|
||||
}
|
||||
if writer.volumes[0].ref.Name != "write-pvc" || writer.volumes[0].status.Status != ops.ManagedVolumeStatusReady {
|
||||
t.Fatalf("volume write=%+v", writer.volumes[0])
|
||||
}
|
||||
out := stdout.String()
|
||||
for _, want := range []string{
|
||||
"operator_status=write_status cluster=kube-system/sw-block volumes=1",
|
||||
"mutation_allowed=false",
|
||||
} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Fatalf("stdout missing %q:\n%s", want, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type operatorStatusTestWriter struct {
|
||||
cluster ops.SwBlockClusterCRDStatus
|
||||
volumes []operatorStatusTestVolumeWrite
|
||||
}
|
||||
|
||||
type operatorStatusTestVolumeWrite struct {
|
||||
ref ops.OperatorObjectRef
|
||||
status ops.SwBlockVolumeCRDStatus
|
||||
}
|
||||
|
||||
func (w *operatorStatusTestWriter) WriteClusterStatus(_ context.Context, _ ops.OperatorObjectRef, status ops.SwBlockClusterCRDStatus) error {
|
||||
w.cluster = status
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *operatorStatusTestWriter) WriteVolumeStatus(_ context.Context, ref ops.OperatorObjectRef, status ops.SwBlockVolumeCRDStatus) error {
|
||||
w.volumes = append(w.volumes, operatorStatusTestVolumeWrite{ref: ref, status: status})
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestOpsInventoryRejectsBadRequiredFrontierFlag(t *testing.T) {
|
||||
|
||||
@@ -154,15 +154,15 @@ func TestPhase35D1OperatorStatusRBACDefaultDisabled(t *testing.T) {
|
||||
assertYAMLBool(t, rbac, "create", true)
|
||||
}
|
||||
|
||||
func TestPhase35D2OperatorStatusDeploymentIsDryRunGuarded(t *testing.T) {
|
||||
func TestPhase35D3OperatorStatusDeploymentCanRunDryRunOrStatusWriteMode(t *testing.T) {
|
||||
raw := readRepoFile(t, "charts/seaweed-block/templates/operator-status.yaml")
|
||||
for _, want := range []string{
|
||||
`operatorStatus.create=true currently requires operatorStatus.dryRun=true`,
|
||||
`kind: Deployment`,
|
||||
`name: sw-block-operator-status`,
|
||||
`serviceAccountName: {{ include "seaweed-block.fullname" . }}-operator-status`,
|
||||
`command: ["/usr/local/bin/sw-block"]`,
|
||||
`- "operator-status"`,
|
||||
`{{- if .Values.operatorStatus.dryRun }}`,
|
||||
`- "--dry-run"`,
|
||||
`- "--master-api={{ include "seaweed-block.blockmasterAddress" . }}"`,
|
||||
`- "--interval={{ .Values.operatorStatus.interval }}"`,
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
SwBlockClusterPlural = "swblockclusters"
|
||||
SwBlockVolumePlural = "swblockvolumes"
|
||||
|
||||
serviceAccountTokenPath = "/var/run/secrets/kubernetes.io/serviceaccount/token"
|
||||
serviceAccountCAPath = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
|
||||
)
|
||||
|
||||
// KubernetesStatusClient patches only CRD status subresources. It deliberately
|
||||
// has no methods for spec, workload, PVC/PV, Secret, StorageClass, or host mutation.
|
||||
type KubernetesStatusClient struct {
|
||||
BaseURL string
|
||||
BearerToken string
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
func NewInClusterKubernetesStatusClient() (*KubernetesStatusClient, error) {
|
||||
host := os.Getenv("KUBERNETES_SERVICE_HOST")
|
||||
port := os.Getenv("KUBERNETES_SERVICE_PORT")
|
||||
if host == "" || port == "" {
|
||||
return nil, fmt.Errorf("KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT are required for non-dry-run operator status")
|
||||
}
|
||||
token, err := os.ReadFile(serviceAccountTokenPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read service account token: %w", err)
|
||||
}
|
||||
ca, err := os.ReadFile(serviceAccountCAPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read service account CA: %w", err)
|
||||
}
|
||||
pool := x509.NewCertPool()
|
||||
if !pool.AppendCertsFromPEM(ca) {
|
||||
return nil, fmt.Errorf("service account CA bundle is empty or invalid")
|
||||
}
|
||||
transport := http.DefaultTransport.(*http.Transport).Clone()
|
||||
transport.TLSClientConfig = &tls.Config{RootCAs: pool}
|
||||
return &KubernetesStatusClient{
|
||||
BaseURL: "https://" + netJoinHostPort(host, port),
|
||||
BearerToken: strings.TrimSpace(string(token)),
|
||||
HTTPClient: &http.Client{Transport: transport, Timeout: 10 * time.Second},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *KubernetesStatusClient) WriteClusterStatus(ctx context.Context, ref OperatorObjectRef, status SwBlockClusterCRDStatus) error {
|
||||
return c.patchStatus(ctx, ref.Namespace, SwBlockClusterPlural, ref.Name, status)
|
||||
}
|
||||
|
||||
func (c *KubernetesStatusClient) WriteVolumeStatus(ctx context.Context, ref OperatorObjectRef, status SwBlockVolumeCRDStatus) error {
|
||||
return c.patchStatus(ctx, ref.Namespace, SwBlockVolumePlural, ref.Name, status)
|
||||
}
|
||||
|
||||
func (c *KubernetesStatusClient) patchStatus(ctx context.Context, namespace, resource, name string, status any) error {
|
||||
if namespace == "" || resource == "" || name == "" {
|
||||
return fmt.Errorf("namespace, resource, and name are required for status patch")
|
||||
}
|
||||
body, err := json.Marshal(map[string]any{"status": status})
|
||||
if err != nil {
|
||||
return fmt.Errorf("marshal status patch: %w", err)
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPatch, c.statusURL(namespace, resource, name), bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Accept", "application/json")
|
||||
req.Header.Set("Content-Type", "application/merge-patch+json")
|
||||
if c.BearerToken != "" {
|
||||
req.Header.Set("Authorization", "Bearer "+c.BearerToken)
|
||||
}
|
||||
client := c.HTTPClient
|
||||
if client == nil {
|
||||
client = http.DefaultClient
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
|
||||
return nil
|
||||
}
|
||||
raw, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
|
||||
return fmt.Errorf("patch %s/%s status failed: http %d %s", resource, name, resp.StatusCode, strings.TrimSpace(string(raw)))
|
||||
}
|
||||
|
||||
func (c *KubernetesStatusClient) statusURL(namespace, resource, name string) string {
|
||||
base := strings.TrimRight(c.BaseURL, "/")
|
||||
return base + "/apis/block.seaweedfs.com/v1alpha1/namespaces/" +
|
||||
pathEscape(namespace) + "/" + pathEscape(resource) + "/" + pathEscape(name) + "/status"
|
||||
}
|
||||
|
||||
func pathEscape(value string) string {
|
||||
return url.PathEscape(value)
|
||||
}
|
||||
|
||||
func netJoinHostPort(host, port string) string {
|
||||
if strings.Contains(host, ":") && !strings.HasPrefix(host, "[") {
|
||||
return "[" + host + "]:" + port
|
||||
}
|
||||
return host + ":" + port
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestKubernetesStatusClientPatchesOnlyStatusSubresources(t *testing.T) {
|
||||
var requests []recordedStatusPatch
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
var body map[string]any
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
t.Fatalf("decode request body: %v", err)
|
||||
}
|
||||
requests = append(requests, recordedStatusPatch{
|
||||
Method: r.Method,
|
||||
Path: r.URL.Path,
|
||||
ContentType: r.Header.Get("Content-Type"),
|
||||
Authorization: r.Header.Get("Authorization"),
|
||||
Body: body,
|
||||
})
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte(`{"ok":true}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := &KubernetesStatusClient{
|
||||
BaseURL: server.URL,
|
||||
BearerToken: "test-token",
|
||||
HTTPClient: server.Client(),
|
||||
}
|
||||
observedAt := time.Date(2026, 6, 3, 10, 0, 0, 0, time.UTC)
|
||||
if err := client.WriteClusterStatus(context.Background(), OperatorObjectRef{
|
||||
Namespace: "kube-system",
|
||||
Name: "sw-block",
|
||||
}, SwBlockClusterCRDStatus{
|
||||
ObservedAt: observedAt,
|
||||
VolumeCount: 1,
|
||||
ReadyVolumeCount: 1,
|
||||
MutationAllowed: false,
|
||||
AllowedActionModes: []string{"read_only", "dry_run"},
|
||||
}); err != nil {
|
||||
t.Fatalf("write cluster status: %v", err)
|
||||
}
|
||||
if err := client.WriteVolumeStatus(context.Background(), OperatorObjectRef{
|
||||
Namespace: "kube-system",
|
||||
Name: "demo-pvc",
|
||||
}, SwBlockVolumeCRDStatus{
|
||||
VolumeID: "pvc-123",
|
||||
PVCName: "demo-pvc",
|
||||
Status: ManagedVolumeStatusReady,
|
||||
ReasonCode: ReasonFirstVolumeVerified,
|
||||
ObservedAt: observedAt,
|
||||
}); err != nil {
|
||||
t.Fatalf("write volume status: %v", err)
|
||||
}
|
||||
|
||||
if len(requests) != 2 {
|
||||
t.Fatalf("requests=%d want 2: %+v", len(requests), requests)
|
||||
}
|
||||
wantPaths := []string{
|
||||
"/apis/block.seaweedfs.com/v1alpha1/namespaces/kube-system/swblockclusters/sw-block/status",
|
||||
"/apis/block.seaweedfs.com/v1alpha1/namespaces/kube-system/swblockvolumes/demo-pvc/status",
|
||||
}
|
||||
for i, req := range requests {
|
||||
if req.Method != http.MethodPatch {
|
||||
t.Fatalf("request %d method=%s want PATCH", i, req.Method)
|
||||
}
|
||||
if req.Path != wantPaths[i] {
|
||||
t.Fatalf("request %d path=%s want %s", i, req.Path, wantPaths[i])
|
||||
}
|
||||
if req.ContentType != "application/merge-patch+json" {
|
||||
t.Fatalf("request %d content-type=%s", i, req.ContentType)
|
||||
}
|
||||
if req.Authorization != "Bearer test-token" {
|
||||
t.Fatalf("request %d authorization=%s", i, req.Authorization)
|
||||
}
|
||||
if _, ok := req.Body["status"]; !ok {
|
||||
t.Fatalf("request %d missing status patch: %+v", i, req.Body)
|
||||
}
|
||||
if _, ok := req.Body["spec"]; ok {
|
||||
t.Fatalf("request %d must not patch spec: %+v", i, req.Body)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestKubernetesStatusClientReturnsHTTPFailure(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
_, _ = w.Write([]byte("missing swblockvolume"))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
err := (&KubernetesStatusClient{
|
||||
BaseURL: server.URL,
|
||||
HTTPClient: server.Client(),
|
||||
}).WriteVolumeStatus(context.Background(), OperatorObjectRef{
|
||||
Namespace: "default",
|
||||
Name: "missing",
|
||||
}, SwBlockVolumeCRDStatus{Status: ManagedVolumeStatusReady})
|
||||
if err == nil || !strings.Contains(err.Error(), "http 404") || !strings.Contains(err.Error(), "missing swblockvolume") {
|
||||
t.Fatalf("err=%v", err)
|
||||
}
|
||||
}
|
||||
|
||||
type recordedStatusPatch struct {
|
||||
Method string
|
||||
Path string
|
||||
ContentType string
|
||||
Authorization string
|
||||
Body map[string]any
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# Current Plan: Phase 35 - Kubernetes-Native Read-Only Operator Foundation
|
||||
|
||||
Status: active, 34% complete. Started on 2026-06-02.
|
||||
Status: active, 42% complete. Started on 2026-06-02.
|
||||
|
||||
Branch: `phase33-testops-failure-hardening`
|
||||
|
||||
@@ -119,12 +119,24 @@ Non-blocking follow-up:
|
||||
|
||||
Goal: prove a normal first PVC becomes Kubernetes-native Ready status.
|
||||
|
||||
Status: local status writer PASS; live k3s CR status publication pending QA.
|
||||
|
||||
Boundary:
|
||||
|
||||
```text
|
||||
D3 patches existing SwBlockCluster / SwBlockVolume .status subresources.
|
||||
It does not create CR objects. Automatic SwBlockVolume object ownership is a
|
||||
separate product contract and must not be added silently.
|
||||
```
|
||||
|
||||
Scenario:
|
||||
|
||||
```text
|
||||
helm install
|
||||
run first-volume writer/reader
|
||||
create/read SwBlockVolume status
|
||||
create SwBlockCluster/SwBlockVolume stubs
|
||||
operatorStatus.dryRun=false patches CRD .status
|
||||
read SwBlockVolume status
|
||||
```
|
||||
|
||||
Acceptance:
|
||||
@@ -255,17 +267,24 @@ finished plan moved under internal/docs/finished-plans/
|
||||
- 34%: D2 live k3s QA signoff passed. The dry-run controller starts under
|
||||
Helm, reads blockmaster evidence, reports `mutation_allowed=false`, writes
|
||||
zero CRD objects, is disabled by default, and rejects `dryRun=false`.
|
||||
- 42%: D3 local status writer landed. `sw-block ops operator-status` can run
|
||||
without `--dry-run`, using an in-cluster REST client that PATCHes only
|
||||
`swblockclusters/status` and `swblockvolumes/status`. Component tests verify
|
||||
method/path/body/auth and reject any `spec` patch. Helm can now render
|
||||
`operatorStatus.dryRun=false`, but live k3s publication is still pending.
|
||||
|
||||
## Next Step
|
||||
|
||||
Implement D3 real Kubernetes status publication in the smallest safe slice:
|
||||
first add a component-tested status writer against fake/discovery-shaped
|
||||
Kubernetes clients, then allow `operatorStatus.dryRun=false` only when the
|
||||
writer is wired and still scoped to CRD `.status` plus Events.
|
||||
Ask QA to run the D3 live gate: install with CRD stubs present, enable
|
||||
`operatorStatus.create=true` and `operatorStatus.dryRun=false`, then verify CRD
|
||||
status agrees with the first-volume report while no storage mutation is added by
|
||||
the operator-status service account.
|
||||
|
||||
```text
|
||||
go test ./core/ops ./cmd/sw-block
|
||||
helm template sw-block charts/seaweed-block \
|
||||
--set operatorStatus.create=true \
|
||||
--set operatorStatus.dryRun=false
|
||||
|
||||
kubectl -n kube-system get swblockcluster sw-block -o jsonpath='{.status.readyVolumeCount}'
|
||||
kubectl -n kube-system get swblockvolume <pvc-name> -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
|
||||
```
|
||||
Reference in new issue
Block a user