Skip to content

Commit 9d5b45f

Browse files
kvapsclaude
andcommitted
fix(rest): writeError emits LINSTOR-shaped []ApiCallRc envelope
golinstor (and therefore linstor-csi) unmarshals failure responses into a []ApiCallRc slice. We were sending a {"error": "..."} object, which surfaced as json: cannot unmarshal object into Go value of type client.ApiCallError on every failed CSI call — losing the actual error message. Switch to the upstream-shaped envelope with the ERROR mask set so golinstor detects pass/fail correctly. This is the single biggest unlock for csi-sanity numbers (most of the 36 failures shared this root cause). Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
1 parent 2bb350b commit 9d5b45f

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

pkg/rest/nodes.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,23 @@ func writeStoreError(w http.ResponseWriter, err error) {
158158
}
159159
}
160160

161-
// writeError sends a minimal JSON error body. Once we wire ApiCallRc in
162-
// Phase 2 this becomes the real LINSTOR error envelope.
161+
// writeError sends the LINSTOR-shaped `[]ApiCallRc` error envelope.
162+
// golinstor (and therefore linstor-csi) unmarshals failure responses
163+
// into a slice — sending a `{"error": "..."}` object made every
164+
// failed CSI call surface as `json: cannot unmarshal object into Go
165+
// value of type client.ApiCallError` instead of the actual error
166+
// message.
167+
//
168+
// retCode follows the upstream convention: high bit set means
169+
// FATAL/error; we use 0xC000_0000 which is the masked-but-untyped
170+
// "generic error" the controller uses when no specific code applies.
163171
func writeError(w http.ResponseWriter, status int, msg string) {
164-
writeJSON(w, status, map[string]string{"error": msg})
172+
writeJSON(w, status, []apiv1.APICallRc{{
173+
RetCode: apiCallRcError,
174+
Message: msg,
175+
}})
165176
}
177+
178+
// apiCallRcError is upstream LINSTOR's ERROR mask (high bit set on a
179+
// 64-bit mask). golinstor checks for this bit to decide pass/fail.
180+
const apiCallRcError uint64 = 0xC000_0000_0000_0000

0 commit comments

Comments
 (0)