beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kami...@apache.org
Subject [beam] branch master updated: Fix an issue with kubectl not being configured properly (#11906)
Date Wed, 03 Jun 2020 11:30:45 GMT
This is an automated email from the ASF dual-hosted git repository.

kamilwu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 7fca79b  Fix an issue with kubectl not being configured properly (#11906)
7fca79b is described below

commit 7fca79b0499ad6f1bb61f6f0b8ebb5aef6fa3783
Author: Kamil Wasilewski <kamil.wasilewski@polidea.com>
AuthorDate: Wed Jun 3 13:30:31 2020 +0200

    Fix an issue with kubectl not being configured properly (#11906)
---
 .test-infra/jenkins/CommonJobProperties.groovy               |  2 +-
 .../jenkins/job_PostCommit_BeamMetrics_Publish.groovy        |  5 +++--
 .test-infra/metrics/build.gradle                             | 12 +++++++++---
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/.test-infra/jenkins/CommonJobProperties.groovy b/.test-infra/jenkins/CommonJobProperties.groovy
index df0d83a..9b7f2f3 100644
--- a/.test-infra/jenkins/CommonJobProperties.groovy
+++ b/.test-infra/jenkins/CommonJobProperties.groovy
@@ -249,7 +249,7 @@ class CommonJobProperties {
   }
 
   static String getKubeconfigLocationForNamespace(def namespace) {
-    return '"$WORKSPACE/' + "config-${namespace}" + '"'
+    return '$WORKSPACE/' + "config-${namespace}"
   }
 
   /**
diff --git a/.test-infra/jenkins/job_PostCommit_BeamMetrics_Publish.groovy b/.test-infra/jenkins/job_PostCommit_BeamMetrics_Publish.groovy
index 629fd51..f8c459f 100644
--- a/.test-infra/jenkins/job_PostCommit_BeamMetrics_Publish.groovy
+++ b/.test-infra/jenkins/job_PostCommit_BeamMetrics_Publish.groovy
@@ -20,7 +20,7 @@ import CommonJobProperties as commonJobProperties
 import Kubernetes
 import PostcommitJobBuilder
 
-PostcommitJobBuilder.postCommitJob('beam_PostCommit_BeamMetrics_Publish', '',
+PostcommitJobBuilder.postCommitJob('beam_PostCommit_BeamMetrics_Publish', 'Run Beam Metrics
deployment',
   'Beam Metrics deployment', this) {
 
   description('Applies new configuration to Beam Metrics infrastructure.')
@@ -28,7 +28,8 @@ PostcommitJobBuilder.postCommitJob('beam_PostCommit_BeamMetrics_Publish',
'',
   // Set common parameters.
   commonJobProperties.setTopLevelMainJobProperties(delegate)
 
-  Kubernetes.create(delegate, 'config-metrics', '', 'metrics')
+  String kubeconfig = commonJobProperties.getKubeconfigLocationForNamespace('default')
+  Kubernetes.create(delegate, kubeconfig, '', 'metrics')
 
   steps {
     gradle {
diff --git a/.test-infra/metrics/build.gradle b/.test-infra/metrics/build.gradle
index 5eebd6a..ddab327 100644
--- a/.test-infra/metrics/build.gradle
+++ b/.test-infra/metrics/build.gradle
@@ -67,6 +67,8 @@ task buildAndPublishContainers(type: Exec) {
 // Applies new configuration to all resources labeled with `app=beammetrics`
 // and forces Kubernetes to re-pull images.
 task applyConfiguration() {
+  dependsOn buildAndPublishContainers
+
   doLast {
     assert grgit : 'Cannot use outside of git repository'
 
@@ -75,12 +77,17 @@ task applyConfiguration() {
       it.dateTime > ZonedDateTime.now().minusHours(6)
     }
 
+    // Older version of kubectl does not offer `rollout restart` command, therefore we scale
+    // deployments to 0 and then scale back to 1.
     if (!commitedChanges.isEmpty()) {
       exec {
         executable 'sh'
         args '-c', 'kubectl apply --selector=app=beammetrics --prune=true -Rf kubernetes
&& \
-          kubectl wait --selector=app=beammetrics --for=condition=available deployment &&
\
-          kubectl get --selector=app=beammetrics -o name deployments | xargs -r kubectl rollout
restart'
+          kubectl wait --selector=app=beammetrics --for=condition=available --timeout=5m
deployment && \
+          kubectl get --selector=app=beammetrics -o name deployments \
+          | xargs -r kubectl scale --replicas=0 && \
+          kubectl get --selector=app=beammetrics -o name deployments \
+          | xargs -r kubectl scale --replicas=1'
       }
     } else {
       println 'No changes committed since the last 6 hours.'
@@ -89,7 +96,6 @@ task applyConfiguration() {
 }
 
 task deploy {
-  dependsOn buildAndPublishContainers
   dependsOn applyConfiguration
 }
 


Mime
View raw message