mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 18:47:20 +01:00
fix: require timestamps for age-bounded cleanup evidence
This commit is contained in:
1 parent
be1f66983e
commit
7cfac5eee9
4 files changed
+45
-8
No files matched your search
@@ -158,8 +158,13 @@ func EvaluateSwBlockVolumeDeleteSafety(facts SwBlockVolumeDeleteSafetyFacts) SwB
|
||||
}
|
||||
|
||||
func cleanupEvidenceStale(facts SwBlockVolumeDeleteSafetyFacts) bool {
|
||||
if facts.Cleanup == nil || facts.Cleanup.ObservedAt.IsZero() ||
|
||||
facts.ObservedAt.IsZero() || facts.MaxEvidenceAge <= 0 {
|
||||
if facts.Cleanup == nil || facts.MaxEvidenceAge <= 0 {
|
||||
return false
|
||||
}
|
||||
if facts.Cleanup.ObservedAt.IsZero() {
|
||||
return true // An enabled age bound requires a timestamp to prove freshness.
|
||||
}
|
||||
if facts.ObservedAt.IsZero() {
|
||||
return false
|
||||
}
|
||||
return facts.Cleanup.ObservedAt.Add(facts.MaxEvidenceAge).Before(facts.ObservedAt)
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
package ops
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestDeleteSafety_UntimedCleanupCannotProveFreshness(t *testing.T) {
|
||||
if os.Getenv("SEAWEED_KNOWN_BUGS") != "1" {
|
||||
t.Skip("known bug #188 (open): reproduction runs with SEAWEED_KNOWN_BUGS=1; the fix PR removes this skip")
|
||||
}
|
||||
decision := EvaluateSwBlockVolumeDeleteSafety(SwBlockVolumeDeleteSafetyFacts{
|
||||
DeleteRequested: true, FinalizerPresent: true,
|
||||
ObservedAt: time.Date(2026, 11, 17, 0, 0, 0, 0, time.UTC), MaxEvidenceAge: 15 * time.Minute,
|
||||
@@ -18,4 +15,28 @@ func TestDeleteSafety_UntimedCleanupCannotProveFreshness(t *testing.T) {
|
||||
if decision.FinalizerReleaseAllowed || decision.Decision != ManagedVolumeActionDecisionUnknown {
|
||||
t.Fatalf("untimed cleanup accepted as fresh: %+v; require UNKNOWN and no finalizer release", decision)
|
||||
}
|
||||
if decision.Reason != ReasonCleanupEvidenceStale || !stringSliceContains(decision.MissingFacts, "cleanup.freshness") || decision.SafeNextAction != ManagedVolumeActionVerifyCleanup {
|
||||
t.Fatalf("missing freshness must request cleanup verification: %+v", decision)
|
||||
}
|
||||
}
|
||||
|
||||
// Exercise the bundle reader used by the Kubernetes status projection, not just
|
||||
// the evaluator: an absent timestamp must survive parsing as unknown freshness.
|
||||
func TestObservationBundle_UntimedCleanupCannotReportReleasable(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
writeProductClusterEvidence(t, dir, []VolumeEvidence{{VolumeID: "pvc-untimed", Status: ObservationStatusOK}})
|
||||
mustWrite(t, filepath.Join(dir, ObservationCleanupSummaryArtifact), "cleanup_status=ok")
|
||||
mustWrite(t, filepath.Join(dir, ObservationDeleteSafetyArtifact), "volume_id=pvc-untimed\ndelete_requested=true\nfinalizer_present=true")
|
||||
cluster, err := BuildObservationFromBundle(ObservationBundleOptions{Dir: dir, VolumeID: "pvc-untimed"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
managed := managedProjectionForVolume(cluster.ManagedVolumes, "pvc-untimed")
|
||||
if managed.DeleteSafety == nil || managed.DeleteSafety.FinalizerReleaseAllowed || managed.DeleteSafety.Decision != ManagedVolumeActionDecisionUnknown || managed.ReasonCode != ReasonCleanupEvidenceStale {
|
||||
t.Fatalf("untimed cleanup must project UNKNOWN, not releasable: %+v", managed)
|
||||
}
|
||||
snapshot := BuildOperatorFoundationSnapshot(cluster)
|
||||
if len(snapshot.Volumes) != 1 || snapshot.Volumes[0].Status.DeleteSafety == nil || snapshot.Volumes[0].Status.DeleteSafety.Decision != ManagedVolumeActionDecisionUnknown || snapshot.Volumes[0].Status.DeleteSafety.FinalizerReleaseAllowed {
|
||||
t.Fatalf("Kubernetes snapshot must retain UNKNOWN delete safety: %+v", snapshot.Volumes)
|
||||
}
|
||||
}
|
||||
@@ -707,6 +707,7 @@ func TestObservationBundle_DeleteSafetyBlocksWithResidue(t *testing.T) {
|
||||
}})
|
||||
mustWrite(t, filepath.Join(dir, ObservationCleanupSummaryArtifact), strings.Join([]string{
|
||||
"cleanup_status=failed",
|
||||
"cleanup_observed_at=2026-05-27T12:00:00Z",
|
||||
"iscsi_residue_count=1",
|
||||
"reason_codes=iscsi_node_records_present",
|
||||
}, "\n"))
|
||||
@@ -921,7 +922,7 @@ func TestObservationBundle_DeleteSafetyReleasableWithCleanCleanupEvidence(t *tes
|
||||
FrontendAddr: "192.168.1.181:3260",
|
||||
}},
|
||||
}})
|
||||
mustWrite(t, filepath.Join(dir, ObservationCleanupSummaryArtifact), "cleanup_status=ok")
|
||||
mustWrite(t, filepath.Join(dir, ObservationCleanupSummaryArtifact), "cleanup_status=ok\ncleanup_observed_at=2026-05-27T12:00:00Z")
|
||||
mustWrite(t, filepath.Join(dir, ObservationDeleteSafetyArtifact), strings.Join([]string{
|
||||
"delete_requested=true",
|
||||
"finalizer_present=true",
|
||||
|
||||
@@ -120,7 +120,17 @@ These are narrow alpha claims tied to documented gates. See
|
||||
- Upgrade or rollback execution. The status layer can report install drift, but
|
||||
it does not run Helm or kubectl mutations.
|
||||
|
||||
## Release images
|
||||
## Known issues
|
||||
|
||||
- In v1.0.0, cleanup evidence without `cleanup_observed_at` can incorrectly
|
||||
report a `SwBlockVolume` deletion as releasable despite the status projection's
|
||||
15-minute evidence age bound ([#188](https://github.com/seaweedfs/seaweed-block/issues/188)).
|
||||
Supply a real observation timestamp in the cleanup summary. The v1.0.1 fix
|
||||
reports UNKNOWN with missing `cleanup.freshness` when that timestamp is absent;
|
||||
the next action is to verify cleanup again. This is a Kubernetes status
|
||||
projection defect; no product delete acts on this decision.
|
||||
|
||||
## Release images
|
||||
|
||||
|
||||
Current validated published quickstart image tag: `sha-dc2972d0059b`.
|
||||
|
||||
Reference in new issue
Block a user