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

che #9062: Adding property for setting workspace pod termination grace period for Kubernetes / OpenShift infrastructures #9118

Merged
merged 1 commit into from
Mar 20, 2018

Conversation

ibuziuk
Copy link
Member

@ibuziuk ibuziuk commented Mar 16, 2018

What does this PR do?

che #9062: Adding property for setting workspace pod termination grace period for Kubernetes / OpenShift infrastructures

What issues does this PR fix or reference?

#9062

Release Notes

Adding property for setting workspace pod termination grace period for Kubernetes / OpenShift infrastructures

Docs PR

eclipse-che/che-docs#376

@codenvy-ci
Copy link

Can one of the admins verify this patch?

2 similar comments
@codenvy-ci
Copy link

Can one of the admins verify this patch?

@codenvy-ci
Copy link

Can one of the admins verify this patch?

@ibuziuk
Copy link
Member Author

ibuziuk commented Mar 16, 2018

ci-test

@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. kind/task Internal things, technical debt, and to-do tasks to be performed. labels Mar 16, 2018
@@ -91,5 +95,8 @@ public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity)
uniqueNamesProvisioner.provision(k8sEnv, identity);
ramLimitProvisioner.provision(k8sEnv, identity);
securityContextProvisioner.provision(k8sEnv, identity);

// 4 stage - set Kubernetes pod termination grace period
podTerminationGracePeriodProvisioner.provision(k8sEnv, identity);
Copy link
Member

Choose a reason for hiding this comment

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

I'd say that it should be in 3 stage like restartPolicyRewriter and securityContextProvisioner.

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for the pointer will fix

public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity)
throws InfrastructureException {
for (Pod pod : k8sEnv.getPods().values()) {
if (!isTerminationGracePeriodSet(pod)) {
Copy link
Member

@sleshchenko sleshchenko Mar 19, 2018

Choose a reason for hiding this comment

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

Maybe it would be better to override user-defined grace period. And do not override only if the grace period is configured to 0.
If not then it makes sense to document it and maybe rename configuration property like default_termination_grace_period_sec.

I vote for overriding user-defined grace period.
@garagatyi @ibuziuk WDYT?

Choose a reason for hiding this comment

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

Not sure we should override the value specified by a user. What for? I opt for overriding only values that are not specified. About renaming I think current name is OK, and name with prefix default would be OK too.
In case we need to set it to 0, in any case, we will be able to add it as a separate flag later.

Copy link
Member

Choose a reason for hiding this comment

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

What for?

To be able to guarantee that workspace will be stopped(or start will be interrupted) in predictable time.

Choose a reason for hiding this comment

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

And what if user's app needs more time, e.g. 1 minute?

Copy link
Member

Choose a reason for hiding this comment

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

The situation is similar to the following: a user's container needs more time to start than workspace start timeout is configured.
Since removing of pods is the last phase of workspace stop, and we remove all pods asynchronously, I'm OK not to override a value defined by a user. But let's document it in che.properties.

Choose a reason for hiding this comment

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

+1 to document it. Let's start without rewriting user's timeouts and then we will figure out whether we need to change it

@@ -416,6 +416,13 @@ che.infra.kubernetes.ingress.annotations_json=NULL
che.infra.kubernetes.pod.security_context.run_as_user=NULL
che.infra.kubernetes.pod.security_context.fs_group=NULL

# Defines grace termination period for pods that will be created by Kubernetes / OpenShift infrastructures
#
# Grace termination period of Kubernetes / OpenShift pods defaults to 30 seconds, which results in
Copy link
Member

@sleshchenko sleshchenko Mar 19, 2018

Choose a reason for hiding this comment

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

Doc says defaults to 30 seconds but default value is

che.infra.kubernetes.pod.termination_grace_period_sec=0

Please check and sync these values

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

well, default to 0 is done deliberately and I think we should stick to it (which would significantly decrease time required for workspace stop on k8s / openshift). Probably I should just remove info about default k8s config, which you find misleading

@skabashnyuk
Copy link
Contributor

@eivantsov Should we add some changes in docs? WDYT?

import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment;

public class PodTerminationGracePeriodProvisioner implements ConfigurationProvisioner {

Choose a reason for hiding this comment

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

Please, add javadocs

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, will do

public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity)
throws InfrastructureException {
for (Pod pod : k8sEnv.getPods().values()) {
if (!isTerminationGracePeriodSet(pod)) {

Choose a reason for hiding this comment

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

Not sure we should override the value specified by a user. What for? I opt for overriding only values that are not specified. About renaming I think current name is OK, and name with prefix default would be OK too.
In case we need to set it to 0, in any case, we will be able to add it as a separate flag later.

@ghost
Copy link

ghost commented Mar 19, 2018

@ibuziuk
Copy link
Member Author

ibuziuk commented Mar 19, 2018

@eivantsov ok, thanks for the pointer - will add some docs

@ibuziuk
Copy link
Member Author

ibuziuk commented Mar 20, 2018

@eivantsov @skabashnyuk @sleshchenko PR has been updated. PR for docs eclipse-che/che-docs#376

Copy link
Member

@sleshchenko sleshchenko left a comment

Choose a reason for hiding this comment

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

LGTM 👍

…ce period for Kubernetes / OpenShift infrastructures

Signed-off-by: Ilya Buziuk <ibuziuk@redhat.com>
@ibuziuk ibuziuk merged commit 3039163 into eclipse-che:master Mar 20, 2018
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Mar 20, 2018
@benoitf benoitf added this to the 6.3.0 milestone Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants