Skip to content
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

bugfix: distinct init process exit and exec process exit #2347

Merged

Conversation

HusterWan
Copy link
Contributor

@HusterWan HusterWan commented Oct 23, 2018

Signed-off-by: Michael Wan zirenwan@gmail.com

Ⅰ. Describe what this PR did

Fix the process exit events not distinct the exec process exit and the container exit.

Now when a container exit we got events below:

2018-10-23T04:11:57.950502774-04:00 container die 33c6c770fa45fc45db7ebe64732cb623e365c67b9e7f30ea7f830410bbac0608 (exitCode=137, image=registry.hub.docker.com/library/centos:latest, name=33c6c7, org.label-schema.build-date=20180804, org.label-schema.license=GPLv2, org.label-schema.name=CentOS Base Image, org.label-schema.schema-version=1.0, org.label-schema.vendor=CentOS)
2018-10-23T04:11:58.138978923-04:00 container stop 33c6c770fa45fc45db7ebe64732cb623e365c67b9e7f30ea7f830410bbac0608 (image=registry.hub.docker.com/library/centos:latest, name=33c6c7, org.label-schema.build-date=20180804, org.label-schema.license=GPLv2, org.label-schema.name=CentOS Base Image, org.label-schema.schema-version=1.0, org.label-schema.vendor=CentOS)

when we execute an exec command, also got a container die event:

2018-10-23T04:14:23.727936681-04:00 container die 33c6c770fa45fc45db7ebe64732cb623e365c67b9e7f30ea7f830410bbac0608 (exitCode=137, image=registry.hub.docker.com/library/centos:latest, name=33c6c7, org.label-schema.build-date=20180804, org.label-schema.license=GPLv2, org.label-schema.name=CentOS Base Image, org.label-schema.schema-version=1.0, org.label-schema.vendor=CentOS)

Ⅱ. Does this pull request fix one issue?

none

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

add TestExecDieEventWorks, TestDieEventWorks cases

Ⅳ. Describe how to verify it

image

Ⅴ. Special notes for reviews

none

@codecov
Copy link

codecov bot commented Oct 23, 2018

Codecov Report

Merging #2347 into master will increase coverage by 1.51%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2347      +/-   ##
==========================================
+ Coverage   66.57%   68.09%   +1.51%     
==========================================
  Files         265      265              
  Lines       18209    18213       +4     
==========================================
+ Hits        12123    12402     +279     
+ Misses       4682     4389     -293     
- Partials     1404     1422      +18
Flag Coverage Δ
#criv1alpha1test 31.42% <100%> (+0.06%) ⬆️
#criv1alpha2test 35.69% <100%> (?)
#integrationtest 39.48% <100%> (ø) ⬆️
#nodee2etest 33.02% <100%> (+0.04%) ⬆️
#unittest 25.3% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
ctrd/client.go 66.92% <100%> (+1.05%) ⬆️
apis/server/utils.go 71.15% <0%> (-3.85%) ⬇️
daemon/mgr/container.go 59.21% <0%> (+0.43%) ⬆️
ctrd/container.go 59.76% <0%> (+1.42%) ⬆️
daemon/containerio/container_io.go 75.95% <0%> (+2.18%) ⬆️
ctrd/image.go 78.94% <0%> (+2.19%) ⬆️
cri/stream/runtime.go 70.58% <0%> (+2.35%) ⬆️
cri/v1alpha2/cri.go 68.56% <0%> (+3.02%) ⬆️
cri/stream/remotecommand/httpstream.go 46.63% <0%> (+3.1%) ⬆️
cri/v1alpha2/cri_utils.go 90.57% <0%> (+3.28%) ⬆️
... and 7 more

@pouchrobot pouchrobot added kind/bug This is bug report for project size/XS labels Oct 23, 2018
@allencloud allencloud added the need-test means a pull request should include related unit test or integration test label Oct 23, 2018
@allencloud
Copy link
Collaborator

Could you add some integration test to cover this kind of distinguish? @HusterWan

containerID = exitEvent.ContainerID
attributes["exitcode"] = strconv.Itoa(int(exitEvent.ExitStatus))
attributes["exitCode"] = strconv.Itoa(int(exitEvent.ExitStatus))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why to make this exitcode uppercase? Will this bring some compatible issues for some early adopters? @HusterWan

Copy link
Contributor Author

@HusterWan HusterWan Oct 23, 2018

Choose a reason for hiding this comment

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

I have confirmed with other adopters that used the events policy of pouchd, they had done compability with the exitCode.

So in order to stay with moby, i change the exitcode to exitCode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add the event document later

@HusterWan
Copy link
Contributor Author

HusterWan commented Oct 23, 2018

Could you add some integration test to cover this kind of distinguish? @HusterWan

@allencloud test cases added

@allencloud allencloud removed the need-test means a pull request should include related unit test or integration test label Oct 23, 2018
if exitEvent.ID == exitEvent.ContainerID {
action = "die"
} else {
action = "exec_die"
Copy link
Collaborator

Choose a reason for hiding this comment

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

In swagger.yml, we defined the /events API like the following:

  /events:
    get:
      summary: "Subscribe pouchd events to users"
      description: |
        Stream real-time events from the server.
        Report various object events of pouchd when something happens to them.
        Containers report these events: create`, `destroy`, `die`, `oom`, `pause`, `rename`, `resize`, `restart`, `start`, `stop`, `top`, `unpause`, and `update`
        Images report these events: `pull`, `untag`
        Volumes report these events: `create`, `destroy`
        Networks report these events: `create`, `connect`, `disconnect`, `destroy`

But here, I a afraid that we are adding another event type for container : exec's exec_die, right?
While this has not been collected in to API illustration. If we need to add this in swagger.yml, we should fix that. @HusterWan
And maybe we could have a very thorough thinking for the all workflow of the change: API, daemon, containerd, doc, test and some others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great advise, i will update this or soon

@allencloud
Copy link
Collaborator

LGTM until the API swagger.yml has updated if necessary.

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Oct 23, 2018
Signed-off-by: Michael Wan <zirenwan@gmail.com>
@allencloud
Copy link
Collaborator

I will merge this soon, while I still have some confusion.
Should your newly added upgrade feature be treated as one kind of event types?
@HusterWan

@allencloud allencloud merged commit 4106b91 into AliyunContainerService:master Oct 24, 2018
@HusterWan
Copy link
Contributor Author

I will merge this soon, while I still have some confusion.
Should your newly added upgrade feature be treated as one kind of event types?
@HusterWan

@allencloud I will support all import event types later that will help us know what pouchd has done during some abnormal situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project LGTM one maintainer or community participant agrees to merge the pull reuqest. size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants