Skip to content

return prune data when context canceled#33979

Merged
cpuguy83 merged 1 commit intomoby:masterfrom
allencloud:return-prune-data-when-context-canceled
Jul 11, 2017
Merged

return prune data when context canceled#33979
cpuguy83 merged 1 commit intomoby:masterfrom
allencloud:return-prune-data-when-context-canceled

Conversation

@allencloud
Copy link
Contributor

@allencloud allencloud commented Jul 6, 2017

Signed-off-by: allencloud allen.sun@daocloud.io

This PR takes into user's cancel request when prune data into consideration. When context is canceled, docker daemon still returns the data which is already pruned.

Prune Object includes: container, network, image, volume, and build cache.

fixes #33957

- What I did

  1. make engine return prune data even if context is canceled.

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

/cc @mlaventure

@allencloud allencloud force-pushed the return-prune-data-when-context-canceled branch from 00888cf to 47c13aa Compare July 6, 2017 09:07
daemon/prune.go Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

This one can stay as before as nothing was altered yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, thanks. Updated now.

@allencloud allencloud force-pushed the return-prune-data-when-context-canceled branch 2 times, most recently from d842e14 to 5b54eb3 Compare July 6, 2017 09:53
Copy link
Contributor

@mlaventure mlaventure left a comment

Choose a reason for hiding this comment

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

LGTM

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this new error?
Why not if err == context.Cancelled?

Copy link
Member

Choose a reason for hiding this comment

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

This could also check context.DeadlineExceeded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your feedback. @cpuguy83
Currently I have updated the PR and only checked err == context.Cancelled. And if we also check context.DeadlineExceeded, what should we return, a report with nil, or a report with error?

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

I don't think think we need to add this new error here, but in any case the wording is a bit funky.
Maybe the prune operation was cancelled

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's right to return a cancelled error here since cancellation is just one reason why the context would be done.

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This sentence doesn't look complete.

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This sentence doesn't look complete.

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This sentence doesn't look complete.

@allencloud allencloud force-pushed the return-prune-data-when-context-canceled branch 4 times, most recently from c69a42b to 6f12a2b Compare July 7, 2017 02:55
Copy link
Member

Choose a reason for hiding this comment

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

Can be a debug

Copy link
Member

Choose a reason for hiding this comment

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

I see others are warnings as well...

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This is obvious from the return line, I don't think we need the comment explaining

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

This is obvious from the return line, I don't think we need the comment explaining

@allencloud allencloud force-pushed the return-prune-data-when-context-canceled branch 2 times, most recently from 4431087 to 88a3eeb Compare July 8, 2017 01:54
@allencloud
Copy link
Contributor Author

Thanks for your review again. @cpuguy83
I have updated that, PTAL.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

Left some questions / comments, thanks!

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

this is now returning a different error than before, because the err = daemon.traverseLocalVolumes() is now moved inside the if ...

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

related to my comment two lines below; this doesn't return if err == nil, correct?

Copy link
Contributor Author

@allencloud allencloud Jul 10, 2017

Choose a reason for hiding this comment

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

What you mentioned is right, I have updated this, Thanks a lot. @thaJeztah
PTAL

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

nit; "when" should probably be "if"

would it be enough to just mention "return true to stop network traverse"? or is "context cancelled" a special case?

daemon/prune.go Outdated
Copy link
Member

Choose a reason for hiding this comment

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

I see @cpuguy83 suggested "debug"; just wondering if changing from "warn" in the current code to "debug" is too big a change, and if "info" would be a better fit.

Not a show stopper, just thinking aloud

Copy link
Contributor

Choose a reason for hiding this comment

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

I think debug is fine. Not sure if that message being in the log by default has any benefits

Signed-off-by: allencloud <allen.sun@daocloud.io>
@allencloud allencloud force-pushed the return-prune-data-when-context-canceled branch from 88a3eeb to 87b4dc2 Compare July 10, 2017 02:06
@thaJeztah
Copy link
Member

hm, flaky? https://jenkins.dockerproject.org/job/Docker-PRs/44175/console

03:33:45 ----------------------------------------------------------------------
03:33:45 FAIL: docker_cli_swarm_test.go:1146: DockerSwarmSuite.TestSwarmLockUnlockCluster
03:33:45 
03:33:45 [d6209096216f9] waiting for daemon to start
03:33:45 [d6209096216f9] daemon started
03:33:45 
03:33:45 [df75e109fdee3] waiting for daemon to start
03:33:45 [df75e109fdee3] daemon started
03:33:45 
03:33:45 [ded4392fb23e8] waiting for daemon to start
03:33:45 [ded4392fb23e8] daemon started
03:33:45 
03:33:45 [df75e109fdee3] exiting daemon
03:33:45 [df75e109fdee3] waiting for daemon to start
03:33:45 [df75e109fdee3] daemon started
03:33:45 
03:33:45 [df75e109fdee3] exiting daemon
03:33:45 [d6209096216f9] exiting daemon
03:33:45 [d6209096216f9] waiting for daemon to start
03:33:45 [d6209096216f9] daemon started
03:33:45 
03:33:45 [ded4392fb23e8] exiting daemon
03:33:45 [ded4392fb23e8] waiting for daemon to start
03:33:45 [ded4392fb23e8] daemon started
03:33:45 
03:33:45 [df75e109fdee3] waiting for daemon to start
03:33:45 [df75e109fdee3] daemon started
03:33:45 
03:33:45 docker_cli_swarm_test.go:1192:
03:33:45     // d2 is now set to lock
03:33:45     checkSwarmUnlockedToLocked(c, d2)
03:33:45 docker_utils_test.go:471:
03:33:45     c.Assert(v, checker, args...)
03:33:45 ... obtained bool = false
03:33:45 ... expected bool = true
03:33:45 
03:33:45 [d6209096216f9] exiting daemon
03:33:45 [df75e109fdee3] exiting daemon
03:33:45 [ded4392fb23e8] exiting daemon
03:34:06 

@allencloud
Copy link
Contributor Author

Great to see all green. ☀️ 😄

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

@cpuguy83 PTAL

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@cpuguy83 cpuguy83 merged commit 73e8f56 into moby:master Jul 11, 2017
@allencloud allencloud deleted the return-prune-data-when-context-canceled branch July 11, 2017 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[question] how to deal partial success in prune API?

6 participants