hub(R-1299): the one-time clean-up window gets a button on the customer page
gates / gates (push) Successful in 1m51s
gates / gates (push) Successful in 1m51s
The Backup card's off-site part shows the window state (weekly switch, the normal cap, a waiting grant, the last window) and a form: optional limit -> a confirm step that names the customer and the limit -> the SAME route and rule as the script address (POST /offsite/window-grant/<customer>, wr(grpOffsite), the page's CSRF). A waiting grant can be cancelled. A raised limit above the store's measured snapshot count is refused (the 500 ceiling stays). Every grant and cancel: a log line and an operator-only info event offsite_window_grant (who, customer, limit). Tests TestR1299_* (five), red-proved by five mutations.
This commit is contained in:
1 parent
7610f69e7c
commit
d85198b835
8 files changed
+549
-32
No files matched your search
@@ -12,7 +12,6 @@ import (
|
||||
"log"
|
||||
"math"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -777,36 +776,10 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_ = json.NewEncoder(w).Encode(map[string]int{"changed": n})
|
||||
case strings.HasPrefix(path, "/offsite/window-grant/") || path == "/offsite/windows-enabled":
|
||||
// Operator (decision 68): a one-shot grant lets the customer's NEXT window request through;
|
||||
// the switch turns the WEEKLY window on/off fleet-wide (off = the interim: nothing prunes).
|
||||
if r.Method != http.MethodPost || s.offsiteWindowGrant == nil {
|
||||
http.Error(w, "unavailable", http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
var err error
|
||||
if path == "/offsite/windows-enabled" {
|
||||
err = s.offsiteWindowSwitch(r.FormValue("on") == "1")
|
||||
} else if mr := r.FormValue("max_remove"); mr != "" {
|
||||
// R-833: one window with a raised removal cap (operator only — this server is behind the
|
||||
// operator's login; the box API has no route to it).
|
||||
n, perr := strconv.Atoi(mr)
|
||||
if perr != nil || s.offsiteWindowGrantMax == nil {
|
||||
http.Error(w, "max_remove must be a number", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if err = s.offsiteWindowGrantMax(strings.TrimPrefix(path, "/offsite/window-grant/"), n); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err = s.offsiteWindowGrant(strings.TrimPrefix(path, "/offsite/window-grant/"))
|
||||
}
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
_, _ = w.Write([]byte("{\"ok\":true}\n"))
|
||||
// Operator (decision 68): a one-shot grant lets the customer's NEXT window request through, with an optional
|
||||
// raised cap (R-833); the switch turns the WEEKLY window on/off fleet-wide. The customer page's form (R-1299)
|
||||
// posts here too — offsite_window.go.
|
||||
s.handleOffsiteWindowGrant(w, r, path)
|
||||
case strings.HasPrefix(path, "/os/"):
|
||||
// Operator (hub v0.130.0, `11` §8 step 2): per-box ring and switch, approve now, the fleet lines.
|
||||
s.handleOSAdmin(w, r, path)
|
||||
|
||||
Reference in new issue
Block a user