Skip to content

Commit 44b1df4

Browse files
kvapsclaude
andcommitted
feat(rest): sos-report endpoint stub (501 Not Implemented)
GET /v1/sos-report returns 501 with a clear message. linstor CLI's `sos-report download` calls this; without the endpoint it 404s confusingly. Real bundling of controller logs + per-satellite state into a tarball is operationally useful but non-trivial work. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
1 parent 98d7fe2 commit 44b1df4

3 files changed

Lines changed: 74 additions & 0 deletions

File tree

pkg/rest/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func (s *Server) Start(ctx context.Context) error {
7979
s.registerExternalFiles(mux)
8080
s.registerDRBDPassphrase(mux)
8181
s.registerRDClone(mux)
82+
s.registerSOSReport(mux)
8283

8384
srv := &http.Server{
8485
Addr: s.Addr,

pkg/rest/sos_report.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
// registerSOSReport wires the `linstor sos-report download` endpoint.
24+
// Bundling controller logs + every satellite's local state into a
25+
// tarball is operationally useful but non-trivial — we 501 today so
26+
// the CLI gets a clear error rather than 404'ing.
27+
func (s *Server) registerSOSReport(mux *http.ServeMux) {
28+
mux.HandleFunc("GET /v1/sos-report", handleSOSReport)
29+
}
30+
31+
func handleSOSReport(w http.ResponseWriter, _ *http.Request) {
32+
writeError(w, http.StatusNotImplemented, "sos-report bundling not yet implemented")
33+
}

pkg/rest/sos_report_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
// TestSOSReportReturns501: linstor CLI's `sos-report download` calls
27+
// /v1/sos-report. We don't yet bundle controller logs / state into a
28+
// tarball; explicitly 501 so the CLI can render a clear error rather
29+
// than crash on the unexpected 404.
30+
func TestSOSReportReturns501(t *testing.T) {
31+
base, stop := startServerWithStore(t, store.NewInMemory())
32+
defer stop()
33+
34+
resp := httpGet(t, base+"/v1/sos-report")
35+
_ = resp.Body.Close()
36+
37+
if resp.StatusCode != http.StatusNotImplemented {
38+
t.Errorf("status: got %d, want 501", resp.StatusCode)
39+
}
40+
}

0 commit comments

Comments
 (0)