Skip to content

Commit

Permalink
support for shinkmulti
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
vsoch committed Jan 15, 2025
1 parent c9e180e commit 8aa2d54
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ func main() {
log.Fatalf("Error in ReapiClient MatchSatisfy - asking for 4 nodes with only 3 should fail: %v\n", err)
}

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

func printOutput(reserved bool, allocated string, at int64, jobid uint64, err error) {
Expand Down
14 changes: 14 additions & 0 deletions pkg/fluxcli/reapi_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ func (cli *ReapiClient) Shrink(rNodePath string) (err error) {
return retvalToError(fluxerr, "issue resource api client shrink")
}

// ShrinkMulti issues multiple shrink requests to the API
func (cli *ReapiClient) ShrinkMulti(rNodePaths []string) (err error) {
var fluxerr int
for _, rNodePath := range rNodePaths {
var nodePath = C.CString(rNodePath)
fluxerr := (int)(C.reapi_cli_shrink((*C.struct_reapi_cli_ctx)(cli.ctx), nodePath))
defer C.free(unsafe.Pointer(nodePath))
if fluxerr != 0 {
return retvalToError(fluxerr, "issue resource api client shrink")
}
}
return retvalToError(fluxerr, "issue resource api client shrink")
}

// Cancel cancels the allocation or reservation corresponding to jobid.
//
// \param jobid jobid of the uint64_t type.
Expand Down

0 comments on commit 8aa2d54

Please sign in to comment.