Skip to content

Commit 0440952

Browse files
kvapsclaude
andcommitted
feat(rest): honour ?nodes= and ?storage_pools= filters on /v1/view/storage-pools
linstor-csi's NodeRegister loop calls /v1/view/storage-pools?nodes=X to discover what topology the satellite advertises for that one node. Returning the whole cluster's pools instead is technically correct but wastes round-trips and surfaces unrelated nodes' state in the client's per-node logic. Match Java LINSTOR's set-membership filter. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
1 parent 2434244 commit 0440952

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

pkg/rest/storage_pools.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package rest
1818

1919
import (
2020
"net/http"
21+
22+
apiv1 "github.com/cozystack/blockstor/pkg/api/v1"
2123
)
2224

2325
// registerStoragePools wires endpoints serving golinstor's StoragePool calls.
@@ -39,7 +41,29 @@ func (s *Server) handleStoragePoolsView(w http.ResponseWriter, r *http.Request)
3941
return
4042
}
4143

42-
writeJSON(w, http.StatusOK, pools)
44+
// Optional filters golinstor sends: ?nodes=a,b&storage_pools=p1,p2.
45+
// Java LINSTOR honours both as case-insensitive set-membership;
46+
// we match that so /v1/view/storage-pools?nodes=X — the call
47+
// linstor-csi makes on every NodeRegister — does not return the
48+
// whole cluster's pools when only one node is asked about.
49+
nodeFilter := splitCSV(r.URL.Query().Get("nodes"))
50+
poolFilter := splitCSV(r.URL.Query().Get("storage_pools"))
51+
52+
out := make([]apiv1.StoragePool, 0, len(pools))
53+
54+
for i := range pools {
55+
if !matchAnyFold(nodeFilter, pools[i].NodeName) {
56+
continue
57+
}
58+
59+
if !matchAnyFold(poolFilter, pools[i].StoragePoolName) {
60+
continue
61+
}
62+
63+
out = append(out, pools[i])
64+
}
65+
66+
writeJSON(w, http.StatusOK, out)
4367
}
4468

4569
func (s *Server) handleNodeStoragePoolsList(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)