Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #813 from diegs/cp-flag
Browse files Browse the repository at this point in the history
checkpointer: make grace period a flag.
  • Loading branch information
diegs authored Jan 2, 2018
2 parents ed5bc17 + 586fc8c commit e6fdc45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions cmd/checkpoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ const (

defaultRuntimeEndpoint = "unix:///var/run/dockershim.sock"
defaultRuntimeRequestTimeout = 2 * time.Minute
defaultCheckpointGracePeriod = 1 * time.Minute
)

var (
lockfilePath string
kubeconfigPath string
remoteRuntimeEndpoint string
runtimeRequestTimeout time.Duration
checkpointGracePeriod time.Duration
)

func init() {
Expand All @@ -35,6 +37,7 @@ func init() {
flag.Set("logtostderr", "true")
flag.StringVar(&remoteRuntimeEndpoint, "container-runtime-endpoint", defaultRuntimeEndpoint, "[Experimental] The endpoint of remote runtime service. Currently unix socket is supported on Linux, and tcp is supported on windows. Examples:'unix:///var/run/dockershim.sock', 'tcp://localhost:3735'")
flag.DurationVar(&runtimeRequestTimeout, "runtime-request-timeout", defaultRuntimeRequestTimeout, "Timeout of all runtime requests except long running request - pull, logs, exec and attach. When timeout exceeded, kubelet will cancel the request, throw out an error and retry later.")
flag.DurationVar(&checkpointGracePeriod, "checkpoint-grace-period", defaultCheckpointGracePeriod, "Grace period for cleaning up checkpoints when the parent pod is deleted. Non-zero values are helpful for accommodating control plane eventual consistency.")
}

func main() {
Expand Down Expand Up @@ -69,6 +72,7 @@ func main() {
KubeConfig: kubeConfig,
RemoteRuntimeEndpoint: remoteRuntimeEndpoint,
RuntimeRequestTimeout: runtimeRequestTimeout,
CheckpointGracePeriod: checkpointGracePeriod,
}); err != nil {
glog.Fatalf("Error starting checkpointer: %v", err)
}
Expand Down
12 changes: 8 additions & 4 deletions pkg/checkpoint/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ const (
shouldCheckpoint = "true"
podSourceFile = "file"

defaultPollingFrequency = 5 * time.Second
defaultCheckpointTimeout = 1 * time.Minute
defaultCheckpointGracePeriod = 1 * time.Minute
defaultPollingFrequency = 5 * time.Second
defaultCheckpointTimeout = 1 * time.Minute
)

var (
lastCheckpoint time.Time
checkpointGracePeriod = defaultCheckpointGracePeriod
checkpointGracePeriod time.Duration
)

// Options defines the parameters that are required to start the checkpointer.
Expand All @@ -45,6 +44,9 @@ type Options struct {
RemoteRuntimeEndpoint string
// RuntimeRequestTimeout is the timeout that is used for requests to the RemoteRuntimeEndpoint.
RuntimeRequestTimeout time.Duration
// CheckpointGracePeriod is the timeout that is used for cleaning up checkpoints when the parent
// pod is deleted.
CheckpointGracePeriod time.Duration
}

// CheckpointerPod holds information about this checkpointer pod.
Expand Down Expand Up @@ -82,6 +84,8 @@ func Run(opts Options) error {
return fmt.Errorf("failed to connect to CRI server: %v", err)
}

checkpointGracePeriod = opts.CheckpointGracePeriod

cp := &checkpointer{
apiserver: apiserver,
kubelet: kubelet,
Expand Down
2 changes: 2 additions & 0 deletions pkg/checkpoint/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var (
)

func init() {
checkpointGracePeriod = time.Second

bools := []bool{true, false}
for _, apiAvailable := range bools {
for _, apiParent := range bools {
Expand Down

0 comments on commit e6fdc45

Please sign in to comment.