server: implement update container resources
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
7d7024999b
commit
c25530ac0b
6 changed files with 107 additions and 5 deletions
19
oci/oci.go
19
oci/oci.go
|
@ -549,6 +549,25 @@ func (r *Runtime) ExecSync(c *Container, command []string, timeout int64) (resp
|
|||
}, nil
|
||||
}
|
||||
|
||||
// UpdateContainer updates container resources
|
||||
func (r *Runtime) UpdateContainer(c *Container, res *rspec.LinuxResources) error {
|
||||
cmd := exec.Command(r.Path(c), "update", "--resources", "-", c.id)
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
jsonResources, err := json.Marshal(res)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.Stdin = bytes.NewReader(jsonResources)
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("updating resources for container %q failed: %v %v (%v)", c.id, stderr.String(), stdout.String(), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func waitContainerStop(ctx context.Context, c *Container, timeout time.Duration) error {
|
||||
done := make(chan struct{})
|
||||
// we could potentially re-use "done" channel to exit the loop on timeout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue