Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

modified the way to terminate disable script with commandContext #1112

Conversation

yzaccc
Copy link
Contributor

@yzaccc yzaccc commented Feb 23, 2019

For hosit launchable, terminate the disable script when grace period is met;
for docker launchable, we do not need to terminate the disable process, just unblock the p2-preparer waiting for the disable script, and proceed killing the container.

Also not only for disable script, this commit enables p2 to have termination grace period on any step.

@yzaccc yzaccc force-pushed the yangzongkun/use-commandContext-to-terminate-disable-script branch 2 times, most recently from 2d34e88 to 1d07449 Compare February 26, 2019 00:32
pkg/docker/docker.go Show resolved Hide resolved
@@ -14,6 +15,8 @@ import (
. "github.com/anthonybishopric/gotcha"
)

var terminationGracePeriod = 1 * time.Hour
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm still not thrilled with us defaulting to 1 hour, but I think I lost that battle before I joined 😢

@yzaccc yzaccc requested a review from ausmith February 26, 2019 22:08
@@ -428,7 +431,7 @@ func TestDisableWithFailingDisable(t *testing.T) {
func TestDisableWithPassingDisable(t *testing.T) {
// This test's behavior is not dependent on whether the pod is a legacy or uuid pod
hl, _ := FakeHoistLaunchableForDirLegacyPod("successful_scripts_test_hoist_launchable")
err := hl.Disable()
err := hl.Disable(terminationGracePeriod)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see any tests that are exercising the new termination grace period (and I suggest you use a lower value than 1 hour when you test it 😉 ).

@yzaccc yzaccc force-pushed the yangzongkun/use-commandContext-to-terminate-disable-script branch from 1d07449 to 62200b9 Compare February 26, 2019 23:23
@yzaccc yzaccc force-pushed the yangzongkun/use-commandContext-to-terminate-disable-script branch from 62200b9 to ed91471 Compare February 26, 2019 23:32
@yzaccc yzaccc force-pushed the yangzongkun/use-commandContext-to-terminate-disable-script branch from ed91471 to e2ef222 Compare February 27, 2019 00:31
@yzaccc yzaccc requested review from ausmith and esuen February 27, 2019 00:42
Copy link
Collaborator

@ausmith ausmith left a comment

Choose a reason for hiding this comment

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

This seems fine with a nit, curious what @esuen thinks to make sure I didn't miss something though.

@@ -1,2 +1,4 @@
#!/bin/bash
echo "sleeping for 2 second to test termination grace period"
sleep 0.005
Copy link
Collaborator

Choose a reason for hiding this comment

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

The echo and sleep statements don't line up. I'm good with the test being so fast that the sleep can be super short, but can we make the echo match the reality?

@ausmith ausmith dismissed their stale review February 27, 2019 03:13

Test was added.

@yzaccc yzaccc force-pushed the yangzongkun/use-commandContext-to-terminate-disable-script branch from 8a96fec to c5cf45c Compare February 27, 2019 17:55
@yzaccc yzaccc requested a review from ausmith February 27, 2019 20:03
Copy link
Collaborator

@ausmith ausmith left a comment

Choose a reason for hiding this comment

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

LGTM

@yzaccc yzaccc merged commit de33d09 into square:master Feb 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants