mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
Show a holder refused by the format gate in the master's status
At format level 1 and above, each server holding a volume whose process for it reads below the level gets a volume condition (reason binary_too_old, with the server and its report level): its holder only sees no assignment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3fcd6d00b7
commit
8fe764c039
4 files changed
+130
-1
No files matched your search
@@ -0,0 +1,63 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
control "github.com/seaweedfs/seaweed-block/core/rpc/control"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// binaryTooOldStatusServer answers a cluster status whose volume carries the
|
||||
// master's binary_too_old condition for a refused holder.
|
||||
type binaryTooOldStatusServer struct{ inspectionControlServer }
|
||||
|
||||
func (s binaryTooOldStatusServer) GetClusterStatus(ctx context.Context, q *control.GetClusterStatusRequest) (*control.ClusterStatusResponse, error) {
|
||||
r, err := s.inspectionControlServer.GetClusterStatus(ctx, q)
|
||||
r.Volumes[0].Conditions = append(r.Volumes[0].Conditions, &control.ObservationCondition{
|
||||
Type: "HolderReadsFormat", Status: "false", Reason: "binary_too_old", Severity: "error",
|
||||
Message: "node host-b's process for this volume reads format level 0; the cluster's format level is 1: no grant (binary_too_old)",
|
||||
})
|
||||
return r, err
|
||||
}
|
||||
|
||||
// A holder refused by the format gate sees only no assignment, so the
|
||||
// operator's cluster status --json carries the master's binary_too_old
|
||||
// condition, with the server and its report level.
|
||||
func TestClusterStatusJSONShowsABinaryTooOldHolder(t *testing.T) {
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
srv := grpc.NewServer()
|
||||
control.RegisterEvidenceServiceServer(srv, cmdFakeEvidenceServer{})
|
||||
control.RegisterClusterEvidenceServiceServer(srv, binaryTooOldStatusServer{})
|
||||
go func() { _ = srv.Serve(ln) }()
|
||||
t.Cleanup(func() { srv.Stop(); _ = ln.Close() })
|
||||
var out, errout bytes.Buffer
|
||||
if code := run([]string{"shell", "-master", ln.Addr().String(), "-c", "cluster.status -o json"}, &out, &errout); code != 0 {
|
||||
t.Fatalf("exit=%d stderr=%s", code, &errout)
|
||||
}
|
||||
var body struct {
|
||||
Volumes []struct {
|
||||
Conditions []struct {
|
||||
Reason string `json:"reason"`
|
||||
Message string `json:"message"`
|
||||
} `json:"conditions"`
|
||||
} `json:"volumes"`
|
||||
}
|
||||
if err := json.Unmarshal(out.Bytes(), &body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, v := range body.Volumes {
|
||||
for _, c := range v.Conditions {
|
||||
if c.Reason == "binary_too_old" && bytes.Contains([]byte(c.Message), []byte("host-b's process for this volume reads format level 0")) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
t.Fatalf("cluster status --json has no binary_too_old condition: %s", &out)
|
||||
}
|
||||
@@ -690,6 +690,23 @@ func TestAHolderRestartedOnAnOldBinaryIsNotReissuedItsLine(t *testing.T) {
|
||||
if !ok || line.Incarnation != "p1" {
|
||||
t.Fatalf("the line after p2's refusal: %+v %v, want it still naming p1 (p2 adopts nothing)", line, ok)
|
||||
}
|
||||
// The refusal is not silent: the master's status names the
|
||||
// refused server with its report level (binary_too_old).
|
||||
st, err := control.NewClusterEvidenceServiceClient(conn).GetClusterStatus(ctx, &control.GetClusterStatusRequest{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
found := false
|
||||
for _, vol := range st.GetVolumes() {
|
||||
for _, c := range vol.GetConditions() {
|
||||
if vol.GetVolumeId() == "v" && c.GetReason() == "binary_too_old" && strings.Contains(c.GetMessage(), "node node-b's process for this volume reads format level 0") {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("the master's status does not show v's refused holder: %v", st.GetVolumes())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +230,7 @@ func (h *Host) observationVolume(volumeID string, rec lifecycle.VolumeRecord, pl
|
||||
Message: "master has no published primary for this volume",
|
||||
})
|
||||
}
|
||||
volume.Conditions = append(volume.Conditions, h.formatTooOldConditions(volumeID, placement, line, hasLine)...)
|
||||
if unsupported, ok := h.Controller().LastUnsupported(volumeID); ok {
|
||||
volume.Status = ops.ObservationStatusBlocked
|
||||
volume.Reason = unsupported.Reason
|
||||
@@ -244,6 +245,51 @@ func (h *Host) observationVolume(volumeID string, rec lifecycle.VolumeRecord, pl
|
||||
return volume
|
||||
}
|
||||
|
||||
// formatTooOldConditions names, at format level 1 and above, each server
|
||||
// holding volumeID (placement, authority line, topology) whose process for
|
||||
// it reads below the level: the grant gate refuses it (binary_too_old), and
|
||||
// its holder only sees no assignment.
|
||||
func (h *Host) formatTooOldConditions(volumeID string, placement lifecycle.PlacementIntent, line authority.AuthorityBasis, hasLine bool) []ops.ObservationCondition {
|
||||
level := h.formatLevel()
|
||||
if level == 0 {
|
||||
return nil
|
||||
}
|
||||
servers := map[string]bool{}
|
||||
for _, slot := range placement.Slots {
|
||||
servers[slot.ServerID] = true
|
||||
}
|
||||
if hasLine && line.Assigned {
|
||||
servers[h.workspaceSourceHost(volumeID, line.ReplicaID, line.Epoch)] = true
|
||||
}
|
||||
for _, v := range h.topo.Volumes {
|
||||
if v.VolumeID == volumeID {
|
||||
for _, slot := range v.Slots {
|
||||
servers[slot.ServerID] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
ids := make([]string, 0, len(servers))
|
||||
for s := range servers {
|
||||
if s != "" {
|
||||
ids = append(ids, s)
|
||||
}
|
||||
}
|
||||
sort.Strings(ids)
|
||||
var out []ops.ObservationCondition
|
||||
for _, s := range ids {
|
||||
if reads, ok := h.reads.entry(s, volumeID, h.servedBy(s)); ok && reads < level {
|
||||
out = append(out, ops.ObservationCondition{
|
||||
Type: "HolderReadsFormat",
|
||||
Status: "false",
|
||||
Reason: ops.ReasonBinaryTooOld,
|
||||
Severity: "error",
|
||||
Message: fmt.Sprintf("node %s's process for this volume reads format level %d; the cluster's format level is %d: no grant (binary_too_old)", s, reads, level),
|
||||
})
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (h *Host) observationReplicas(volumeID string, placement lifecycle.PlacementIntent, line authority.AuthorityBasis, hasLine bool) []ops.ReplicaEvidence {
|
||||
slots := placement.Slots
|
||||
if len(slots) == 0 {
|
||||
|
||||
@@ -54,7 +54,10 @@ const (
|
||||
ReasonObservedReplicasBelowDesired = "observed_replicas_below_desired"
|
||||
// A new volume serves nothing until the primary attested every initial
|
||||
// replica's store (creating: waiting for replica attestations).
|
||||
ReasonAwaitingReplicaAttestations = "awaiting_replica_attestations"
|
||||
ReasonAwaitingReplicaAttestations = "awaiting_replica_attestations"
|
||||
// A process holding the volume reads below the cluster's format level:
|
||||
// the master grants it nothing (its holder sees only no assignment).
|
||||
ReasonBinaryTooOld = "binary_too_old"
|
||||
ReasonLoopbackFrontendRejected = "loopback_frontend_rejected"
|
||||
ReasonStalePrimaryFenced = "stale_primary_fenced"
|
||||
ReasonWALIntegrityFault = "wal_integrity_fault"
|
||||
|
||||
Reference in new issue
Block a user