mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
include source modification in diagnostic revisions
This commit is contained in:
1 parent
f91247f4cb
commit
f02e4a0bfa
6 files changed
+19
-23
No files matched your search
@@ -15,7 +15,7 @@ func TestGetClusterStatusReportsBuildRevision(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := strings.TrimPrefix(strings.Fields(buildinfo.Version("blockmaster"))[1], "revision=")
|
||||
want := strings.TrimPrefix(buildinfo.Version("blockmaster"), "blockmaster revision=")
|
||||
if resp.GetProductRevision() == "" || resp.GetProductRevision() != want {
|
||||
t.Fatalf("master product_revision=%q; --version revision=%q", resp.GetProductRevision(), want)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestStatusReportsComparableBuildRevision(t *testing.T) {
|
||||
if err = json.NewDecoder(resp.Body).Decode(&body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := strings.TrimPrefix(strings.Fields(buildinfo.Version("blockvolume"))[1], "revision=")
|
||||
want := strings.TrimPrefix(buildinfo.Version("blockvolume"), "blockvolume revision=")
|
||||
if body.Version == "" || body.Version != want || body.VolumeID != "v1" {
|
||||
t.Fatalf("holder /status=%+v; --version revision=%q", body, want)
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ const (
|
||||
// replica readiness from authority movement.
|
||||
type StatusProjection struct {
|
||||
frontend.Projection
|
||||
// Version is the build revision, in the same form as master product_revision.
|
||||
// Version is the build revision plus modified flag, matching master product_revision.
|
||||
// Unknown provenance does not prove that two builds are equal.
|
||||
Version string
|
||||
// Memory is the process's memory use at the time of the request.
|
||||
|
||||
@@ -772,4 +772,4 @@ A restore makes a new volume from a snapshot. The new volume reads every chunk i
|
||||
|
||||
### Comparing master and holder revisions
|
||||
|
||||
`ClusterEvidenceService.GetClusterStatus.product_revision` and the holder's local `GET /status?volume=<name>` field `Version` both report the component-independent VCS revision from buildinfo. Compare these values to check for different source revisions; the holder field is read on its host through the existing loopback status endpoint. Neither value is carried in `HeartbeatReport`. An absent or `unknown` value means provenance is unavailable: even two `unknown` values do not establish equal builds. A matching revision does not prove byte-identical binaries or a clean working tree; the daemon's `--version` also reports whether its source was modified. These fields are diagnostic and do not affect readiness, leases or admissions.
|
||||
`ClusterEvidenceService.GetClusterStatus.product_revision` and the holder's local `GET /status?volume=<name>` field `Version` both report component-independent buildinfo provenance as `<revision> modified=<true/false/unknown>`. The modified flag is appended so clean and modified source trees do not compare equal. Compare these values to check for different source revisions; the holder field is read on its host through the existing loopback status endpoint. Neither value is carried in `HeartbeatReport`. An absent value or `unknown` revision/modified field means provenance is unavailable: even matching unknown values do not establish equal builds. Matching provenance does not prove byte-identical binaries, and two dirty trees can differ despite matching revision/modified fields; the daemon's `--version` reports these same fields with its component name. These fields are diagnostic and do not affect readiness, leases or admissions.
|
||||
@@ -19,6 +19,7 @@ The volume's authority and health projection. Go type `volume.StatusProjection`.
|
||||
| `Epoch` | uint64 | the authority epoch of the current assignment |
|
||||
| `EndpointVersion` | uint64 | the assignment's endpoint version within the epoch |
|
||||
| `Healthy` | bool | the replica may serve I/O at this epoch |
|
||||
| `Version` | string | Component-independent build provenance in `<revision> modified=<true/false/unknown>` form, matching master `product_revision`; missing revision is `unknown`. Unknown never establishes equal builds. Diagnostic only. |
|
||||
| `Memory` | object | Memory is the process's memory use at the time of the request. |
|
||||
| `Memory.HeapAllocBytes` | uint64 | Go heap bytes in live objects (runtime.MemStats.HeapAlloc) |
|
||||
| `Memory.HeapInuseBytes` | uint64 | Go heap bytes in in-use spans (HeapInuse) |
|
||||
|
||||
@@ -7,31 +7,26 @@ import (
|
||||
|
||||
// Version returns a compact provenance string suitable for lab artifacts.
|
||||
func Version(component string) string {
|
||||
revision := Revision()
|
||||
modified := "unknown"
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
for _, setting := range info.Settings {
|
||||
switch setting.Key {
|
||||
case "vcs.modified":
|
||||
if setting.Value != "" {
|
||||
modified = setting.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s revision=%s modified=%s", component, revision, modified)
|
||||
return fmt.Sprintf("%s revision=%s", component, Revision())
|
||||
}
|
||||
|
||||
// Revision is the component-independent VCS revision, or "unknown" when
|
||||
// build provenance is unavailable. It is diagnostic, never an identity or
|
||||
// admission fact; two unknown revisions do not establish equal builds.
|
||||
// Revision is the component-independent VCS revision and modified flag.
|
||||
// Unavailable build metadata is explicit; unknown never proves equal builds.
|
||||
// This is diagnostic, never an identity or admission fact.
|
||||
func Revision() string {
|
||||
revision, modified := "unknown", "unknown"
|
||||
if info, ok := debug.ReadBuildInfo(); ok {
|
||||
for _, setting := range info.Settings {
|
||||
if setting.Key == "vcs.revision" && setting.Value != "" {
|
||||
return setting.Value
|
||||
if setting.Value == "" {
|
||||
continue
|
||||
}
|
||||
switch setting.Key {
|
||||
case "vcs.revision":
|
||||
revision = setting.Value
|
||||
case "vcs.modified":
|
||||
modified = setting.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
return "unknown"
|
||||
return fmt.Sprintf("%s modified=%s", revision, modified)
|
||||
}
|
||||
Reference in new issue
Block a user