Skip to content

Commit

Permalink
Add an option to ignore job status in helm task handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinathc committed Jun 4, 2019
1 parent 8ff093a commit fd6c4af
Show file tree
Hide file tree
Showing 16 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<artifactId>kronos</artifactId>
<groupId>com.cognitree</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>kronos</artifactId>
<groupId>com.cognitree</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>kronos</artifactId>
<groupId>com.cognitree</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>

<groupId>com.cognitree.kronos</groupId>
Expand Down
2 changes: 1 addition & 1 deletion executor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>kronos</artifactId>
<groupId>com.cognitree</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions extensions/embedded-hsql-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>com.cognitree.kronos.extensions</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>embedded-hsql-store</artifactId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>

<properties>
<hsqldb.version>2.4.1</hsqldb.version>
Expand Down
2 changes: 1 addition & 1 deletion extensions/helm-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>com.cognitree.kronos.extensions</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import hapi.chart.ChartOuterClass.Chart;
import hapi.release.ReleaseOuterClass.Release;
import hapi.release.StatusOuterClass.Status.Code;
import hapi.services.tiller.Tiller.GetReleaseStatusRequest;
import hapi.services.tiller.Tiller.GetReleaseStatusResponse;
import hapi.services.tiller.Tiller.InstallReleaseRequest;
import hapi.services.tiller.Tiller.*;
import hapi.services.tiller.Tiller.InstallReleaseRequest.Builder;
import io.fabric8.kubernetes.api.model.batch.Job;
import io.fabric8.kubernetes.api.model.batch.JobList;
Expand Down Expand Up @@ -81,11 +79,13 @@ public class HelmTaskHandler implements TaskHandler {
private static final String PROP_VALUES_FILE = "valuesFile";
private static final String PROP_TIMEOUT = "timeout";
private static final String PROP_MAX_WAIT_TIMEOUT = "maxWaitTimeout";
private static final String PROP_IGNORE_JOB_STATUS = "ignoreJobStatus";

private static final ChartType DEFAULT_CHART_TYPE = directory;
private static final String DEFAULT_RELEASE_PREFIX = "release";
private static final long DEFAULT_WAIT_TIMEOUT = 600L;
private static final long DEFAULT_HELM_TIMEOUT = 300L;
private static final boolean DEFAULT_IGNORE_JOB_STATUS = false;
private static final int SLEEP_INTERVAL_IN_SECONDS = 5;
private static final int MAX_RETRY_COUNT = 3;
private static final int RETRY_SLEEP_INTERVAL = 5000;
Expand Down Expand Up @@ -178,8 +178,9 @@ private TaskResult handle(Task task, String releaseName, int retryCount) {
release = releaseManager.install(requestBuilder, chart).get().getRelease();
logger.info("Successfully installed release: {} in namespace: {}", releaseName, release.getNamespace());
}
boolean ignoreJobStatus = (boolean) taskProperties.getOrDefault(PROP_IGNORE_JOB_STATUS, DEFAULT_IGNORE_JOB_STATUS);
waitForReleaseAndJobCompletion(releaseManager, kubernetesClient, releaseName,
release.getNamespace(), waitTimeout);
release.getNamespace(), waitTimeout, ignoreJobStatus);
logger.info("Successfully completed release: {} in namespace {}", releaseName,
release.getNamespace());
return new TaskResult(true, null, taskResult);
Expand All @@ -203,7 +204,8 @@ private TaskResult handle(Task task, String releaseName, int retryCount) {
}

private void waitForReleaseAndJobCompletion(ReleaseManager releaseManager, KubernetesClient kubernetesClient,
String releaseName, String namespace, long waitTimeout) throws Exception {
String releaseName, String namespace, long waitTimeout,
boolean ignoreJobStatus) throws Exception {
logger.info("Waiting for release {} in namespace {} to complete.", releaseName, namespace);

boolean deployed = false;
Expand Down Expand Up @@ -234,7 +236,12 @@ private void waitForReleaseAndJobCompletion(ReleaseManager releaseManager, Kuber
" in namespace " + namespace + " current state is: " + statusCode);
}
}
waitForJobCompletion(kubernetesClient, releaseName, namespace, waitTimeout);
if (ignoreJobStatus) {
logger.info("Task is configured to not wait for the completion" +
" of release {} in namespace {}", releaseName, namespace);
} else {
waitForJobCompletion(kubernetesClient, releaseName, namespace, waitTimeout);
}
}

private Code getHelmReleaseStatus(ReleaseManager releaseManager, String releaseName) throws Exception {
Expand Down Expand Up @@ -387,14 +394,14 @@ private Chart.Builder loadHelmChart(ChartType chartType, String chartPath) throw
case zip:
File zipFile = new File(chartPath);
ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipFile));
try (ZipInputStreamChartLoader zipInputStreamChartLoader = new ZipInputStreamChartLoader();) {
try (ZipInputStreamChartLoader zipInputStreamChartLoader = new ZipInputStreamChartLoader()) {
helmChart = zipInputStreamChartLoader.load(zipInputStream);
}
break;
case tape:
File tarFile = new File(chartPath);
TarInputStream tarInputStream = new TarInputStream(new FileInputStream(tarFile));
try (TapeArchiveChartLoader tapeArchiveChartLoader = new TapeArchiveChartLoader();) {
try (TapeArchiveChartLoader tapeArchiveChartLoader = new TapeArchiveChartLoader()) {
helmChart = tapeArchiveChartLoader.load(tarInputStream);
}
break;
Expand Down
2 changes: 1 addition & 1 deletion extensions/jdbc-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>com.cognitree.kronos.extensions</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion extensions/kafka-message-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>com.cognitree.kronos.extensions</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion extensions/kafka-queue/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>com.cognitree.kronos.extensions</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion extensions/mongo-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>com.cognitree.kronos.extensions</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<groupId>com.cognitree</groupId>
<artifactId>kronos</artifactId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>

<groupId>com.cognitree.kronos.extensions</groupId>
Expand Down
2 changes: 1 addition & 1 deletion extensions/shell-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>com.cognitree.kronos.extensions</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion extensions/spark-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>extensions</artifactId>
<groupId>com.cognitree.kronos.extensions</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<name>kronos</name>
<artifactId>kronos</artifactId>
<packaging>pom</packaging>
<version>2.2.3</version>
<version>2.2.4-RC1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
2 changes: 1 addition & 1 deletion scheduler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<artifactId>kronos</artifactId>
<groupId>com.cognitree</groupId>
<version>2.2.3</version>
<version>2.2.4-RC1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down

0 comments on commit fd6c4af

Please sign in to comment.