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

Remove containers grace period #686

Merged
merged 5 commits into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public class PodTemplate extends AbstractDescribableImpl<PodTemplate> implements

private PodTemplateToolLocation nodeProperties;

private Long terminationGracePeriodSeconds;

/**
* Persisted yaml fragment
*/
Expand Down Expand Up @@ -733,6 +735,14 @@ public void setPodRetention(PodRetention podRetention) {
this.podRetention = podRetention;
}

public Long getTerminationGracePeriodSeconds() {
return terminationGracePeriodSeconds;
}

public void setTerminationGracePeriodSeconds(Long terminationGracePeriodSeconds) {
this.terminationGracePeriodSeconds = terminationGracePeriodSeconds;
}

protected Object readResolve() {
if (containers == null) {
// upgrading from 0.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ public Pod build() {
builder.withNodeSelector(nodeSelector);
}

if (template.getTerminationGracePeriodSeconds() != null) {
builder.withTerminationGracePeriodSeconds(template.getTerminationGracePeriodSeconds());
}
builder.withContainers(containers.values().toArray(new Container[containers.size()]));

Long runAsUser = template.getRunAsUserAsLong();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud;
import org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil;
import org.csanchez.jenkins.plugins.kubernetes.PodTemplate;
import org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder;
import org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar;
import org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar;
import org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar;
Expand Down Expand Up @@ -160,6 +161,7 @@ private PodTemplate buildBusyboxTemplate(String label) {
// Create a busybox template
PodTemplate podTemplate = new PodTemplate();
podTemplate.setLabel(label);
podTemplate.setTerminationGracePeriodSeconds(0L);

ContainerTemplate containerTemplate = new ContainerTemplate("busybox", "busybox", "cat", "");
containerTemplate.setTtyEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void configureCloud() throws Exception {
.withCommand("cat").withTty(true).withWorkingDir("/home/jenkins/agent1").build();
String podName = "test-command-execution-" + RandomStringUtils.random(5, "bcdfghjklmnpqrstvwxz0123456789");
pod = client.pods().create(new PodBuilder().withNewMetadata().withName(podName)
.withLabels(getLabels(this, name)).endMetadata().withNewSpec().withContainers(c, d).withNodeSelector(Collections.singletonMap("kubernetes.io/os", "linux")).endSpec().build());
.withLabels(getLabels(this, name)).endMetadata().withNewSpec().withContainers(c, d).withNodeSelector(Collections.singletonMap("kubernetes.io/os", "linux")).withTerminationGracePeriodSeconds(0L).endSpec().build());
Copy link
Member

Choose a reason for hiding this comment

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

Fine here in tests.


System.out.println("Created pod: " + pod.getMetadata().getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private PodTemplate buildBusyboxTemplate(String label) {
// Create a busybox template
PodTemplate podTemplate = new PodTemplate();
podTemplate.setLabel(label);
podTemplate.setTerminationGracePeriodSeconds(0L);

ContainerTemplate containerTemplate = new ContainerTemplate("busybox", "busybox", "cat", "");
containerTemplate.setTtyEnabled(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ spec:
labels:
app: cascading-delete
spec:
terminationGracePeriodSeconds: 0
containers:
- name: ubuntu
image: ubuntu
Expand Down