Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Conversation

@Random-Liu
Copy link
Member

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

See comments

// Client holds the containerd container client.
// containerd.Container is a pointer underlying. New assignment won't affect
// the previous pointer, so simply lock around is enough.
type Client struct {
Copy link
Member

Choose a reason for hiding this comment

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

I like it.

id := cntr.ID
// Do not update the container when there is a removal in progress.
if status.Removing {
return fmt.Errorf("container %q is in removing state", id)
Copy link
Member

Choose a reason for hiding this comment

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

should this be an ignore or error?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could either ignore it or return error here. The reason I let it return error is that:

  1. The container is being removed, it only adds more race condition to update the resources at the same time;
  2. Docker has similar behavior https://github.com/moby/moby/blob/master/daemon/update.go#L52

// Update container spec. If the container is not started yet, updating
// spec makes sure that the resource limits are correct when start;
// if the container is already started, updating spec is still required,
// the spec will become our source of truth for resource limits.
Copy link
Member

Choose a reason for hiding this comment

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

cool!

return fmt.Errorf("failed to marshal spec %+v: %v", newSpec, err)
}
info.Spec = any
// TODO(random-liu): Add helper function in containerd to do the update.
Copy link
Member

Choose a reason for hiding this comment

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

good

Copy link
Member

Choose a reason for hiding this comment

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

i'll add this today

Copy link
Member

Choose a reason for hiding this comment

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

}
defer func() {
if retErr != nil {
// Reset spec on error.
Copy link
Member

Choose a reason for hiding this comment

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

Curious, what is the reason/rule here for resetting to the spec on error? Eg. failed to load container.. reset to spec?

Copy link
Member Author

Choose a reason for hiding this comment

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

The main reason is that: If the container is running, we updated the spec, but failed to update the real resource limit of the running task, there will be inconsistency between the spec and the running task if we don't recover the spec.

This is best effort anyway. cri-containerd dies before we recover the spec or before we update the task, there will still be inconsistency. We could reconcile it during restart, but I don't think it's super necessary.

if err != nil {
if errdefs.IsNotFound(err) {
// Task exited already.
return nil
Copy link
Member

Choose a reason for hiding this comment

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

good!

// Task exited already.
return nil
}
return fmt.Errorf("failed to get task: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

random thought here.. the term "task" may be very confusing to kubernetes users... Let's consider using "container" or "container state" instead of task in error messages we generate.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have many error messages include task now. :p We may want to address them all when we have better name for it. :)

@Random-Liu
Copy link
Member Author

@mikebrow Replied comments. :)

Copy link
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

/LGTM your call if you want to push this through now and do the TODO bringing in Michael's helper tomorrow or just wait for it.

Cheers.

@crosbymichael
Copy link
Member

No need to wait on it

@mikebrow mikebrow added the lgtm label Oct 3, 2017
@Random-Liu Random-Liu merged commit aec175c into containerd:master Oct 3, 2017
@Random-Liu Random-Liu deleted the fix-update-container-resources branch October 3, 2017 20:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants