Bound serve_stale member copies by age, toggle and eviction
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful

- drop a member's copy when serve_stale is off
- block on the member again once its copy is over an hour old
- skip storing a refresh whose entry was evicted or replaced
- show serve_stale in the UI and TUI
This commit is contained in:
2026-10-25 13:29:43 +11:00
parent 327f09fc6f
commit 50ef1291fc
7 changed files with 221 additions and 16 deletions
+19
View File
@@ -416,6 +416,25 @@ func TestServerRemoteUpdateAndVirtualCRUD(t *testing.T) {
}
}
func TestServerRemoteServeStaleRoundTrip(t *testing.T) {
requireStack(t)
if resp, b := req(t, "POST", "/api/v2/remotes", `{"name":"srv-ss","package_type":"rpm","repo_type":"remote","base_url":"https://a.example.com","serve_stale":true}`); resp.StatusCode != 201 {
t.Fatalf("create remote: %d %s", resp.StatusCode, b)
}
defer req(t, "DELETE", "/api/v2/remotes/srv-ss", "")
get := func(want string) {
t.Helper()
if _, b := req(t, "GET", "/api/v2/remotes/srv-ss", ""); !strings.Contains(string(b), want) {
t.Errorf("get remote: want %s in %s", want, b)
}
}
get(`"serve_stale":true`)
if resp, b := req(t, "PUT", "/api/v2/remotes/srv-ss", `{"package_type":"rpm","base_url":"https://a.example.com"}`); resp.StatusCode != 200 {
t.Fatalf("update remote: %d %s", resp.StatusCode, b)
}
get(`"serve_stale":false`)
}
func TestServerLocalRemoveAndMissing(t *testing.T) {
requireStack(t)
req(t, "POST", "/api/v2/remotes", `{"name":"srv-rm","package_type":"generic","repo_type":"local"}`)