mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-12 05:12:37 +00:00
Merge pull request #1759 from kata-containers/fix_update
Fix the issue that sandbox size is not right after update
This commit is contained in:
commit
b20dff8027
@ -1415,8 +1415,6 @@ func (c *Container) cgroupsCreate() (err error) {
|
|||||||
return fmt.Errorf("Could not create cgroup for %v: %v", c.state.CgroupPath, err)
|
return fmt.Errorf("Could not create cgroup for %v: %v", c.state.CgroupPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.config.Resources = resources
|
|
||||||
|
|
||||||
// Add shim into cgroup
|
// Add shim into cgroup
|
||||||
if c.process.Pid > 0 {
|
if c.process.Pid > 0 {
|
||||||
if err := cgroup.Add(cgroups.Process{Pid: c.process.Pid}); err != nil {
|
if err := cgroup.Add(cgroups.Process{Pid: c.process.Pid}); err != nil {
|
||||||
|
@ -1099,15 +1099,11 @@ func (s *Sandbox) addContainer(c *Container) error {
|
|||||||
// This should be called only when the sandbox is already created.
|
// This should be called only when the sandbox is already created.
|
||||||
// It will add new container config to sandbox.config.Containers
|
// It will add new container config to sandbox.config.Containers
|
||||||
func (s *Sandbox) CreateContainer(ctx context.Context, contConfig ContainerConfig) (VCContainer, error) {
|
func (s *Sandbox) CreateContainer(ctx context.Context, contConfig ContainerConfig) (VCContainer, error) {
|
||||||
// Create the container object, add devices to the sandbox's device-manager:
|
|
||||||
c, err := newContainer(ctx, s, &contConfig)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update sandbox config to include the new container's config
|
// Update sandbox config to include the new container's config
|
||||||
s.config.Containers = append(s.config.Containers, contConfig)
|
s.config.Containers = append(s.config.Containers, contConfig)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if len(s.config.Containers) > 0 {
|
if len(s.config.Containers) > 0 {
|
||||||
@ -1117,6 +1113,12 @@ func (s *Sandbox) CreateContainer(ctx context.Context, contConfig ContainerConfi
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// Create the container object, add devices to the sandbox's device-manager:
|
||||||
|
c, err := newContainer(ctx, s, &s.config.Containers[len(s.config.Containers)-1])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// create and start the container
|
// create and start the container
|
||||||
err = c.create(ctx)
|
err = c.create(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1434,9 +1436,9 @@ func (s *Sandbox) createContainers(ctx context.Context) error {
|
|||||||
span, ctx := s.trace(ctx, "createContainers")
|
span, ctx := s.trace(ctx, "createContainers")
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
for _, contConfig := range s.config.Containers {
|
for i := range s.config.Containers {
|
||||||
|
|
||||||
c, err := newContainer(ctx, s, &contConfig)
|
c, err := newContainer(ctx, s, &s.config.Containers[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user