Skip to content

Commit 558d80f

Browse files
kvapsclaude
andcommitted
feat(rest): drbd-proxy compatibility stubs (501 Not Implemented)
Cozystack-style clusters run flat L2 so DRBD-9's native protocol covers everything; we don't actually run drbd-proxy. The endpoints exist anyway so `linstor drbd-proxy *` returns a deterministic 501 instead of a confusing 404. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
1 parent def3e7c commit 558d80f

4 files changed

Lines changed: 99 additions & 1 deletion

File tree

PLAN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Full scope list lives in `docs/csi-api-surface.md` (to be created in Phase 1).
257257

258258
- [ ] LUKS encryption layer (volume-level)
259259
- [ ] DRBD encryption passphrase
260-
- [ ] DRBD proxy enable/disable/configure
260+
- [x] DRBD proxy enable/disable/configure: 501 Not Implemented stubs (`/v1/resource-definitions/{rd}/drbd-proxy*`). Cozystack-style clusters run flat L2 so DRBD-9's native protocol suffices; proxy isn't needed. Endpoints exist so `linstor drbd-proxy *` returns a deterministic error.
261261
- [ ] DRBD options: full set from `drbdoptions.json`
262262
- [x] file storage provider (`pkg/storage/file`): FILE / FILE_THIN behind same Provider seam — fallocate (thick) / truncate (thin) for create, statfs(2) for pool capacity, snapshots intentionally unsupported (caller routes to LVM/ZFS instead). 9 contract tests.
263263
- [ ] External-file management

pkg/rest/drbd_proxy.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2026 Cozystack contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package rest
18+
19+
import (
20+
"net/http"
21+
)
22+
23+
// registerDRBDProxy wires the DRBD-proxy compatibility endpoints. We
24+
// don't actually run drbd-proxy in cozystack-style clusters — the
25+
// network is flat L2 and DRBD-9's native protocol handles everything.
26+
// But the linstor CLI calls these (in `drbd-proxy enable` etc.) and we
27+
// want a deterministic 501 instead of a confusing 404.
28+
func (s *Server) registerDRBDProxy(mux *http.ServeMux) {
29+
mux.HandleFunc("POST /v1/resource-definitions/{rd}/drbd-proxy/enable/{a}/{b}",
30+
handleNotImplemented)
31+
mux.HandleFunc("POST /v1/resource-definitions/{rd}/drbd-proxy/disable/{a}/{b}",
32+
handleNotImplemented)
33+
mux.HandleFunc("PUT /v1/resource-definitions/{rd}/drbd-proxy",
34+
handleNotImplemented)
35+
}
36+
37+
// handleNotImplemented is the shared 501 responder. The body matches
38+
// the LINSTOR ApiCallRc shape so the CLI renders a sensible error.
39+
func handleNotImplemented(w http.ResponseWriter, _ *http.Request) {
40+
writeError(w, http.StatusNotImplemented, "drbd-proxy is not supported in this build")
41+
}

pkg/rest/drbd_proxy_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2026 Cozystack contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package rest
18+
19+
import (
20+
"net/http"
21+
"testing"
22+
23+
"github.com/cozystack/blockstor/pkg/store"
24+
)
25+
26+
// TestDRBDProxyEndpointsRespond: every DRBD-proxy endpoint we expose
27+
// returns 501 Not Implemented. Cozystack does not run DRBD proxy
28+
// (everything is on the same flat L2), but the linstor CLI calls
29+
// these and falling through to 404 is worse than an explicit 501.
30+
func TestDRBDProxyEndpointsRespond(t *testing.T) {
31+
base, stop := startServerWithStore(t, store.NewInMemory())
32+
defer stop()
33+
34+
cases := []struct {
35+
method string
36+
path string
37+
}{
38+
{http.MethodPost, "/v1/resource-definitions/pvc-1/drbd-proxy/enable/n1/n2"},
39+
{http.MethodPost, "/v1/resource-definitions/pvc-1/drbd-proxy/disable/n1/n2"},
40+
{http.MethodPut, "/v1/resource-definitions/pvc-1/drbd-proxy"},
41+
}
42+
43+
for _, tc := range cases {
44+
req, _ := http.NewRequestWithContext(t.Context(), tc.method, base+tc.path, nil)
45+
46+
resp, err := http.DefaultClient.Do(req)
47+
if err != nil {
48+
t.Fatalf("%s %s: %v", tc.method, tc.path, err)
49+
}
50+
_ = resp.Body.Close()
51+
52+
if resp.StatusCode != http.StatusNotImplemented {
53+
t.Errorf("%s %s: status %d, want 501", tc.method, tc.path, resp.StatusCode)
54+
}
55+
}
56+
}

pkg/rest/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func (s *Server) Start(ctx context.Context) error {
7575
s.registerSnapshotRestore(mux)
7676
s.registerEncryption(mux)
7777
s.registerNodeLifecycle(mux)
78+
s.registerDRBDProxy(mux)
7879

7980
srv := &http.Server{
8081
Addr: s.Addr,

0 commit comments

Comments
 (0)