Skip to content

Commit 8aa2d54

Browse files
committed
support for shinkmulti
I tested having multiple contexts, but cancel issued an error and I did not think now was worth trying to debug. Signed-off-by: vsoch <vsoch@users.noreply.github.com>
1 parent c9e180e commit 8aa2d54

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

cmd/test/test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ func main() {
192192
log.Fatalf("Error in ReapiClient MatchSatisfy - asking for 4 nodes with only 3 should fail: %v\n", err)
193193
}
194194

195+
fmt.Println("Asking to ShrinkMulti by 2 nodes")
196+
err = cli.ShrinkMulti([]string{"/tiny0/rack0/node3", "/tiny0/rack0/node1"})
197+
if err != nil {
198+
log.Fatalf("Error in ReapiClient ShrinkMulti: %s %s\n", err, cli.GetErrMsg())
199+
}
200+
fmt.Printf("Shrink request return value: %v\n", err)
195201
}
196202

197203
func printOutput(reserved bool, allocated string, at int64, jobid uint64, err error) {

pkg/fluxcli/reapi_cli.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,20 @@ func (cli *ReapiClient) Shrink(rNodePath string) (err error) {
252252
return retvalToError(fluxerr, "issue resource api client shrink")
253253
}
254254

255+
// ShrinkMulti issues multiple shrink requests to the API
256+
func (cli *ReapiClient) ShrinkMulti(rNodePaths []string) (err error) {
257+
var fluxerr int
258+
for _, rNodePath := range rNodePaths {
259+
var nodePath = C.CString(rNodePath)
260+
fluxerr := (int)(C.reapi_cli_shrink((*C.struct_reapi_cli_ctx)(cli.ctx), nodePath))
261+
defer C.free(unsafe.Pointer(nodePath))
262+
if fluxerr != 0 {
263+
return retvalToError(fluxerr, "issue resource api client shrink")
264+
}
265+
}
266+
return retvalToError(fluxerr, "issue resource api client shrink")
267+
}
268+
255269
// Cancel cancels the allocation or reservation corresponding to jobid.
256270
//
257271
// \param jobid jobid of the uint64_t type.

0 commit comments

Comments
 (0)