-
Notifications
You must be signed in to change notification settings - Fork 944
feature: UpdateContainerResources of CRI Manager #1511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1511 +/- ##
===========================================
+ Coverage 16.88% 40.68% +23.79%
===========================================
Files 211 254 +43
Lines 14020 16647 +2627
===========================================
+ Hits 2367 6772 +4405
+ Misses 11490 9006 -2484
- Partials 163 869 +706
|
cri/v1alpha1/cri.go
Outdated
| containerID := r.GetContainerId() | ||
| container, err := c.ContainerMgr.Get(ctx, containerID) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to get container of %q: %v", containerID, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need the work of. 😄
cri/v1alpha1/cri.go
Outdated
|
|
||
| // Do not update the container when there is a removal in progress. | ||
| if container.State.Status == apitypes.StatusRemoving { | ||
| return nil, fmt.Errorf("container %q is in removing state", containerID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error is not so readable. How about cannot update container resource when it is in removing state?
| Resources: resources, | ||
| } | ||
| c.ContainerMgr.Update(ctx, containerID, updateConfig) | ||
| if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which err this line code is using? From resources, err := resourceToCriResource(r.GetLinux()) or c.ContainerMgr.Update(ctx, containerID, updateConfig)?
If it is the latter one, please add more to be err = c.ContainerMgr.Update(ctx, containerID, updateConfig), and in the next line of fmt.Errorf() to construct this with the specific error. Thanks a lot.
cri/v1alpha1/cri_utils.go
Outdated
| } | ||
|
|
||
| // resourceToCriResource converts OCILinuxResource to apitypes.Resources Object. | ||
| func resourceToCriResource(new *runtime.LinuxContainerResources) (apitypes.Resources, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the input parameter's naming is new? Quite strange, how about changing another new name, like resource or something like that.
77cbd41 to
cd3450e
Compare
cri/v1alpha1/cri_utils.go
Outdated
| } | ||
|
|
||
| // resourceToCriResource converts OCILinuxResource to apitypes.Resources Object. | ||
| func resourceToCriResource(newresource *runtime.LinuxContainerResources) apitypes.Resources { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the Camel-Case naming. s/newresource/newResource/g.
|
@allencloud Thank you for your patient guidance. Everything mentioned above has been resolved. |
| func (c *CriManager) UpdateContainerResources(ctx context.Context, r *runtime.UpdateContainerResourcesRequest) (*runtime.UpdateContainerResourcesResponse, error) { | ||
| return nil, fmt.Errorf("UpdateContainerResources Not Implemented Yet") | ||
| containerID := r.GetContainerId() | ||
| container, err := c.ContainerMgr.Get(ctx, containerID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if we need to add lock here for container.
cri/v1alpha2/cri.go
Outdated
| } | ||
|
|
||
| // cannot update container resource when it is in removing state | ||
| if container.State.Status == apitypes.StatusRemoving { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check here if we have already support StatusRemoving in container manager. @HusterWan
cri/v1alpha1/cri.go
Outdated
| } | ||
| err = c.ContainerMgr.Update(ctx, containerID, updateConfig) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to update resource for container %q with error: %v", containerID, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove with error
cri/v1alpha1/cri.go
Outdated
| defer container.Unlock() | ||
|
|
||
| // cannot update container resource when it is in removing state | ||
| if container.State.Status == apitypes.StatusRemoving { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this part into container_state.go
a807c6e to
390d95e
Compare
Signed-off-by: Starnop <[email protected]>
|
LGTM |
Signed-off-by: Starnop [email protected]
Ⅰ. Describe what this PR did
add feature: UpdateContainerResources of CRI Manager
Ⅱ. Does this pull request fix one issue?
None
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews