Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/cow/cow.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,6 @@ type Container interface {
// container to be terminated by some error condition (including calling
// Close).
Wait() error
// Modify sends a request to modify container resources
Modify(ctx context.Context, config interface{}) error
}
19 changes: 19 additions & 0 deletions internal/gcs/guestconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,25 @@ func (gc *GuestConnection) DeleteContainerState(ctx context.Context, cid string)
return gc.brdg.RPC(ctx, rpcDeleteContainerState, &req, &resp, false)
}

func (gc *GuestConnection) UpdateContainer(ctx context.Context, cid string, resources interface{}) (err error) {
ctx, span := trace.StartSpan(ctx, "gcs::GuestConnection::UpdateContainer")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for new code the plan was to stop with the :: convention in our logs and use periods but my mind is hazy.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevpar can you comment on this? I wanted to be consistent with the other guest connection traces

defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes(trace.StringAttribute("cid", cid))

resourcesJSON, err := json.Marshal(resources)
if err != nil {
return err
}

req := updateContainerRequest{
requestBase: makeRequest(ctx, cid),
Resources: string(resourcesJSON),
}
var resp responseBase
return gc.brdg.RPC(ctx, rpcUpdateContainer, &req, &resp, false)
}

// Close terminates the guest connection. It is undefined to call any other
// methods on the connection after this is called.
func (gc *GuestConnection) Close() error {
Expand Down
8 changes: 8 additions & 0 deletions internal/gcs/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
rpcNegotiateProtocol
rpcDumpStacks
rpcDeleteContainerState
rpcUpdateContainer
rpcLifecycleNotification
)

Expand Down Expand Up @@ -118,6 +119,8 @@ func (typ msgType) String() string {
s += "DumpStacks"
case rpcDeleteContainerState:
s += "DeleteContainerState"
case rpcUpdateContainer:
s += "UpdateContainer"
case rpcLifecycleNotification:
s += "LifecycleNotification"
default:
Expand Down Expand Up @@ -358,3 +361,8 @@ type containerGetPropertiesResponseV2 struct {
responseBase
Properties containerPropertiesV2
}

type updateContainerRequest struct {
requestBase
Resources string
}
10 changes: 10 additions & 0 deletions internal/gcs/resourcepaths.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package gcs

const (
// silo container resources paths
siloDeviceResourcePath string = "Container/Devices/Generic"
siloMappedDirectoryResourcePath string = "Container/MappedDirectories"
siloMappedPipeResourcePath string = "Container/MappedPipes"
siloMemoryResourcePath string = "Container/Memory/SizeInMB"
siloRegistryFlushStatePath string = "Container/RegistryFlushState"
)
1 change: 1 addition & 0 deletions internal/schema1/schema1.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ type GuestDefinedCapabilities struct {
SignalProcessSupported bool `json:",omitempty"`
DumpStacksSupported bool `json:",omitempty"`
DeleteContainerStateSupported bool `json:",omitempty"`
UpdateContainerSupported bool `json:",omitempty"`
}

// GuestConnectionInfo is the structure of an iterm return by a GuestConnection call on a utility VM
Expand Down
12 changes: 12 additions & 0 deletions internal/uvm/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package uvm

import (
"context"
)

func (uvm *UtilityVM) UpdateContainer(ctx context.Context, cid string, resources interface{}) error {
if uvm.gc == nil || !uvm.guestCaps.UpdateContainerSupported {
return nil
}
return uvm.gc.UpdateContainer(ctx, cid, resources)
}