Skip to content

Commit 4c904db

Browse files
kvapsclaude
andcommitted
feat(rest): autoplace returns LINSTOR-shaped success ApiCallRc
Java LINSTOR replies with a `[]ApiCallRc` body that carries MASK_INFO + RC_RSC_DFN_PLACED. golinstor.Autoplace ignored an empty 200, but CLI tools and proxies that surface API messages expect the shape to match. Emit it. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
1 parent 74421e3 commit 4c904db

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

pkg/rest/autoplace.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,25 @@ func (s *Server) handleAutoplace(w http.ResponseWriter, r *http.Request) {
130130
return
131131
}
132132

133-
w.WriteHeader(http.StatusOK)
133+
// Java LINSTOR replies with a `[]ApiCallRc` envelope on success.
134+
// golinstor's RD.Autoplace ignores an empty body, but tools that
135+
// surface API messages (e.g. the linstor CLI) want a real result
136+
// to log. Return MASK_INFO + RC_PLACEMENT_DONE-style entry so the
137+
// shape matches the oracle's.
138+
writeJSON(w, http.StatusOK, []apiv1.APICallRc{{
139+
RetCode: apiCallRcInfo | apiCallRcRDAutoplaceDone,
140+
Message: "Resource definition '" + rdName + "' auto-placed",
141+
}})
134142
}
135143

144+
// apiCallRcInfo is upstream LINSTOR's MASK_INFO bit (0x0040_…).
145+
// Combined with a per-action code it lets clients distinguish
146+
// success-with-info from a fatal error.
147+
const (
148+
apiCallRcInfo int64 = 0x0040_0000_0000_0000
149+
apiCallRcRDAutoplaceDone int64 = 0x4231 // ApiConsts.RC_RSC_DFN_PLACED
150+
)
151+
136152
// placeResources picks free pools from the candidates and creates Resource
137153
// objects up to filter.PlaceCount. Returns (placed, want, err).
138154
func (s *Server) placeResources(ctx context.Context, rdName string, filter *apiv1.AutoSelectFilter) (int, int, error) {

0 commit comments

Comments
 (0)