From 567bd6aa62c811044534aeaca02e4dc01957b9ac Mon Sep 17 00:00:00 2001 From: Patrik Greco Date: Sun, 23 May 2021 16:31:03 +0200 Subject: [PATCH] refactor(igor): Rename master to controller This change renames master to controller. The reasoning behind this change is that none of the services seems to be using that terminology anymore. Changing the terminology in Igor to something that at least some of the services uses makes it easier to understand what's being referenced. All externally accessible APIs with the old terminology are marked as deprecated and will use the new functions until the deprecated functions are finally removed. This to remain backward compatible. --- .../spinnaker/igor/build/BuildCache.java | 53 ++--- .../igor/config/BuildServerProperties.java | 13 +- .../history/model/GenericBuildContent.java | 14 ++ .../igor/service/BuildOperations.java | 4 +- .../igor/travis/TravisBuildMonitor.java | 67 ++++--- .../spinnaker/igor/travis/TravisCache.java | 24 +-- ...visMasters.java => TravisControllers.java} | 2 +- .../igor/travis/config/TravisConfig.java | 12 +- .../igor/travis/config/TravisProperties.java | 18 +- .../igor/travis/service/TravisService.java | 2 +- .../igor/travis/TravisBuildMonitorSpec.groovy | 72 +++---- igor-web/config/igor.yml | 2 +- .../spinnaker/igor/admin/AdminController.java | 4 +- .../igor/build/BuildController.groovy | 124 ++++++++---- .../igor/build/InfoController.groovy | 36 ++-- .../igor/config/BitBucketConfig.groovy | 6 +- .../igor/config/BitBucketProperties.groovy | 2 +- .../spinnaker/igor/config/GitHubConfig.groovy | 6 +- .../igor/config/GitHubProperties.groovy | 2 +- .../spinnaker/igor/config/GitLabConfig.java | 6 +- .../igor/config/GitLabProperties.java | 2 +- .../spinnaker/igor/config/GitlabCiConfig.java | 12 +- .../igor/config/GitlabCiProperties.java | 18 +- .../igor/config/JenkinsConfig.groovy | 10 +- .../igor/config/JenkinsProperties.groovy | 13 +- .../spinnaker/igor/config/StashConfig.groovy | 8 +- .../igor/config/StashProperties.groovy | 2 +- .../igor/config/WerckerConfig.groovy | 10 +- .../igor/config/WerckerProperties.groovy | 10 + .../exceptions/ArtifactNotFoundException.java | 4 +- .../igor/gitlabci/GitlabCiBuildMonitor.java | 53 ++--- .../igor/history/model/BuildContent.groovy | 2 +- .../igor/jenkins/JenkinsBuildMonitor.groovy | 60 +++--- .../spinnaker/igor/jenkins/JenkinsCache.java | 42 ++-- ...sters.groovy => JenkinsControllers.groovy} | 2 +- .../igor/jenkins/service/JenkinsService.java | 6 +- .../igor/scm/ScmInfoController.groovy | 44 ++-- .../scm/bitbucket/CommitController.groovy | 12 +- ...ster.groovy => BitBucketController.groovy} | 8 +- .../igor/scm/github/CommitController.groovy | 12 +- ...bMaster.groovy => GitHubController.groovy} | 4 +- .../igor/scm/gitlab/CommitController.java | 18 +- ...itLabMaster.java => GitLabController.java} | 6 +- .../igor/scm/stash/CommitController.groovy | 12 +- ...shMaster.groovy => StashController.groovy} | 4 +- .../igor/wercker/WerckerBuildMonitor.groovy | 70 +++---- .../spinnaker/igor/wercker/WerckerCache.java | 72 +++---- .../igor/wercker/WerckerService.groovy | 8 +- .../igor/concourse/ConcourseBuildMonitor.java | 6 +- .../igor/concourse/ConcourseController.java | 28 +-- .../concourse/service/ConcourseService.java | 7 +- .../igor/config/ConcourseConfig.java | 16 +- .../igor/config/ConcourseProperties.java | 13 ++ .../spinnaker/igor/config/IgorConfig.java | 2 +- .../health/EchoServiceHealthIndicator.java | 2 +- ...Master.java => AbstractScmController.java} | 4 +- .../igor/scm/ManagedDeliveryScmService.java | 55 ++--- .../{ScmMaster.java => ScmController.java} | 2 +- .../igor/build/BuildCacheSpec.groovy | 62 +++--- .../igor/build/BuildControllerSpec.groovy | 188 +++++++++++++++++- .../igor/build/InfoControllerSpec.groovy | 59 +++--- .../gitlabci/GitlabCiBuildMonitorSpec.groovy | 34 ++-- .../jenkins/JenkinsBuildMonitorSpec.groovy | 38 ++-- .../igor/jenkins/JenkinsCacheSpec.groovy | 62 +++--- .../scm/ManagedDeliveryScmServiceSpec.groovy | 6 +- .../igor/scm/ScmInfoControllerSpec.groovy | 31 ++- .../scm/bitbucket/CommitControllerSpec.groovy | 4 +- .../scm/github/CommitControllerSpec.groovy | 4 +- ...pec.groovy => GitHubControllerSpec.groovy} | 10 +- .../scm/gitlab/CommitControllerSpec.groovy | 7 +- .../scm/stash/CommitControllerSpec.groovy | 4 +- .../scm/stash/client/StashClientSpec.groovy | 6 +- .../wercker/WerckerBuildMonitorSpec.groovy | 36 ++-- .../igor/wercker/WerckerCacheSpec.groovy | 23 +-- .../igor/wercker/WerckerClientSpec.groovy | 2 +- .../igor/wercker/WerckerServiceSpec.groovy | 8 +- .../concourse/ConcourseBuildMonitorTest.java | 2 +- 77 files changed, 1022 insertions(+), 692 deletions(-) rename igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/client/{TravisMasters.java => TravisControllers.java} (96%) rename igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/client/{JenkinsMasters.groovy => JenkinsControllers.groovy} (96%) rename igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/client/{BitBucketMaster.groovy => BitBucketController.groovy} (91%) rename igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/client/{GitHubMaster.groovy => GitHubController.groovy} (95%) rename igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/client/{GitLabMaster.java => GitLabController.java} (83%) rename igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/client/{StashMaster.groovy => StashController.groovy} (95%) rename igor-web/src/main/java/com/netflix/spinnaker/igor/scm/{AbstractScmMaster.java => AbstractScmController.java} (93%) rename igor-web/src/main/java/com/netflix/spinnaker/igor/scm/{ScmMaster.java => ScmController.java} (96%) rename igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/client/{GitHubMasterSpec.groovy => GitHubControllerSpec.groovy} (83%) diff --git a/igor-core/src/main/java/com/netflix/spinnaker/igor/build/BuildCache.java b/igor-core/src/main/java/com/netflix/spinnaker/igor/build/BuildCache.java index ef90ac03d..9bd7a9cbc 100644 --- a/igor-core/src/main/java/com/netflix/spinnaker/igor/build/BuildCache.java +++ b/igor-core/src/main/java/com/netflix/spinnaker/igor/build/BuildCache.java @@ -43,10 +43,10 @@ public BuildCache( this.igorConfigurationProperties = igorConfigurationProperties; } - public List getJobNames(String master) { + public List getJobNames(String controller) { List jobs = new ArrayList<>(); redisClientDelegate.withKeyScan( - baseKey() + ":completed:" + master + ":*", + baseKey() + ":completed:" + controller + ":*", 1000, page -> jobs.addAll( @@ -71,8 +71,8 @@ public List getTypeaheadResults(String search) { return results; } - public int getLastBuild(String master, String job, boolean running) { - String key = makeKey(master, job, running); + public int getLastBuild(String controller, String job, boolean running) { + String key = makeKey(controller, job, running); return redisClientDelegate.withCommandsClient( c -> { if (!c.exists(key)) { @@ -82,8 +82,8 @@ public int getLastBuild(String master, String job, boolean running) { }); } - public Long getTTL(String master, String job) { - final String key = makeKey(master, job); + public Long getTTL(String controller, String job) { + final String key = makeKey(controller, job); return getTTL(key); } @@ -101,17 +101,18 @@ public void setTTL(String key, int ttl) { }); } - public void setLastBuild(String master, String job, int lastBuild, boolean building, int ttl) { + public void setLastBuild( + String controller, String job, int lastBuild, boolean building, int ttl) { if (!building) { - setBuild(makeKey(master, job), lastBuild, false, master, job, ttl); + setBuild(makeKey(controller, job), lastBuild, false, controller, job, ttl); } - storeLastBuild(makeKey(master, job, building), lastBuild, ttl); + storeLastBuild(makeKey(controller, job, building), lastBuild, ttl); } - public List getDeprecatedJobNames(String master) { + public List getDeprecatedJobNames(String controller) { List jobs = new ArrayList<>(); redisClientDelegate.withKeyScan( - baseKey() + ":" + master + ":*", + baseKey() + ":" + controller + ":*", 1000, page -> jobs.addAll( @@ -122,8 +123,8 @@ public List getDeprecatedJobNames(String master) { return jobs; } - public Map getDeprecatedLastBuild(String master, String job) { - String key = makeKey(master, job); + public Map getDeprecatedLastBuild(String controller, String job) { + String key = makeKey(controller, job); Map result = redisClientDelegate.withCommandsClient( c -> { @@ -144,10 +145,10 @@ public Map getDeprecatedLastBuild(String master, String job) { return converted; } - public List> getTrackedBuilds(String master) { + public List> getTrackedBuilds(String controller) { List> builds = new ArrayList<>(); redisClientDelegate.withKeyScan( - baseKey() + ":track:" + master + ":*", + baseKey() + ":track:" + controller + ":*", 1000, page -> builds.addAll( @@ -157,8 +158,8 @@ public List> getTrackedBuilds(String master) { return builds; } - public void setTracking(String master, String job, int buildId, int ttl) { - String key = makeTrackKey(master, job, buildId); + public void setTracking(String controller, String job, int buildId, int ttl) { + String key = makeTrackKey(controller, job, buildId); redisClientDelegate.withCommandsClient( c -> { c.set(key, "marked as running"); @@ -166,8 +167,8 @@ public void setTracking(String master, String job, int buildId, int ttl) { setTTL(key, ttl); } - public void deleteTracking(String master, String job, int buildId) { - String key = makeTrackKey(master, job, buildId); + public void deleteTracking(String controller, String job, int buildId) { + String key = makeTrackKey(controller, job, buildId); redisClientDelegate.withCommandsClient( c -> { c.del(key); @@ -182,7 +183,7 @@ private static Map getTrackedBuild(String key) { } private void setBuild( - String key, int lastBuild, boolean building, String master, String job, int ttl) { + String key, int lastBuild, boolean building, String controller, String job, int ttl) { redisClientDelegate.withCommandsClient( c -> { c.hset(key, "lastBuildLabel", Integer.toString(lastBuild)); @@ -199,17 +200,17 @@ private void storeLastBuild(String key, int lastBuild, int ttl) { setTTL(key, ttl); } - protected String makeKey(String master, String job) { - return baseKey() + ":" + master + ":" + job.toUpperCase() + ":" + job; + protected String makeKey(String controller, String job) { + return baseKey() + ":" + controller + ":" + job.toUpperCase() + ":" + job; } - protected String makeKey(String master, String job, boolean running) { + protected String makeKey(String controller, String job, boolean running) { String buildState = running ? "running" : "completed"; - return baseKey() + ":" + buildState + ":" + master + ":" + job.toUpperCase() + ":" + job; + return baseKey() + ":" + buildState + ":" + controller + ":" + job.toUpperCase() + ":" + job; } - protected String makeTrackKey(String master, String job, int buildId) { - return baseKey() + ":track:" + master + ":" + job.toUpperCase() + ":" + job + ":" + buildId; + protected String makeTrackKey(String controller, String job, int buildId) { + return baseKey() + ":track:" + controller + ":" + job.toUpperCase() + ":" + job + ":" + buildId; } private static String extractJobName(String key) { diff --git a/igor-core/src/main/java/com/netflix/spinnaker/igor/config/BuildServerProperties.java b/igor-core/src/main/java/com/netflix/spinnaker/igor/config/BuildServerProperties.java index 21cedeb1a..894194d44 100644 --- a/igor-core/src/main/java/com/netflix/spinnaker/igor/config/BuildServerProperties.java +++ b/igor-core/src/main/java/com/netflix/spinnaker/igor/config/BuildServerProperties.java @@ -26,7 +26,7 @@ * *
{@code
  * someProvider:
- *   masters:
+ *   controllers:
  *   - name: someProvider-host1
  *     address: https://foo.com/api
  *     permissions:
@@ -46,10 +46,19 @@ public interface BuildServerProperties {
   /**
    * Returns a list of the build service hosts configured with this provider
    *
+   * @deprecated
    * @return The build service hosts
    */
+  @Deprecated(forRemoval = true)
   List getMasters();
 
+  /**
+   * Returns a list of the build service hosts configured with this provider
+   *
+   * @return The build service hosts
+   */
+  List getControllers();
+
   /** Interface for representing the properties of a specific build service host */
   interface Host {
     /**
@@ -75,7 +84,7 @@ interface Host {
      *
      * 
{@code
      * someProvider:
-     *   masters:
+     *   controllers:
      *   - name: someProvider-host1
      *     address: https://foo.com/api
      *     permissions:
diff --git a/igor-core/src/main/java/com/netflix/spinnaker/igor/history/model/GenericBuildContent.java b/igor-core/src/main/java/com/netflix/spinnaker/igor/history/model/GenericBuildContent.java
index c89647d49..ccbe52a62 100644
--- a/igor-core/src/main/java/com/netflix/spinnaker/igor/history/model/GenericBuildContent.java
+++ b/igor-core/src/main/java/com/netflix/spinnaker/igor/history/model/GenericBuildContent.java
@@ -22,6 +22,20 @@
 @Data
 public class GenericBuildContent {
   private GenericProject project;
+
+  @Deprecated(forRemoval = true)
   private String master;
+
+  @Deprecated(forRemoval = true)
+  public String getMaster() {
+    return controller;
+  }
+
+  @Deprecated(forRemoval = true)
+  public void setMaster(String controller) {
+    this.controller = controller;
+  }
+
+  private String controller;
   private String type;
 }
diff --git a/igor-core/src/main/java/com/netflix/spinnaker/igor/service/BuildOperations.java b/igor-core/src/main/java/com/netflix/spinnaker/igor/service/BuildOperations.java
index 53928bd1f..b54d00f73 100644
--- a/igor-core/src/main/java/com/netflix/spinnaker/igor/service/BuildOperations.java
+++ b/igor-core/src/main/java/com/netflix/spinnaker/igor/service/BuildOperations.java
@@ -77,8 +77,8 @@ default void updateBuild(String jobName, Integer buildNumber, UpdatedBuild updat
 
   JobConfiguration getJobConfig(String jobName);
 
-  default Object queuedBuild(String master, int item) {
+  default Object queuedBuild(String controller, int item) {
     throw new UnsupportedOperationException(
-        String.format("Queued builds are not supported for build service %s", master));
+        String.format("Queued builds are not supported for build service %s", controller));
   }
 }
diff --git a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/TravisBuildMonitor.java b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/TravisBuildMonitor.java
index c638eab30..e45b62ac9 100644
--- a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/TravisBuildMonitor.java
+++ b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/TravisBuildMonitor.java
@@ -99,36 +99,36 @@ public TravisBuildMonitor(
   public void poll(boolean sendEvents) {
     buildServices
         .getServiceNames(BuildServiceProvider.TRAVIS)
-        .forEach(master -> pollSingle(new PollContext(master, !sendEvents)));
+        .forEach(controller -> pollSingle(new PollContext(controller, !sendEvents)));
   }
 
   @Override
   protected BuildPollingDelta generateDelta(PollContext ctx) {
     final Instant startTime = Instant.now();
-    final String master = ctx.partitionName;
-    final TravisService travisService = (TravisService) buildServices.getService(master);
+    final String controller = ctx.partitionName;
+    final TravisService travisService = (TravisService) buildServices.getService(controller);
 
     List builds =
         travisService.getLatestBuilds().stream()
-            .flatMap(build -> createBuildDelta(master, travisService, build))
+            .flatMap(build -> createBuildDelta(controller, travisService, build))
             .collect(Collectors.toList());
 
     log.info(
         "({}) generateDelta: Took {}ms to generate polling delta. Polled {} builds.",
-        kv("master", master),
+        kv("controller", controller),
         Duration.between(startTime, Instant.now()).toMillis(),
         builds.size());
 
-    return BuildPollingDelta.builder().master(master).items(builds).build();
+    return BuildPollingDelta.builder().controller(controller).items(builds).build();
   }
 
   @Override
   protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) {
     Instant startTime = Instant.now();
-    final String master = delta.getMaster();
-    final TravisService travisService = (TravisService) buildServices.getService(master);
+    final String controller = delta.getController();
+    final TravisService travisService = (TravisService) buildServices.getService(controller);
 
-    delta.getItems().forEach(item -> processBuild(sendEvents, master, travisService, item));
+    delta.getItems().forEach(item -> processBuild(sendEvents, controller, travisService, item));
 
     // Find id of processed builds
     Set processedBuilds =
@@ -139,7 +139,7 @@ protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) {
 
     // Check for tracked builds that have fallen out of the tracking window (can happen for long
     // running Travis jobs)
-    buildCache.getTrackedBuilds(master).stream()
+    buildCache.getTrackedBuilds(controller).stream()
         .mapToInt(build -> Integer.parseInt(build.get("buildId")))
         .filter(id -> !processedBuilds.contains(id))
         .mapToObj(travisService::getV3Build)
@@ -151,19 +151,19 @@ protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) {
         .peek(
             build ->
                 log.info(
-                    "(master={}) Found tracked build missing from the API: {}:{}:{}. If you see this message a lot, "
+                    "(controller={}) Found tracked build missing from the API: {}:{}:{}. If you see this message a lot, "
                         + "consider increasing the 'travis.{}.numberOfJobs' property.",
-                    master,
+                    controller,
                     build.branchedRepoSlug(),
                     build.getNumber(),
                     build.getState(),
-                    master))
-        .flatMap(build -> createBuildDelta(master, travisService, build))
-        .forEach(buildDelta -> processBuild(sendEvents, master, travisService, buildDelta));
+                    controller))
+        .flatMap(build -> createBuildDelta(controller, travisService, build))
+        .forEach(buildDelta -> processBuild(sendEvents, controller, travisService, buildDelta));
 
     log.info(
         "({}) commitDelta: Took {}ms to commit polling delta",
-        kv("master", master),
+        kv("controller", controller),
         Duration.between(startTime, Instant.now()).toMillis());
 
     if (travisProperties.isRepositorySyncEnabled()) {
@@ -171,15 +171,16 @@ protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) {
       travisService.syncRepos();
       log.info(
           "({}) repositorySync: Took {}ms to sync repositories",
-          kv("master", master),
+          kv("controller", controller),
           Duration.between(startTime, Instant.now()).toMillis());
     }
   }
 
   private Stream createBuildDelta(
-      String master, TravisService travisService, V3Build v3Build) {
+      String controller, TravisService travisService, V3Build v3Build) {
     int lastBuild =
-        buildCache.getLastBuild(master, v3Build.branchedRepoSlug(), v3Build.getState().isRunning());
+        buildCache.getLastBuild(
+            controller, v3Build.branchedRepoSlug(), v3Build.getState().isRunning());
     return Stream.of(v3Build)
         .filter(build -> !build.spinnakerTriggered())
         .filter(build -> build.getNumber() > lastBuild)
@@ -200,13 +201,13 @@ private Stream createBuildDelta(
   }
 
   private void processBuild(
-      boolean sendEvents, String master, TravisService travisService, BuildDelta item) {
+      boolean sendEvents, String controller, TravisService travisService, BuildDelta item) {
     V3Build build = item.getBuild();
     switch (build.getState()) {
       case created:
       case started:
         buildCache.setTracking(
-            master, build.getRepository().getSlug(), build.getId(), TRACKING_TTL);
+            controller, build.getRepository().getSlug(), build.getId(), TRACKING_TTL);
         break;
       case passed:
         if (!travisService.isLogReady(build)) {
@@ -214,21 +215,21 @@ private void processBuild(
         }
         if (build.getNumber()
             > buildCache.getLastBuild(
-                master, build.getRepository().getSlug(), build.getState().isRunning())) {
+                controller, build.getRepository().getSlug(), build.getState().isRunning())) {
           buildCache.setLastBuild(
-              master,
+              controller,
               build.getRepository().getSlug(),
               build.getNumber(),
               build.getState().isRunning(),
               buildCacheJobTTLSeconds());
           if (sendEvents) {
-            sendEventForBuild(item, build.getRepository().getSlug(), master);
+            sendEventForBuild(item, build.getRepository().getSlug(), controller);
           }
         }
 
         if (build.getNumber() > item.previousBuildNum) {
           buildCache.setLastBuild(
-              master,
+              controller,
               build.branchedRepoSlug(),
               build.getNumber(),
               build.getState().isRunning(),
@@ -236,13 +237,13 @@ private void processBuild(
         }
 
         if (sendEvents) {
-          sendEventForBuild(item, build.branchedRepoSlug(), master);
+          sendEventForBuild(item, build.branchedRepoSlug(), controller);
         }
         // Fall through
       case failed:
       case errored:
       case canceled:
-        buildCache.deleteTracking(master, build.getRepository().getSlug(), build.getId());
+        buildCache.deleteTracking(controller, build.getRepository().getSlug(), build.getId());
     }
   }
 
@@ -252,12 +253,12 @@ public String getName() {
   }
 
   private void sendEventForBuild(
-      final BuildDelta buildDelta, final String branchedSlug, String master) {
+      final BuildDelta buildDelta, final String branchedSlug, String controller) {
     if (!buildDelta.getBuild().spinnakerTriggered()) {
       if (echoService.isPresent()) {
         log.info(
             "({}) pushing event for: {}:{}",
-            kv("master", master),
+            kv("controller", controller),
             branchedSlug,
             buildDelta.getBuild().getNumber());
 
@@ -265,7 +266,7 @@ private void sendEventForBuild(
 
         GenericBuildContent content = new GenericBuildContent();
         content.setProject(project);
-        content.setMaster(master);
+        content.setController(controller);
         content.setType("travis");
 
         GenericBuildEvent event = new GenericBuildEvent();
@@ -276,7 +277,7 @@ private void sendEventForBuild(
         log.warn("Cannot send build event notification: Echo is not configured");
         log.info(
             "({}) unable to push event for: {}:{}",
-            kv("master", master),
+            kv("controller", controller),
             branchedSlug,
             buildDelta.getBuild().getNumber());
         registry.counter(missedNotificationId.withTag("monitor", getName())).increment();
@@ -290,7 +291,7 @@ private int buildCacheJobTTLSeconds() {
 
   @Override
   protected Integer getPartitionUpperThreshold(final String partition) {
-    return travisProperties.getMasters().stream()
+    return travisProperties.getControllers().stream()
         .filter(host -> host.getName().equals(partition))
         .findAny()
         .map(TravisProperties.TravisHost::getItemUpperThreshold)
@@ -300,7 +301,7 @@ protected Integer getPartitionUpperThreshold(final String partition) {
   @Getter
   @Builder
   public static class BuildPollingDelta implements PollingDelta {
-    private final String master;
+    private final String controller;
     private final List items;
   }
 
diff --git a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/TravisCache.java b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/TravisCache.java
index 9e2f506d4..5764bf485 100644
--- a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/TravisCache.java
+++ b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/TravisCache.java
@@ -47,11 +47,11 @@ public TravisCache(
     this.igorConfigurationProperties = igorConfigurationProperties;
   }
 
-  public Map getQueuedJob(String master, int queueNumber) {
+  public Map getQueuedJob(String controller, int queueNumber) {
     Map result =
         redisClientDelegate.withCommandsClient(
             c -> {
-              return c.hgetAll(makeKey(QUEUE_TYPE, master, queueNumber));
+              return c.hgetAll(makeKey(QUEUE_TYPE, controller, queueNumber));
             });
 
     if (result.isEmpty()) {
@@ -65,8 +65,8 @@ public Map getQueuedJob(String master, int queueNumber) {
     return converted;
   }
 
-  public int setQueuedJob(String master, int repositoryId, int requestId) {
-    String key = makeKey(QUEUE_TYPE, master, requestId);
+  public int setQueuedJob(String controller, int repositoryId, int requestId) {
+    String key = makeKey(QUEUE_TYPE, controller, requestId);
     redisClientDelegate.withCommandsClient(
         c -> {
           c.hset(key, "requestId", Integer.toString(requestId));
@@ -75,31 +75,31 @@ public int setQueuedJob(String master, int repositoryId, int requestId) {
     return requestId;
   }
 
-  public void removeQuededJob(String master, int queueId) {
+  public void removeQuededJob(String controller, int queueId) {
     redisClientDelegate.withCommandsClient(
         c -> {
-          c.del(makeKey(QUEUE_TYPE, master, queueId));
+          c.del(makeKey(QUEUE_TYPE, controller, queueId));
         });
   }
 
-  public void setJobLog(String master, int jobId, String log) {
-    String key = makeKey(LOG_TYPE, master, jobId);
+  public void setJobLog(String controller, int jobId, String log) {
+    String key = makeKey(LOG_TYPE, controller, jobId);
     redisClientDelegate.withCommandsClient(
         c -> {
           c.setex(key, LOG_EXPIRE_SECONDS, log);
         });
   }
 
-  public String getJobLog(String master, int jobId) {
-    String key = makeKey(LOG_TYPE, master, jobId);
+  public String getJobLog(String controller, int jobId) {
+    String key = makeKey(LOG_TYPE, controller, jobId);
     return redisClientDelegate.withCommandsClient(
         c -> {
           return c.get(key);
         });
   }
 
-  private String makeKey(String type, String master, int id) {
-    return baseKey() + ":" + type + ":" + master + ":" + id;
+  private String makeKey(String type, String controller, int id) {
+    return baseKey() + ":" + type + ":" + controller + ":" + id;
   }
 
   private String baseKey() {
diff --git a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/client/TravisMasters.java b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/client/TravisControllers.java
similarity index 96%
rename from igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/client/TravisMasters.java
rename to igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/client/TravisControllers.java
index 60f0cbb37..ffbebd97b 100644
--- a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/client/TravisMasters.java
+++ b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/client/TravisControllers.java
@@ -20,7 +20,7 @@
 import com.netflix.spinnaker.igor.travis.service.TravisService;
 import java.util.Map;
 
-public class TravisMasters {
+public class TravisControllers {
   private Map map;
 
   public Map getMap() {
diff --git a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/config/TravisConfig.java b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/config/TravisConfig.java
index 06333243d..249cdc988 100644
--- a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/config/TravisConfig.java
+++ b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/config/TravisConfig.java
@@ -57,7 +57,7 @@
 public class TravisConfig {
 
   @Bean
-  public Map travisMasters(
+  public Map travisControllers(
       BuildServices buildServices,
       TravisCache travisCache,
       IgorConfigurationProperties igorConfigurationProperties,
@@ -65,12 +65,12 @@ public Map travisMasters(
       ObjectMapper objectMapper,
       Optional artifactDecorator,
       CircuitBreakerRegistry circuitBreakerRegistry) {
-    log.info("creating travisMasters");
+    log.info("creating travisControllers");
 
-    Map travisMasters =
+    Map travisControllers =
         (travisProperties == null
                 ? new ArrayList()
-                : travisProperties.getMasters())
+                : travisProperties.getControllers())
             .stream()
                 .map(
                     host -> {
@@ -112,8 +112,8 @@ public Map travisMasters(
                     })
                 .collect(Collectors.toMap(TravisService::getGroupKey, Function.identity()));
 
-    buildServices.addServices(travisMasters);
-    return travisMasters;
+    buildServices.addServices(travisControllers);
+    return travisControllers;
   }
 
   public static TravisClient travisClient(String address, int timeout, ObjectMapper objectMapper) {
diff --git a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/config/TravisProperties.java b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/config/TravisProperties.java
index 6e79ab72c..c6adf9866 100644
--- a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/config/TravisProperties.java
+++ b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/config/TravisProperties.java
@@ -35,7 +35,8 @@ public class TravisProperties implements BuildServerProperties masters;
+  @Deprecated @Valid private List masters;
+  @Valid private List controllers;
   @Valid private List regexes;
   /**
    * Lets you customize the build message used when Spinnaker triggers builds in Travis. If you set
@@ -46,6 +47,19 @@ public class TravisProperties implements BuildServerProperties getMasters() {
+    return this.controllers;
+  }
+
+  @Deprecated(forRemoval = true)
+  public void setMasters(List controllers) {
+    log.warn(
+        "The 'travis.masters' property is no longer in use and the value will be ignored. "
+            + "The new option 'travis.controllers' will let you define controllers.");
+    this.controllers = controllers;
+  }
+
   @Deprecated
   public void setNewBuildGracePeriodSeconds(long newBuildGracePeriodSeconds) {
     log.warn(
@@ -80,7 +94,7 @@ public void setNumberOfRepositories(int numberOfRepositories) {
       log.warn(
           "The 'travis.numberOfRepositories' property is no longer in use and the value will be ignored. "
               + "If you want to limit the number of builds retrieved per polling cycle, you can use the property "
-              + "'travis.[master].numberOfJobs' (default: 100).");
+              + "'travis.[controller].numberOfJobs' (default: 100).");
       this.numberOfRepositories = numberOfRepositories;
     }
   }
diff --git a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/service/TravisService.java b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/service/TravisService.java
index 479b9ad9e..01001e1f5 100644
--- a/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/service/TravisService.java
+++ b/igor-monitor-travis/src/main/java/com/netflix/spinnaker/igor/travis/service/TravisService.java
@@ -508,7 +508,7 @@ public String getUrl(String repoSlug) {
   }
 
   @Override
-  public Map queuedBuild(String master, int queueId) {
+  public Map queuedBuild(String controller, int queueId) {
     Map queuedJob = travisCache.getQueuedJob(groupKey, queueId);
     Request requestResponse =
         travisClient.request(
diff --git a/igor-monitor-travis/src/test/groovy/com/netflix/spinnaker/igor/travis/TravisBuildMonitorSpec.groovy b/igor-monitor-travis/src/test/groovy/com/netflix/spinnaker/igor/travis/TravisBuildMonitorSpec.groovy
index 72bac96e6..9b5c11f14 100644
--- a/igor-monitor-travis/src/test/groovy/com/netflix/spinnaker/igor/travis/TravisBuildMonitorSpec.groovy
+++ b/igor-monitor-travis/src/test/groovy/com/netflix/spinnaker/igor/travis/TravisBuildMonitorSpec.groovy
@@ -40,14 +40,14 @@ class TravisBuildMonitorSpec extends Specification {
     EchoService echoService = Mock()
     TravisBuildMonitor travisBuildMonitor
 
-    String MASTER = "MASTER"
+    String CONTROLLER = "CONTROLLER"
     int CACHED_JOB_TTL_SECONDS = 172800
     int CACHED_JOB_TTL_DAYS = 2
 
     void setup() {
         def travisProperties = new TravisProperties(cachedJobTTLDays: CACHED_JOB_TTL_DAYS)
         def buildServices = new BuildServices()
-        buildServices.addServices([MASTER: travisService])
+        buildServices.addServices([CONTROLLER: travisService])
         travisBuildMonitor = new TravisBuildMonitor(
             new IgorConfigurationProperties(),
             new NoopRegistry(),
@@ -61,7 +61,7 @@ class TravisBuildMonitorSpec extends Specification {
             Mock(TaskScheduler)
         )
         travisService.isLogReady(_) >> true
-        buildCache.getTrackedBuilds(MASTER) >> []
+        buildCache.getTrackedBuilds(CONTROLLER) >> []
     }
 
     void 'flag a new build on master, but do not send event on repo if a newer build is present at repo level'() {
@@ -69,7 +69,7 @@ class TravisBuildMonitorSpec extends Specification {
         V3Repository repository = Mock(V3Repository)
 
         when:
-        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(MASTER))
+        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(CONTROLLER))
         travisBuildMonitor.commitDelta(buildPollingDelta, true)
 
         then:
@@ -81,11 +81,11 @@ class TravisBuildMonitorSpec extends Specification {
         build.repository >> repository
         repository.slug >> 'test-org/test-repo'
 
-        1 * travisService.getGenericBuild(build, true) >> TravisBuildConverter.genericBuild(build, MASTER)
-        1 * buildCache.getLastBuild(MASTER, 'test-org/test-repo/master', false) >> 3
-        1 * buildCache.getLastBuild(MASTER, 'test-org/test-repo', false) >> 5
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo/master', 4, false, CACHED_JOB_TTL_SECONDS)
-        0 * buildCache.setLastBuild(MASTER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * travisService.getGenericBuild(build, true) >> TravisBuildConverter.genericBuild(build, CONTROLLER)
+        1 * buildCache.getLastBuild(CONTROLLER, 'test-org/test-repo/master', false) >> 3
+        1 * buildCache.getLastBuild(CONTROLLER, 'test-org/test-repo', false) >> 5
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo/master', 4, false, CACHED_JOB_TTL_SECONDS)
+        0 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
 
         buildPollingDelta.items.size() == 1
         buildPollingDelta.items[0].branchedRepoSlug == 'test-org/test-repo/master'
@@ -98,7 +98,7 @@ class TravisBuildMonitorSpec extends Specification {
         V3Repository repository = Mock(V3Repository)
 
         when:
-        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(MASTER))
+        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(CONTROLLER))
         travisBuildMonitor.commitDelta(buildPollingDelta, true)
 
         then:
@@ -110,10 +110,10 @@ class TravisBuildMonitorSpec extends Specification {
         build.repository >> repository
         repository.slug >> 'test-org/test-repo'
 
-        1 * travisService.getGenericBuild(build, true) >> TravisBuildConverter.genericBuild(build, MASTER)
-        1 * buildCache.getLastBuild(MASTER, 'test-org/test-repo/my_branch', false) >> 3
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo/my_branch', 4, false, CACHED_JOB_TTL_SECONDS)
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * travisService.getGenericBuild(build, true) >> TravisBuildConverter.genericBuild(build, CONTROLLER)
+        1 * buildCache.getLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', false) >> 3
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
 
         1 * echoService.postEvent({
             it.content.project.name == "test-org/test-repo"
@@ -130,7 +130,7 @@ class TravisBuildMonitorSpec extends Specification {
         V3Repository repository = Mock(V3Repository)
 
         when:
-        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(MASTER))
+        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(CONTROLLER))
         travisBuildMonitor.commitDelta(buildPollingDelta, false)
 
         then:
@@ -138,9 +138,9 @@ class TravisBuildMonitorSpec extends Specification {
         build.branchedRepoSlug() >> "test-org/test-repo/my_branch"
         build.getNumber() >> 4
 
-        1 * buildCache.getLastBuild(MASTER, 'test-org/test-repo/my_branch', false) >> 3
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo/my_branch', 4, false, CACHED_JOB_TTL_SECONDS)
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * buildCache.getLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', false) >> 3
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
 
         build.jobs >> []
         build.repository >> repository
@@ -156,7 +156,7 @@ class TravisBuildMonitorSpec extends Specification {
         V3Repository repository = Mock(V3Repository)
 
         when:
-        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(MASTER))
+        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(CONTROLLER))
         travisBuildMonitor.commitDelta(buildPollingDelta, true)
 
         then:
@@ -172,15 +172,15 @@ class TravisBuildMonitorSpec extends Specification {
         buildDifferentBranch.jobs >> []
         buildDifferentBranch.repository >> repository
         repository.slug >> 'test-org/test-repo'
-        1 * travisService.getGenericBuild(build, true) >> TravisBuildConverter.genericBuild(build, MASTER)
-        1 * travisService.getGenericBuild(buildDifferentBranch, true) >> TravisBuildConverter.genericBuild(buildDifferentBranch, MASTER)
-        1 * buildCache.getLastBuild(MASTER, 'test-org/test-repo/my_branch', false) >> 2
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo/my_branch', 4, false, CACHED_JOB_TTL_SECONDS)
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo', 3, false, CACHED_JOB_TTL_SECONDS)
+        1 * travisService.getGenericBuild(build, true) >> TravisBuildConverter.genericBuild(build, CONTROLLER)
+        1 * travisService.getGenericBuild(buildDifferentBranch, true) >> TravisBuildConverter.genericBuild(buildDifferentBranch, CONTROLLER)
+        1 * buildCache.getLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', false) >> 2
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo', 3, false, CACHED_JOB_TTL_SECONDS)
 
-        1 * buildCache.getLastBuild(MASTER, 'test-org/test-repo/different_branch', false) >> 1
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo/different_branch', 3, false, CACHED_JOB_TTL_SECONDS)
+        1 * buildCache.getLastBuild(CONTROLLER, 'test-org/test-repo/different_branch', false) >> 1
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo/different_branch', 3, false, CACHED_JOB_TTL_SECONDS)
 
         1 * echoService.postEvent({
             it.content.project.name == "test-org/test-repo/my_branch" &&
@@ -218,25 +218,25 @@ class TravisBuildMonitorSpec extends Specification {
         repository.slug >> 'test-org/test-repo'
 
         when:
-        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(MASTER))
+        TravisBuildMonitor.BuildPollingDelta buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(CONTROLLER))
         travisBuildMonitor.commitDelta(buildPollingDelta, true)
 
         build.state = TravisBuildState.passed
-        buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(MASTER))
+        buildPollingDelta = travisBuildMonitor.generateDelta(new PollContext(CONTROLLER))
         travisBuildMonitor.commitDelta(buildPollingDelta, true)
 
         then:
         2 * travisService.getLatestBuilds() >>> [ [ build ], [] ]
-        1 * buildCache.setTracking(MASTER, build.getRepository().getSlug(), 1337, TravisBuildMonitor.TRACKING_TTL)
-        2 * buildCache.getTrackedBuilds(MASTER) >> [ [ buildId: "1337" ] ]
+        1 * buildCache.setTracking(CONTROLLER, build.getRepository().getSlug(), 1337, TravisBuildMonitor.TRACKING_TTL)
+        2 * buildCache.getTrackedBuilds(CONTROLLER) >> [ [ buildId: "1337" ] ]
         1 * travisService.getV3Build(1337) >> build
         2 * travisService.getGenericBuild(_, _) >> { V3Build b, boolean fetchLogs ->
-            TravisBuildConverter.genericBuild(b, MASTER)
+            TravisBuildConverter.genericBuild(b, CONTROLLER)
         }
-        1 * buildCache.getLastBuild(MASTER, 'test-org/test-repo/my_branch', true) >> 3
-        1 * buildCache.getLastBuild(MASTER, 'test-org/test-repo/my_branch', false) >> 3
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo/my_branch', 4, false, CACHED_JOB_TTL_SECONDS)
-        1 * buildCache.setLastBuild(MASTER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * buildCache.getLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', true) >> 3
+        1 * buildCache.getLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', false) >> 3
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo/my_branch', 4, false, CACHED_JOB_TTL_SECONDS)
+        1 * buildCache.setLastBuild(CONTROLLER, 'test-org/test-repo', 4, false, CACHED_JOB_TTL_SECONDS)
 
         1 * echoService.postEvent({
             it.content.project.name == "test-org/test-repo"
diff --git a/igor-web/config/igor.yml b/igor-web/config/igor.yml
index e170ec8b1..64faad136 100644
--- a/igor-web/config/igor.yml
+++ b/igor-web/config/igor.yml
@@ -44,7 +44,7 @@ redis:
 #  newBuildGracePeriodSeconds: 10
 #
 #  Travis names are prefixed with travis- inside igor.
-#  masters:
+#  controllers:
 #    - name: ci # This will show as travis-ci inside spinnaker.
 #      baseUrl: https://travis-ci.com
 #      address: https://api.travis-ci.com
diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/admin/AdminController.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/admin/AdminController.java
index 825de566e..7c07faff1 100644
--- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/admin/AdminController.java
+++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/admin/AdminController.java
@@ -47,8 +47,8 @@ public AdminController(Optional> pollingMonitors) {
    * Silently fast-forwards a poller. Fast-forwarding means that all pending cache state will be
    * polled and saved, but will not send Echo notifications.
    *
-   * 

By default all partitions (ex: masters) will be fast-forwarded, however specific partition - * names should be used whenever possible. + *

By default all partitions (ex: controllers) will be fast-forwarded, however specific + * partition names should be used whenever possible. * * @param monitorName The polling monitor name (ex: "DockerMonitor") * @param partition The partition name, if not provided, method will re-index the entire monitor diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/build/BuildController.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/build/BuildController.groovy index 0f22d2947..cf8e1aea8 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/build/BuildController.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/build/BuildController.groovy @@ -76,7 +76,7 @@ class BuildController { } @Nullable - private GenericBuild jobStatus(BuildOperations buildService, String master, String job, Integer buildNumber) { + private GenericBuild jobStatus(BuildOperations buildService, String controller, String job, Integer buildNumber) { GenericBuild build = buildService.getGenericBuild(job, buildNumber) if (!build) return null @@ -84,7 +84,7 @@ class BuildController { try { build.genericGitRevisions = buildService.getGenericGitRevisions(job, build) } catch (Exception e) { - log.error("could not get scm results for {} / {} / {}", kv("master", master), kv("job", job), kv("buildNumber", buildNumber), e) + log.error("could not get scm results for {} / {} / {}", kv("controller", controller), kv("job", job), kv("buildNumber", buildNumber), e) } if (artifactDecorator) { @@ -97,24 +97,24 @@ class BuildController { return build } - @RequestMapping(value = '/builds/status/{buildNumber}/{master:.+}/**') - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')") - GenericBuild getJobStatus(@PathVariable String master, @PathVariable + @RequestMapping(value = '/builds/status/{buildNumber}/{controller:.+}/**') + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'READ')") + GenericBuild getJobStatus(@PathVariable String controller, @PathVariable Integer buildNumber, HttpServletRequest request) { def job = ((String) request.getAttribute( HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).split('/').drop(5).join('/') - def buildService = getBuildService(master) - return jobStatus(buildService, master, job, buildNumber) + def buildService = getBuildService(controller) + return jobStatus(buildService, controller, job, buildNumber) } - @RequestMapping(value = '/builds/artifacts/{buildNumber}/{master:.+}/**') - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')") - List getBuildResults(@PathVariable String master, @PathVariable + @RequestMapping(value = '/builds/artifacts/{buildNumber}/{controller:.+}/**') + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'READ')") + List getBuildResults(@PathVariable String controller, @PathVariable Integer buildNumber, @Query("propertyFile") String propertyFile, HttpServletRequest request) { def job = ((String) request.getAttribute( HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).split('/').drop(5).join('/') - def buildService = getBuildService(master) - GenericBuild build = jobStatus(buildService, master, job, buildNumber) + def buildService = getBuildService(controller) + GenericBuild build = jobStatus(buildService, controller, job, buildNumber) if (build && buildService instanceof BuildProperties && artifactExtractor != null) { build.properties = buildService.getBuildProperties(job, build, propertyFile) return artifactExtractor.extractArtifacts(build) @@ -122,31 +122,31 @@ class BuildController { return Collections.emptyList() } - @RequestMapping(value = '/builds/queue/{master}/{item}') - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')") - Object getQueueLocation(@PathVariable String master, @PathVariable int item) { - def buildService = getBuildService(master) - return buildService.queuedBuild(master, item); + @RequestMapping(value = '/builds/queue/{controller}/{item}') + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'READ')") + Object getQueueLocation(@PathVariable String controller, @PathVariable int item) { + def buildService = getBuildService(controller) + return buildService.queuedBuild(controller, item); } - @RequestMapping(value = '/builds/all/{master:.+}/**') - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')") - List getBuilds(@PathVariable String master, HttpServletRequest request) { + @RequestMapping(value = '/builds/all/{controller:.+}/**') + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'READ')") + List getBuilds(@PathVariable String controller, HttpServletRequest request) { def job = ((String) request.getAttribute( HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).split('/').drop(4).join('/') - def buildService = getBuildService(master) + def buildService = getBuildService(controller) return buildService.getBuilds(job) } - @RequestMapping(value = "/masters/{name}/jobs/{jobName}/stop/{queuedBuild}/{buildNumber}", method = RequestMethod.PUT) - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'WRITE')") + @RequestMapping(value = "/controllers/{name}/jobs/{jobName}/stop/{queuedBuild}/{buildNumber}", method = RequestMethod.PUT) + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'WRITE')") String stop( - @PathVariable("name") String master, + @PathVariable("name") String controller, @PathVariable String jobName, @PathVariable String queuedBuild, @PathVariable Integer buildNumber) { - def buildService = getBuildService(master) + def buildService = getBuildService(controller) if (buildService instanceof JenkinsService) { // Jobs that haven't been started yet won't have a buildNumber // (They're still in the queue). We use 0 to denote that case @@ -172,10 +172,23 @@ class BuildController { "true" } - @RequestMapping(value = "/masters/{name}/jobs/**/update/{buildNumber}", method = RequestMethod.PATCH) - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'WRITE')") + @Deprecated(forRemoval = true) + @RequestMapping(value = "/masters/{name}/jobs/{jobName}/stop/{queuedBuild}/{buildNumber}", method = RequestMethod.PUT) + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'WRITE')") + String stopMaster( + @PathVariable("name") String controller, + @PathVariable String jobName, + @PathVariable String queuedBuild, + @PathVariable Integer buildNumber) { + stop(controller, jobName, queuedBuild, buildNumber) + + "true" + } + + @RequestMapping(value = "/controllers/{name}/jobs/**/update/{buildNumber}", method = RequestMethod.PATCH) + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'WRITE')") void update( - @PathVariable("name") String master, + @PathVariable("name") String controller, @PathVariable("buildNumber") Integer buildNumber, @RequestBody UpdatedBuild updatedBuild, HttpServletRequest request @@ -186,21 +199,33 @@ class BuildController { .dropRight(2) .join('/') - def buildService = getBuildService(master) + def buildService = getBuildService(controller) buildService.updateBuild(jobName, buildNumber, updatedBuild) } - @RequestMapping(value = '/masters/{name}/jobs/**', method = RequestMethod.PUT) - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'WRITE')") + @Deprecated(forRemoval = true) + @RequestMapping(value = "/masters/{name}/jobs/**/update/{buildNumber}", method = RequestMethod.PATCH) + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'WRITE')") + void updateMaster( + @PathVariable("name") String controller, + @PathVariable("buildNumber") Integer buildNumber, + @RequestBody UpdatedBuild updatedBuild, + HttpServletRequest request + ) { + update(controller, buildNumber, updatedBuild, request) + } + + @RequestMapping(value = '/controllers/{name}/jobs/**', method = RequestMethod.PUT) + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'WRITE')") ResponseEntity build( - @PathVariable("name") String master, + @PathVariable("name") String controller, @RequestParam Map requestParams, @RequestBody(required = false) String startTime, HttpServletRequest request) { def job = ((String) request.getAttribute( HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).split('/').drop(4).join('/') - String pendingKey = computePendingBuildKey(master, job, requestParams, startTime) + String pendingKey = computePendingBuildKey(controller, job, requestParams, startTime) // Initializing buildNumber to null will get it silently casted to "null" down the line String buildNumber = "" @@ -218,7 +243,7 @@ class BuildController { } try { - def buildService = getBuildService(master) + def buildService = getBuildService(controller) if (buildService instanceof JenkinsService) { def response JenkinsService jenkinsService = (JenkinsService) buildService @@ -243,7 +268,7 @@ class BuildController { } if (response.status != 201) { - throw new BuildJobError("Received a non-201 status when submitting job '${job}' to master '${master}'") + throw new BuildJobError("Received a non-201 status when submitting job '${job}' to controller '${controller}'") } log.info("Submitted build job '{}'", kv("job", job)) @@ -265,6 +290,17 @@ class BuildController { return ResponseEntity.of(Optional.of(buildNumber)) } + @Deprecated(forRemoval = true) + @RequestMapping(value = '/masters/{name}/jobs/**', method = RequestMethod.PUT) + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'WRITE')") + ResponseEntity buildMaster( + @PathVariable("name") String controller, + @RequestParam Map requestParams, + @RequestBody(required = false) String startTime, + HttpServletRequest request) { + return build(controller, requestParams, startTime, request) + } + static void validateJobParameters(JobConfig jobConfig, Map requestParams) { jobConfig.parameterDefinitionList.each { parameterDefinition -> String matchingParam = requestParams[parameterDefinition.name] @@ -278,8 +314,8 @@ class BuildController { } } - static String computePendingBuildKey(String master, String job, Map requestParams, String startTime) { - String key = master + ":" + job + ":" + AuthenticatedRequest.getSpinnakerExecutionId().orElse("NO_EXECUTION_ID") + static String computePendingBuildKey(String controller, String job, Map requestParams, String startTime) { + String key = controller + ":" + job + ":" + AuthenticatedRequest.getSpinnakerExecutionId().orElse("NO_EXECUTION_ID") if (startTime != null && !startTime.isEmpty()) { key = key + ":startTime=" + startTime @@ -292,15 +328,15 @@ class BuildController { return key; } - @RequestMapping(value = '/builds/properties/{buildNumber}/{fileName}/{master:.+}/**') - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')") + @RequestMapping(value = '/builds/properties/{buildNumber}/{fileName}/{controller:.+}/**') + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'READ')") Map getProperties( - @PathVariable String master, + @PathVariable String controller, @PathVariable Integer buildNumber, @PathVariable String fileName, HttpServletRequest request) { def job = ((String) request.getAttribute( HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE)).split('/').drop(6).join('/') - def buildService = getBuildService(master) + def buildService = getBuildService(controller) if (buildService instanceof BuildProperties) { BuildProperties buildProperties = (BuildProperties) buildService def genericBuild = buildService.getGenericBuild(job, buildNumber) @@ -309,10 +345,10 @@ class BuildController { return Collections.emptyMap() } - private BuildOperations getBuildService(String master) { - def buildService = buildServices.getService(master) + private BuildOperations getBuildService(String controller) { + def buildService = buildServices.getService(controller) if (buildService == null) { - throw new NotFoundException("Master '${master}' not found") + throw new NotFoundException("Controller '${controller}' not found") } return buildService } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/build/InfoController.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/build/InfoController.groovy index 9e9f2ddd7..da174ddbf 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/build/InfoController.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/build/InfoController.groovy @@ -53,9 +53,9 @@ class InfoController { @Autowired(required = false) GoogleCloudBuildProperties gcbProperties - @RequestMapping(value = '/masters', method = RequestMethod.GET) + @RequestMapping(value = '/controllers', method = RequestMethod.GET) @PostFilter("hasPermission(filterObject, 'BUILD_SERVICE', 'READ')") - List listMasters(@RequestParam(value = "type", defaultValue = "") String type) { + List listControllers(@RequestParam(value = "type", defaultValue = "") String type) { BuildServiceProvider providerType = (type == "") ? null : BuildServiceProvider.valueOf(type.toUpperCase()) //Filter by provider type if it is specified @@ -66,7 +66,15 @@ class InfoController { } } - @RequestMapping(value = '/buildServices', method = RequestMethod.GET) + @Deprecated(forRemoval = true) + @RequestMapping(value = '/masters', method = RequestMethod.GET) + @PostFilter("hasPermission(filterObject, 'BUILD_SERVICE', 'READ')") + List listMasters(@RequestParam(value = "type", defaultValue = "") String type) { + return listControllers(type) + } + + + @RequestMapping(value = '/buildServices', method = RequestMethod.GET) List getAllBuildServices() { List allBuildServices = new ArrayList<>(buildServices.allBuildServices) // GCB accounts are not part of com.netflix.spinnaker.igor.service.BuildServices class. @@ -77,12 +85,12 @@ class InfoController { return allBuildServices } - @RequestMapping(value = '/jobs/{master:.+}', method = RequestMethod.GET) - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')") - List getJobs(@PathVariable String master) { - def buildService = buildServices.getService(master) + @RequestMapping(value = '/jobs/{controller:.+}', method = RequestMethod.GET) + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'READ')") + List getJobs(@PathVariable String controller) { + def buildService = buildServices.getService(controller) if (buildService == null) { - throw new NotFoundException("Master '${master}' does not exist") + throw new NotFoundException("Controller '${controller}' does not exist") } if (buildService instanceof JenkinsService) { @@ -109,18 +117,18 @@ class InfoController { WerckerService werckerService = (WerckerService) buildService return werckerService.getJobs() } else { - return buildCache.getJobNames(master) + return buildCache.getJobNames(controller) } } - @RequestMapping(value = '/jobs/{master:.+}/**') - @PreAuthorize("hasPermission(#master, 'BUILD_SERVICE', 'READ')") - Object getJobConfig(@PathVariable String master, HttpServletRequest request) { + @RequestMapping(value = '/jobs/{controller:.+}/**') + @PreAuthorize("hasPermission(#controller, 'BUILD_SERVICE', 'READ')") + Object getJobConfig(@PathVariable String controller, HttpServletRequest request) { def job = (String) request.getAttribute( HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE).split('/').drop(3).join('/') - def service = buildServices.getService(master) + def service = buildServices.getService(controller) if (service == null) { - throw new NotFoundException("Master '${master}' does not exist") + throw new NotFoundException("Controller '${controller}' does not exist") } return service.getJobConfig(job) } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/BitBucketConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/BitBucketConfig.groovy index 3b86feaf3..946064c3e 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/BitBucketConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/BitBucketConfig.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.igor.config import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketClient -import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketMaster +import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketController import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger import com.squareup.okhttp.Credentials import groovy.transform.CompileStatic @@ -44,9 +44,9 @@ import javax.validation.Valid class BitBucketConfig { @Bean - BitBucketMaster bitBucketMaster(@Valid BitBucketProperties bitBucketProperties) { + BitBucketController bitBucketController(@Valid BitBucketProperties bitBucketProperties) { log.info "bootstrapping ${bitBucketProperties.baseUrl} as bitbucket" - new BitBucketMaster( + new BitBucketController( bitBucketClient: bitBucketClient(bitBucketProperties.baseUrl, bitBucketProperties.username, bitBucketProperties.password), baseUrl: bitBucketProperties.baseUrl) } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/BitBucketProperties.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/BitBucketProperties.groovy index fc797c7db..8bdf9c054 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/BitBucketProperties.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/BitBucketProperties.groovy @@ -23,7 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties import javax.validation.constraints.NotNull /** - * Helper class to map masters in properties file into a validated property map + * Helper class to map controllers in properties file into a validated property map */ @ConditionalOnProperty('bitbucket.base-url') @CompileStatic diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitHubConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitHubConfig.groovy index 14859d61e..6bb7273da 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitHubConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitHubConfig.groovy @@ -18,7 +18,7 @@ package com.netflix.spinnaker.igor.config import com.fasterxml.jackson.databind.ObjectMapper import com.netflix.spinnaker.igor.scm.github.client.GitHubClient -import com.netflix.spinnaker.igor.scm.github.client.GitHubMaster +import com.netflix.spinnaker.igor.scm.github.client.GitHubController import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger import groovy.transform.CompileStatic import groovy.util.logging.Slf4j @@ -45,9 +45,9 @@ import javax.validation.Valid class GitHubConfig { @Bean - GitHubMaster gitHubMasters(@Valid GitHubProperties gitHubProperties, ObjectMapper mapper) { + GitHubController gitHubControllers(@Valid GitHubProperties gitHubProperties, ObjectMapper mapper) { log.info "bootstrapping ${gitHubProperties.baseUrl} as github" - new GitHubMaster(gitHubClient: gitHubClient(gitHubProperties.baseUrl, gitHubProperties.accessToken, mapper), baseUrl: gitHubProperties.baseUrl) + new GitHubController(gitHubClient: gitHubClient(gitHubProperties.baseUrl, gitHubProperties.accessToken, mapper), baseUrl: gitHubProperties.baseUrl) } GitHubClient gitHubClient(String address, String accessToken, ObjectMapper mapper = new ObjectMapper()) { diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitHubProperties.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitHubProperties.groovy index 7cb8e7e5f..186c4fd6e 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitHubProperties.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitHubProperties.groovy @@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties import javax.validation.constraints.NotNull /** - * Helper class to map masters in properties file into a validated property map + * Helper class to map controllers in properties file into a validated property map */ @ConditionalOnProperty('github.base-url') @CompileStatic diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitLabConfig.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitLabConfig.java index 04df8ad3f..aeab2ae50 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitLabConfig.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitLabConfig.java @@ -17,7 +17,7 @@ package com.netflix.spinnaker.igor.config; import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabClient; -import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabMaster; +import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabController; import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger; import javax.validation.Valid; import org.slf4j.Logger; @@ -39,9 +39,9 @@ public class GitLabConfig { private static final Logger log = LoggerFactory.getLogger(GitLabConfig.class); @Bean - public GitLabMaster gitLabMasters(@Valid GitLabProperties gitLabProperties) { + public GitLabController gitLabControllers(@Valid GitLabProperties gitLabProperties) { log.info("bootstrapping {} as gitlab", gitLabProperties.getBaseUrl()); - return new GitLabMaster( + return new GitLabController( gitLabClient(gitLabProperties.getBaseUrl(), gitLabProperties.getPrivateToken()), gitLabProperties.getBaseUrl()); } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitLabProperties.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitLabProperties.java index 7d9779829..64b742c76 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitLabProperties.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitLabProperties.java @@ -21,7 +21,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.ConfigurationProperties; -/** Helper class to map masters in properties file into a validated property map. */ +/** Helper class to map controllers in properties file into a validated property map. */ @ConditionalOnProperty("gitlab.base-url") @ConfigurationProperties(prefix = "gitlab") public class GitLabProperties { diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitlabCiConfig.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitlabCiConfig.java index a8e731d8f..4166f3db3 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitlabCiConfig.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitlabCiConfig.java @@ -46,14 +46,14 @@ public class GitlabCiConfig { private static final Logger log = LoggerFactory.getLogger(GitlabCiConfig.class); @Bean - public Map gitlabCiMasters( + public Map gitlabCiControllers( BuildServices buildServices, final IgorConfigurationProperties igorConfigurationProperties, GitlabCiProperties gitlabCiProperties, ObjectMapper objectMapper) { - log.info("creating gitlabCiMasters"); - Map gitlabCiMasters = - gitlabCiProperties.getMasters().stream() + log.info("creating gitlabCiControllers"); + Map gitlabCiControllers = + gitlabCiProperties.getControllers().stream() .map( gitlabCiHost -> gitlabCiService( @@ -62,8 +62,8 @@ public Map gitlabCiMasters( gitlabCiHost, objectMapper)) .collect(Collectors.toMap(GitlabCiService::getName, Function.identity())); - buildServices.addServices(gitlabCiMasters); - return gitlabCiMasters; + buildServices.addServices(gitlabCiControllers); + return gitlabCiControllers; } private static GitlabCiService gitlabCiService( diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitlabCiProperties.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitlabCiProperties.java index 19aa21ca9..630210142 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitlabCiProperties.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/GitlabCiProperties.java @@ -28,7 +28,7 @@ public class GitlabCiProperties implements BuildServerProperties { private int cachedJobTTLDays = 60; - @Valid private List masters = new ArrayList<>(); + @Valid private List controllers = new ArrayList<>(); public int getCachedJobTTLDays() { return cachedJobTTLDays; @@ -38,12 +38,22 @@ public void setCachedJobTTLDays(int cachedJobTTLDays) { this.cachedJobTTLDays = cachedJobTTLDays; } + @Deprecated(forRemoval = true) public List getMasters() { - return masters; + return controllers; } - public void setMasters(List masters) { - this.masters = masters; + @Deprecated(forRemoval = true) + public void setMasters(List controllers) { + this.controllers = controllers; + } + + public List getControllers() { + return controllers; + } + + public void setControllers(List controllers) { + this.controllers = controllers; } public static class GitlabCiHost implements BuildServerProperties.Host { diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/JenkinsConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/JenkinsConfig.groovy index 228b5eddf..994f1a441 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/JenkinsConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/JenkinsConfig.groovy @@ -81,7 +81,7 @@ class JenkinsConfig { } @Bean - Map jenkinsMasters(BuildServices buildServices, + Map jenkinsControllers(BuildServices buildServices, IgorConfigurationProperties igorConfigurationProperties, @Valid JenkinsProperties jenkinsProperties, JenkinsOkHttpClientProvider jenkinsOkHttpClientProvider, @@ -89,8 +89,8 @@ class JenkinsConfig { Registry registry, CircuitBreakerRegistry circuitBreakerRegistry, RestAdapter.LogLevel retrofitLogLevel) { - log.info "creating jenkinsMasters" - Map jenkinsMasters = jenkinsProperties?.masters?.collectEntries { JenkinsProperties.JenkinsHost host -> + log.info "creating jenkinsControllers" + Map jenkinsControllers = jenkinsProperties?.controllers?.collectEntries { JenkinsProperties.JenkinsHost host -> log.info "bootstrapping ${host.address} as ${host.name}" [(host.name): jenkinsService( host.name, @@ -108,8 +108,8 @@ class JenkinsConfig { )] } - buildServices.addServices(jenkinsMasters) - jenkinsMasters + buildServices.addServices(jenkinsControllers) + jenkinsControllers } static JenkinsService jenkinsService( diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/JenkinsProperties.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/JenkinsProperties.groovy index 1c6fcc651..61562d9ba 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/JenkinsProperties.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/JenkinsProperties.groovy @@ -18,7 +18,7 @@ package com.netflix.spinnaker.igor.config import com.netflix.spinnaker.fiat.model.resources.Permissions import groovy.transform.CompileStatic -import org.hibernate.validator.constraints.NotEmpty +import javax.validation.constraints.NotEmpty; import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.validation.annotation.Validated @@ -32,9 +32,20 @@ import java.security.KeyStore @ConfigurationProperties(prefix = 'jenkins') @Validated class JenkinsProperties implements BuildServerProperties { + @Deprecated(forRemoval = true) @Valid List masters + @Deprecated(forRemoval = true) + public List getMasters() { return controllers; } + + + @Deprecated(forRemoval = true) + public void setMasters(List controllers) { this.controllers = controllers; } + + @Valid + List controllers + static class JenkinsHost implements BuildServerProperties.Host { @NotEmpty String name diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/StashConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/StashConfig.groovy index 6655bfed5..10ed67086 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/StashConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/StashConfig.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.igor.config import com.netflix.spinnaker.igor.scm.stash.client.StashClient -import com.netflix.spinnaker.igor.scm.stash.client.StashMaster +import com.netflix.spinnaker.igor.scm.stash.client.StashController import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger import com.squareup.okhttp.Credentials import groovy.transform.CompileStatic @@ -45,10 +45,10 @@ import javax.validation.Valid class StashConfig { @Bean - StashMaster stashMaster(@Valid StashProperties stashProperties, - RestAdapter.LogLevel retrofitLogLevel) { + StashController stashController(@Valid StashProperties stashProperties, + RestAdapter.LogLevel retrofitLogLevel) { log.info "bootstrapping ${stashProperties.baseUrl} as stash" - new StashMaster( + new StashController( stashClient: stashClient(stashProperties.baseUrl, stashProperties.username, stashProperties.password, retrofitLogLevel), baseUrl: stashProperties.baseUrl) } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/StashProperties.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/StashProperties.groovy index d4af77fad..58d4f38e3 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/StashProperties.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/StashProperties.groovy @@ -21,7 +21,7 @@ import org.hibernate.validator.constraints.NotEmpty import org.springframework.boot.context.properties.ConfigurationProperties /** - * Helper class to map masters in properties file into a validated property map + * Helper class to map controllers in properties file into a validated property map */ @CompileStatic @ConfigurationProperties(prefix = 'stash') diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerConfig.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerConfig.groovy index 1db2e990c..325a52932 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerConfig.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerConfig.groovy @@ -41,21 +41,21 @@ import retrofit.RestAdapter @EnableConfigurationProperties(WerckerProperties) class WerckerConfig { @Bean - Map werckerMasters( + Map werckerControllers( BuildServices buildServices, WerckerCache cache, IgorConfigurationProperties igorConfigurationProperties, OkHttpClientProvider clientProvider, @Valid WerckerProperties werckerProperties, RestAdapter.LogLevel retrofitLogLevel) { - log.debug "creating werckerMasters" - Map werckerMasters = werckerProperties?.masters?.collectEntries { WerckerHost host -> + log.debug "creating werckerControllers" + Map werckerControllers = werckerProperties?.controllers?.collectEntries { WerckerHost host -> log.debug "bootstrapping Wercker ${host.address} as ${host.name}" [(host.name): new WerckerService(host, cache, werckerClient(host, igorConfigurationProperties.getClient().timeout, clientProvider, retrofitLogLevel), host.permissions.build())] } - buildServices.addServices(werckerMasters) - werckerMasters + buildServices.addServices(werckerControllers) + werckerControllers } static WerckerClient werckerClient(WerckerHost host, int timeout = 30000, OkHttpClientProvider clientProvider, RestAdapter.LogLevel retrofitLogLevel) { diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerProperties.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerProperties.groovy index e087ba510..cbf5e7642 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerProperties.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/config/WerckerProperties.groovy @@ -21,9 +21,19 @@ import javax.validation.Valid @CompileStatic @ConfigurationProperties(prefix = 'wercker') class WerckerProperties implements BuildServerProperties { + @Deprecated(forRemoval = true) @Valid List masters + @Deprecated(forRemoval = true) + public List getMasters() { return controllers; } + + @Deprecated(forRemoval = true) + public void setMasters(List controllers) { this.controllers = controllers; } + + @Valid + List controllers + static class WerckerHost implements BuildServerProperties.Host { @NotEmpty String name diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/exceptions/ArtifactNotFoundException.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/exceptions/ArtifactNotFoundException.java index 747e4f467..f72301c59 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/exceptions/ArtifactNotFoundException.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/exceptions/ArtifactNotFoundException.java @@ -24,10 +24,10 @@ @ResponseStatus(NOT_FOUND) public class ArtifactNotFoundException extends NotFoundException { public ArtifactNotFoundException( - String master, String job, Integer buildNumber, String fileName) { + String controller, String job, Integer buildNumber, String fileName) { super( String.format( "Could not find build artifact matching requested filename '%s' on '%s/%s' build %s", - fileName, master, job, buildNumber)); + fileName, controller, job, buildNumber)); } } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/gitlabci/GitlabCiBuildMonitor.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/gitlabci/GitlabCiBuildMonitor.java index eee407d27..9e72e3476 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/gitlabci/GitlabCiBuildMonitor.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/gitlabci/GitlabCiBuildMonitor.java @@ -98,19 +98,19 @@ public void poll(boolean sendEvents) { @Override protected BuildPollingDelta generateDelta(PollContext ctx) { - final String master = ctx.partitionName; + final String controller = ctx.partitionName; - log.info("Checking for new builds for {}", kv("master", master)); + log.info("Checking for new builds for {}", kv("controller", controller)); final AtomicInteger updatedBuilds = new AtomicInteger(); - final GitlabCiService gitlabCiService = (GitlabCiService) buildServices.getService(master); + final GitlabCiService gitlabCiService = (GitlabCiService) buildServices.getService(controller); long startTime = System.currentTimeMillis(); final List projects = gitlabCiService.getProjects(); log.info( - "Took {} ms to retrieve {} repositories (master: {})", + "Took {} ms to retrieve {} repositories (controller: {})", System.currentTimeMillis() - startTime, projects.size(), - kv("master", master)); + kv("controller", controller)); List delta = new ArrayList<>(); projects.parallelStream() @@ -125,7 +125,7 @@ protected BuildPollingDelta generateDelta(PollContext ctx) { boolean isPipelineRunning = GitlabCiResultConverter.running(pipeline.getStatus()); int cachedBuildId = - buildCache.getLastBuild(master, branchedRepoSlug, isPipelineRunning); + buildCache.getLastBuild(controller, branchedRepoSlug, isPipelineRunning); // In case of Gitlab CI the pipeline ids are increasing so we can use it for // ordering if (pipeline.getId() > cachedBuildId) { @@ -136,36 +136,39 @@ protected BuildPollingDelta generateDelta(PollContext ctx) { }); if (!delta.isEmpty()) { - log.info("Found {} new builds (master: {})", updatedBuilds.get(), kv("master", master)); + log.info( + "Found {} new builds (controller: {})", + updatedBuilds.get(), + kv("controller", controller)); } - return new BuildPollingDelta(delta, master, startTime); + return new BuildPollingDelta(delta, controller, startTime); } @Override protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) { int ttl = buildCacheJobTTLSeconds(); final GitlabCiService gitlabCiService = - (GitlabCiService) buildServices.getService(delta.master); + (GitlabCiService) buildServices.getService(delta.controller); delta.items.parallelStream() .forEach( item -> { log.info( "Build update [{}:{}:{}] [status:{}] [running:{}]", - kv("master", delta.master), + kv("controller", delta.controller), item.branchedRepoSlug, item.pipeline.getId(), item.pipeline.getStatus(), item.pipelineRunning); buildCache.setLastBuild( - delta.master, + delta.controller, item.branchedRepoSlug, item.pipeline.getId(), item.pipelineRunning, ttl); buildCache.setLastBuild( - delta.master, + delta.controller, item.project.getPathWithNamespace(), item.pipeline.getId(), item.pipelineRunning, @@ -176,14 +179,14 @@ protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) { item.pipeline, gitlabCiService.getAddress(), item.branchedRepoSlug, - delta.master); + delta.controller); } }); log.info( - "Last poll took {} ms (master: {})", + "Last poll took {} ms (controller: {})", System.currentTimeMillis() - delta.startTime, - kv("master", delta.master)); + kv("controller", delta.controller)); } private List filterOldPipelines(List pipelines) { @@ -211,29 +214,29 @@ private void sendEventForPipeline( final Pipeline pipeline, String address, final String branchedSlug, - String master) { + String controller) { if (echoService.isPresent()) { - sendEvent(pipeline.getRef(), project, pipeline, address, master); - sendEvent(branchedSlug, project, pipeline, address, master); + sendEvent(pipeline.getRef(), project, pipeline, address, controller); + sendEvent(branchedSlug, project, pipeline, address, controller); } } private void sendEvent( - String slug, Project project, Pipeline pipeline, String address, String master) { + String slug, Project project, Pipeline pipeline, String address, String controller) { if (!echoService.isPresent()) { log.warn("Cannot send build notification: Echo is not enabled"); registry.counter(missedNotificationId.withTag("monitor", getName())).increment(); return; } - log.info("pushing event for {}:{}:{}", kv("master", master), slug, pipeline.getId()); + log.info("pushing event for {}:{}:{}", kv("controller", controller), slug, pipeline.getId()); GenericProject genericProject = new GenericProject( slug, GitlabCiPipelineUtis.genericBuild(pipeline, project.getPathWithNamespace(), address)); GenericBuildContent content = new GenericBuildContent(); - content.setMaster(master); + content.setController(controller); content.setType("gitlab-ci"); content.setProject(genericProject); @@ -244,7 +247,7 @@ private void sendEvent( @Override protected Integer getPartitionUpperThreshold(String partition) { - for (GitlabCiProperties.GitlabCiHost host : gitlabCiProperties.getMasters()) { + for (GitlabCiProperties.GitlabCiHost host : gitlabCiProperties.getControllers()) { if (host.getName() != null && host.getName().equals(partition)) { return host.getItemUpperThreshold(); } @@ -254,12 +257,12 @@ protected Integer getPartitionUpperThreshold(String partition) { static class BuildPollingDelta implements PollingDelta { private final List items; - private final String master; + private final String controller; private final long startTime; - public BuildPollingDelta(List items, String master, long startTime) { + public BuildPollingDelta(List items, String controller, long startTime) { this.items = items; - this.master = master; + this.controller = controller; this.startTime = startTime; } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/history/model/BuildContent.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/history/model/BuildContent.groovy index ebcf22096..f3554866b 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/history/model/BuildContent.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/history/model/BuildContent.groovy @@ -25,5 +25,5 @@ import com.netflix.spinnaker.igor.jenkins.client.model.Project */ class BuildContent { Project project - String master + String controller } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsBuildMonitor.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsBuildMonitor.groovy index ce4926302..4bc1fc8d7 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsBuildMonitor.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsBuildMonitor.groovy @@ -93,49 +93,49 @@ class JenkinsBuildMonitor extends CommonPollingMonitor pollSingle(new PollContext(master, !sendEvents)) } + { controller -> pollSingle(new PollContext(controller, !sendEvents)) } ) } /** - * Gets a list of jobs for this master & processes builds between last poll stamp and a sliding upper bound stamp, + * Gets a list of jobs for this controller & processes builds between last poll stamp and a sliding upper bound stamp, * the cursor will be used to advanced to the upper bound when all builds are completed in the commit phase. */ @Override protected JobPollingDelta generateDelta(PollContext ctx) { - String master = ctx.partitionName - log.trace("Checking for new builds for $master") + String controller = ctx.partitionName + log.trace("Checking for new builds for $controller") final List delta = [] - registry.timer("pollingMonitor.jenkins.retrieveProjects", [new BasicTag("partition", master)]).record { - JenkinsService jenkinsService = buildServices.getService(master) as JenkinsService + registry.timer("pollingMonitor.jenkins.retrieveProjects", [new BasicTag("partition", controller)]).record { + JenkinsService jenkinsService = buildServices.getService(controller) as JenkinsService List jobs = jenkinsService.getProjects()?.getList() ?:[] - jobs.forEach( { job -> processBuildsOfProject(jenkinsService, master, job, delta)}) + jobs.forEach( { job -> processBuildsOfProject(jenkinsService, controller, job, delta)}) } - return new JobPollingDelta(master: master, items: delta) + return new JobPollingDelta(controller: controller, items: delta) } - private void processBuildsOfProject(JenkinsService jenkinsService, String master, Project job, List delta) { + private void processBuildsOfProject(JenkinsService jenkinsService, String controller, Project job, List delta) { if (!job.lastBuild) { - log.trace("[{}:{}] has no builds skipping...", kv("master", master), kv("job", job.name)) + log.trace("[{}:{}] has no builds skipping...", kv("controller", controller), kv("job", job.name)) return } try { - Long cursor = cache.getLastPollCycleTimestamp(master, job.name) + Long cursor = cache.getLastPollCycleTimestamp(controller, job.name) Long lastBuildStamp = job.lastBuild.timestamp as Long Date upperBound = new Date(lastBuildStamp) if (cursor == lastBuildStamp) { - log.trace("[${master}:${job.name}] is up to date. skipping") + log.trace("[${controller}:${job.name}] is up to date. skipping") return } if (!cursor && !igorProperties.spinnaker.build.handleFirstBuilds) { - cache.setLastPollCycleTimestamp(master, job.name, lastBuildStamp) + cache.setLastPollCycleTimestamp(controller, job.name, lastBuildStamp) return } - List allBuilds = getBuilds(jenkinsService, master, job, cursor, lastBuildStamp) + List allBuilds = getBuilds(jenkinsService, controller, job, cursor, lastBuildStamp) List currentlyBuilding = allBuilds.findAll { it.building } List completedBuilds = allBuilds.findAll { !it.building } cursor = !cursor ? lastBuildStamp : cursor @@ -156,17 +156,17 @@ class JenkinsBuildMonitor extends CommonPollingMonitor getBuilds(JenkinsService jenkinsService, String master, Project job, Long cursor, Long lastBuildStamp) { + private List getBuilds(JenkinsService jenkinsService, String controller, Project job, Long cursor, Long lastBuildStamp) { if (!cursor) { - log.debug("[${master}:${job.name}] setting new cursor to ${lastBuildStamp}") + log.debug("[${controller}:${job.name}] setting new cursor to ${lastBuildStamp}") return jenkinsService.getBuilds(job.name) ?: [] } @@ -192,52 +192,52 @@ class JenkinsBuildMonitor extends CommonPollingMonitor // post events for finished builds job.completedBuilds.forEach { build -> - Boolean eventPosted = cache.getEventPosted(master, job.name, job.cursor, build.number) + Boolean eventPosted = cache.getEventPosted(controller, job.name, job.cursor, build.number) if (!eventPosted) { if (sendEvents) { - postEvent(new Project(name: job.name, lastBuild: build), master) - log.debug("[${master}:${job.name}]:${build.number} event posted") + postEvent(new Project(name: job.name, lastBuild: build), controller) + log.debug("[${controller}:${job.name}]:${build.number} event posted") } else { registry.counter(missedNotificationId.withTags("monitor", getName(), "reason", "fastForward")).increment() } - cache.setEventPosted(master, job.name, job.cursor, build.number) + cache.setEventPosted(controller, job.name, job.cursor, build.number) } } // advance cursor when all builds have completed in the interval if (job.runningBuilds.isEmpty()) { log.info("[{}:{}] has no other builds between [${job.lowerBound} - ${job.upperBound}], " + - "advancing cursor to ${job.lastBuildStamp}", kv("master", master), kv("job", job.name)) - cache.pruneOldMarkers(master, job.name, job.cursor) - cache.setLastPollCycleTimestamp(master, job.name, job.lastBuildStamp) + "advancing cursor to ${job.lastBuildStamp}", kv("controller", controller), kv("job", job.name)) + cache.pruneOldMarkers(controller, job.name, job.cursor) + cache.setLastPollCycleTimestamp(controller, job.name, job.lastBuildStamp) } } } @Override protected Integer getPartitionUpperThreshold(String partition) { - return jenkinsProperties.masters.find { partition == it.name }?.itemUpperThreshold + return jenkinsProperties.controllers.find { partition == it.name }?.itemUpperThreshold } - private void postEvent(Project project, String master) { + private void postEvent(Project project, String controller) { if (!echoService.isPresent()) { log.warn("Cannot send build notification: Echo is not configured") registry.counter(missedNotificationId.withTag("monitor", getName())).increment() return } AuthenticatedRequest.allowAnonymous { - echoService.get().postEvent(new BuildEvent(content: new BuildContent(project: project, master: master))) + echoService.get().postEvent(new BuildEvent(content: new BuildContent(project: project, controller: controller))) } } private static class JobPollingDelta implements PollingDelta { - String master + String controller List items } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsCache.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsCache.java index f323b0510..dbf020388 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsCache.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsCache.java @@ -39,10 +39,10 @@ public JenkinsCache( this.igorConfigurationProperties = igorConfigurationProperties; } - public List getJobNames(String master) { + public List getJobNames(String controller) { List jobs = new ArrayList<>(); redisClientDelegate.withKeyScan( - prefix() + ":" + master + ":*", + prefix() + ":" + controller + ":*", 1000, page -> jobs.addAll( @@ -67,8 +67,8 @@ public List getTypeaheadResults(String search) { return results; } - public Map getLastBuild(String master, String job) { - String key = makeKey(master, job); + public Map getLastBuild(String controller, String job) { + String key = makeKey(controller, job); Map result = redisClientDelegate.withCommandsClient( c -> { @@ -89,8 +89,8 @@ public Map getLastBuild(String master, String job) { return converted; } - public void setLastBuild(String master, String job, int lastBuild, boolean building) { - String key = makeKey(master, job); + public void setLastBuild(String controller, String job, int lastBuild, boolean building) { + String key = makeKey(controller, job); redisClientDelegate.withCommandsClient( c -> { c.hset(key, "lastBuildLabel", Integer.toString(lastBuild)); @@ -98,53 +98,53 @@ public void setLastBuild(String master, String job, int lastBuild, boolean build }); } - public void setLastPollCycleTimestamp(String master, String job, Long timestamp) { - String key = makeKey(master, job); + public void setLastPollCycleTimestamp(String controller, String job, Long timestamp) { + String key = makeKey(controller, job); redisClientDelegate.withCommandsClient( c -> { c.hset(key, POLL_STAMP, Long.toString(timestamp)); }); } - public Long getLastPollCycleTimestamp(String master, String job) { + public Long getLastPollCycleTimestamp(String controller, String job) { return redisClientDelegate.withCommandsClient( c -> { - String ts = c.hget(makeKey(master, job), POLL_STAMP); + String ts = c.hget(makeKey(controller, job), POLL_STAMP); return ts == null ? null : Long.parseLong(ts); }); } - public Boolean getEventPosted(String master, String job, Long cursor, Integer buildNumber) { - String key = makeKey(master, job) + ":" + POLL_STAMP + ":" + cursor; + public Boolean getEventPosted(String controller, String job, Long cursor, Integer buildNumber) { + String key = makeKey(controller, job) + ":" + POLL_STAMP + ":" + cursor; return redisClientDelegate.withCommandsClient( c -> c.hget(key, Integer.toString(buildNumber)) != null); } - public void setEventPosted(String master, String job, Long cursor, Integer buildNumber) { - String key = makeKey(master, job) + ":" + POLL_STAMP + ":" + cursor; + public void setEventPosted(String controller, String job, Long cursor, Integer buildNumber) { + String key = makeKey(controller, job) + ":" + POLL_STAMP + ":" + cursor; redisClientDelegate.withCommandsClient( c -> { c.hset(key, Integer.toString(buildNumber), "POSTED"); }); } - public void pruneOldMarkers(String master, String job, Long cursor) { - remove(master, job); + public void pruneOldMarkers(String controller, String job, Long cursor) { + remove(controller, job); redisClientDelegate.withCommandsClient( c -> { - c.del(makeKey(master, job) + ":" + POLL_STAMP + ":" + cursor); + c.del(makeKey(controller, job) + ":" + POLL_STAMP + ":" + cursor); }); } - public void remove(String master, String job) { + public void remove(String controller, String job) { redisClientDelegate.withCommandsClient( c -> { - c.del(makeKey(master, job)); + c.del(makeKey(controller, job)); }); } - private String makeKey(String master, String job) { - return prefix() + ":" + master + ":" + job.toUpperCase() + ":" + job; + private String makeKey(String controller, String job) { + return prefix() + ":" + controller + ":" + job.toUpperCase() + ":" + job; } private static String extractJobName(String key) { diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/client/JenkinsMasters.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/client/JenkinsControllers.groovy similarity index 96% rename from igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/client/JenkinsMasters.groovy rename to igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/client/JenkinsControllers.groovy index e2056bce9..6c486efc7 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/client/JenkinsMasters.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/client/JenkinsControllers.groovy @@ -21,7 +21,7 @@ import com.netflix.spinnaker.igor.jenkins.service.JenkinsService /** * Wrapper class for a collection of jenkins clients */ -class JenkinsMasters { +class JenkinsControllers { Map map diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/service/JenkinsService.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/service/JenkinsService.java index 0cf96d100..851eef906 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/service/JenkinsService.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/jenkins/service/JenkinsService.java @@ -237,13 +237,13 @@ public Build getLatestBuild(String jobName) { } @Override - public QueuedJob queuedBuild(String master, int item) { + public QueuedJob queuedBuild(String controller, int item) { try { return circuitBreaker.executeSupplier(() -> jenkinsClient.getQueuedItem(item)); } catch (RetrofitError e) { if (e.getResponse() != null && e.getResponse().getStatus() == NOT_FOUND.value()) { throw new NotFoundException( - String.format("Queued job '%s' not found for master '%s'.", item, master)); + String.format("Queued job '%s' not found for controller '%s'.", item, controller)); } throw e; } @@ -317,7 +317,7 @@ private String getArtifactPathFromBuild(String job, int buildNumber, String file log.error( "Unable to get igorProperties: Could not find build artifact matching requested filename '{}' on '{}' build '{}", kv("fileName", fileName), - kv("master", serviceName), + kv("controller", serviceName), kv("buildNumber", buildNumber)); return new ArtifactNotFoundException(serviceName, job, buildNumber, fileName); }), diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/ScmInfoController.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/ScmInfoController.groovy index de05953d8..95400aa0a 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/ScmInfoController.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/ScmInfoController.groovy @@ -16,10 +16,10 @@ package com.netflix.spinnaker.igor.scm -import com.netflix.spinnaker.igor.scm.github.client.GitHubMaster -import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabMaster -import com.netflix.spinnaker.igor.scm.stash.client.StashMaster -import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketMaster +import com.netflix.spinnaker.igor.scm.github.client.GitHubController +import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabController +import com.netflix.spinnaker.igor.scm.stash.client.StashController +import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketController import groovy.util.logging.Slf4j import org.springframework.beans.factory.annotation.Autowired import org.springframework.web.bind.annotation.RequestMapping @@ -34,31 +34,37 @@ import org.springframework.web.bind.annotation.RestController @RequestMapping("/scm") class ScmInfoController { @Autowired(required = false) - StashMaster stashMaster + StashController stashController @Autowired(required = false) - GitHubMaster gitHubMaster + GitHubController gitHubController @Autowired(required = false) - GitLabMaster gitLabMaster + GitLabController gitLabController @Autowired(required = false) - BitBucketMaster bitBucketMaster + BitBucketController bitBucketController + @Deprecated(forRemoval = true) @RequestMapping(value = '/masters', method = RequestMethod.GET) Map listMasters() { - def result = [:] - if(stashMaster) - result << [stash : stashMaster.baseUrl] + listControllers() + } - if(gitHubMaster) - result << [gitHub : gitHubMaster.baseUrl] + @RequestMapping(value = '/controllers', method = RequestMethod.GET) + Map listControllers() { + def result = [:] + if(stashController) + result << [stash : stashController.baseUrl] - if(gitLabMaster) - result << [gitLab : gitLabMaster.baseUrl] + if(gitHubController) + result << [gitHub : gitHubController.baseUrl] - if(bitBucketMaster) - result << [bitBucket : bitBucketMaster.baseUrl] - result - } + if(gitLabController) + result << [gitLab : gitLabController.baseUrl] + + if(bitBucketController) + result << [bitBucket : bitBucketController.baseUrl] + result + } } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/CommitController.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/CommitController.groovy index 51b472669..86846a157 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/CommitController.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/CommitController.groovy @@ -19,7 +19,7 @@ package com.netflix.spinnaker.igor.scm.bitbucket import com.netflix.spinnaker.igor.config.BitBucketProperties import com.netflix.spinnaker.igor.exceptions.UnhandledDownstreamServiceErrorException import com.netflix.spinnaker.igor.scm.AbstractCommitController -import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketMaster +import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketController import com.netflix.spinnaker.igor.scm.bitbucket.client.model.CompareCommitsResponse import groovy.util.logging.Slf4j import org.springframework.beans.factory.annotation.Autowired @@ -37,7 +37,7 @@ import retrofit.RetrofitError @RequestMapping("/bitbucket") class CommitController extends AbstractCommitController { @Autowired - BitBucketMaster bitBucketMaster + BitBucketController bitBucketController @Autowired BitBucketProperties bitBucketProperties @@ -55,10 +55,10 @@ class CommitController extends AbstractCommitController { */ try { - commitsResponse = bitBucketMaster.bitBucketClient.getCompareCommits(projectKey, repositorySlug, ['limit': 100, 'include': requestParams.to]) + commitsResponse = bitBucketController.bitBucketClient.getCompareCommits(projectKey, repositorySlug, ['limit': 100, 'include': requestParams.to]) if (!commitsResponse.values.any { it.hash == requestParams.from }) { while (!commitsResponse.values.any { it.hash == requestParams.from }) { - def response = bitBucketMaster.bitBucketClient.getCompareCommits(projectKey, repositorySlug, ['limit': 100, 'include': commitsResponse.values.last().hash]) + def response = bitBucketController.bitBucketClient.getCompareCommits(projectKey, repositorySlug, ['limit': 100, 'include': commitsResponse.values.last().hash]) commitsResponse.values.addAll(response.values) } commitsResponse.values.unique { a, b -> a.hash <=> b.hash } @@ -70,9 +70,9 @@ class CommitController extends AbstractCommitController { } } catch (RetrofitError e) { if (e.response.status == 404) { - return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, bitBucketMaster.baseUrl) + return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, bitBucketController.baseUrl) } - throw new UnhandledDownstreamServiceErrorException("Unhandled bitbucket error for ${bitBucketMaster.baseUrl}", e) + throw new UnhandledDownstreamServiceErrorException("Unhandled bitbucket error for ${bitBucketController.baseUrl}", e) } commitsResponse.values.each { diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/client/BitBucketMaster.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/client/BitBucketController.groovy similarity index 91% rename from igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/client/BitBucketMaster.groovy rename to igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/client/BitBucketController.groovy index cf2fe54d0..7d6011422 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/client/BitBucketMaster.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/bitbucket/client/BitBucketController.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.igor.scm.bitbucket.client import com.netflix.spinnaker.igor.config.BitBucketProperties -import com.netflix.spinnaker.igor.scm.AbstractScmMaster +import com.netflix.spinnaker.igor.scm.AbstractScmController import com.netflix.spinnaker.retrofit.Slf4jRetrofitLogger import com.squareup.okhttp.Credentials import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty @@ -32,15 +32,15 @@ import javax.validation.Valid /** * Wrapper class for a collection of BitBucket clients */ -class BitBucketMaster extends AbstractScmMaster { +class BitBucketController extends AbstractScmController { BitBucketClient bitBucketClient String baseUrl @Bean @ConditionalOnProperty('bitbucket.base-url') - BitBucketMaster bitBucketMaster(@Valid BitBucketProperties bitBucketProperties) { + BitBucketController bitBucketController(@Valid BitBucketProperties bitBucketProperties) { log.info "bootstrapping ${bitBucketProperties.baseUrl}" - new BitBucketMaster( + new BitBucketController( bitBucketClient : bitBucketClient(bitBucketProperties.baseUrl, bitBucketProperties.username, bitBucketProperties.password), baseUrl: bitBucketProperties.baseUrl) } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/CommitController.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/CommitController.groovy index 425209955..7871fdd26 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/CommitController.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/CommitController.groovy @@ -18,7 +18,7 @@ package com.netflix.spinnaker.igor.scm.github import com.netflix.spinnaker.igor.config.GitHubProperties import com.netflix.spinnaker.igor.scm.AbstractCommitController -import com.netflix.spinnaker.igor.scm.github.client.GitHubMaster +import com.netflix.spinnaker.igor.scm.github.client.GitHubController import com.netflix.spinnaker.igor.scm.github.client.model.CompareCommitsResponse import com.netflix.spinnaker.kork.web.exceptions.NotFoundException import groovy.util.logging.Slf4j @@ -37,7 +37,7 @@ import retrofit.RetrofitError @RequestMapping("/github") class CommitController extends AbstractCommitController { @Autowired - GitHubMaster master + GitHubController controller @Autowired GitHubProperties gitHubProperties @@ -49,15 +49,15 @@ class CommitController extends AbstractCommitController { List result = [] try { - commitsResponse = master.gitHubClient.getCompareCommits(projectKey, repositorySlug, requestParams.to, requestParams.from) + commitsResponse = controller.gitHubClient.getCompareCommits(projectKey, repositorySlug, requestParams.to, requestParams.from) } catch (RetrofitError e) { if(e.getKind() == RetrofitError.Kind.NETWORK) { - throw new NotFoundException("Could not find the server ${master.baseUrl}") + throw new NotFoundException("Could not find the server ${controller.baseUrl}") } else if(e.response.status == 404) { - return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, master.baseUrl) + return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, controller.baseUrl) } log.error("Unhandled error response, acting like commit response was not found", e) - return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, master.baseUrl) + return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, controller.baseUrl) } commitsResponse.commits.each { diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubMaster.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubController.groovy similarity index 95% rename from igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubMaster.groovy rename to igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubController.groovy index 0a776271c..191ae31a9 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubMaster.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubController.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.igor.scm.github.client -import com.netflix.spinnaker.igor.scm.AbstractScmMaster +import com.netflix.spinnaker.igor.scm.AbstractScmController import com.netflix.spinnaker.igor.scm.github.client.model.Commit import com.netflix.spinnaker.igor.scm.github.client.model.GetRepositoryContentResponse import com.netflix.spinnaker.kork.web.exceptions.NotFoundException @@ -30,7 +30,7 @@ import java.util.stream.Collectors * Wrapper class for a collection of GitHub clients */ @Slf4j -class GitHubMaster extends AbstractScmMaster { +class GitHubController extends AbstractScmController { private static final String FILE_CONTENT_TYPE = "file"; diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/CommitController.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/CommitController.java index 98cfa6397..b4ae6420b 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/CommitController.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/CommitController.java @@ -18,7 +18,7 @@ import com.netflix.spinnaker.igor.config.GitLabProperties; import com.netflix.spinnaker.igor.scm.AbstractCommitController; -import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabMaster; +import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabController; import com.netflix.spinnaker.igor.scm.gitlab.client.model.CompareCommitsResponse; import com.netflix.spinnaker.kork.web.exceptions.NotFoundException; import java.util.HashMap; @@ -37,12 +37,12 @@ @RequestMapping("/gitlab") public class CommitController extends AbstractCommitController { private static final Logger log = LoggerFactory.getLogger(CommitController.class); - private final GitLabMaster gitLabMaster; + private final GitLabController gitLabController; private final GitLabProperties gitLabProperties; @Autowired - public CommitController(GitLabMaster gitLabMaster, GitLabProperties gitLabProperties) { - this.gitLabMaster = gitLabMaster; + public CommitController(GitLabController gitLabController, GitLabProperties gitLabProperties) { + this.gitLabController = gitLabController; this.gitLabProperties = gitLabProperties; } @@ -65,17 +65,19 @@ public List> compareCommits( queryMap.put("to", toParam); queryMap.put("from", fromParam); commitsResponse = - gitLabMaster.getGitLabClient().getCompareCommits(projectKey, repositorySlug, queryMap); + gitLabController + .getGitLabClient() + .getCompareCommits(projectKey, repositorySlug, queryMap); } catch (RetrofitError e) { if (e.getKind() == RetrofitError.Kind.NETWORK) { - throw new NotFoundException("Could not find the server " + gitLabMaster.getBaseUrl()); + throw new NotFoundException("Could not find the server " + gitLabController.getBaseUrl()); } else if (e.getResponse().getStatus() == 404) { return getNotFoundCommitsResponse( - projectKey, repositorySlug, toParam, fromParam, gitLabMaster.getBaseUrl()); + projectKey, repositorySlug, toParam, fromParam, gitLabController.getBaseUrl()); } log.error("Unhandled error response, acting like commit response was not found", e); return getNotFoundCommitsResponse( - projectKey, repositorySlug, toParam, fromParam, gitLabMaster.getBaseUrl()); + projectKey, repositorySlug, toParam, fromParam, gitLabController.getBaseUrl()); } return commitsResponse.commits.stream() diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/client/GitLabMaster.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/client/GitLabController.java similarity index 83% rename from igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/client/GitLabMaster.java rename to igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/client/GitLabController.java index 82c48944e..e5c47b668 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/client/GitLabMaster.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/gitlab/client/GitLabController.java @@ -16,14 +16,14 @@ package com.netflix.spinnaker.igor.scm.gitlab.client; -import com.netflix.spinnaker.igor.scm.AbstractScmMaster; +import com.netflix.spinnaker.igor.scm.AbstractScmController; /** Wrapper class for a collection of GitLab clients */ -public class GitLabMaster extends AbstractScmMaster { +public class GitLabController extends AbstractScmController { private final GitLabClient gitLabClient; private final String baseUrl; - public GitLabMaster(GitLabClient gitLabClient, String baseUrl) { + public GitLabController(GitLabClient gitLabClient, String baseUrl) { this.gitLabClient = gitLabClient; this.baseUrl = baseUrl; } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/CommitController.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/CommitController.groovy index 646394e5a..8ff3476b0 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/CommitController.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/CommitController.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.igor.scm.stash import com.netflix.spinnaker.igor.scm.AbstractCommitController -import com.netflix.spinnaker.igor.scm.stash.client.StashMaster +import com.netflix.spinnaker.igor.scm.stash.client.StashController import com.netflix.spinnaker.igor.scm.stash.client.model.CompareCommitsResponse import com.netflix.spinnaker.kork.web.exceptions.NotFoundException import groovy.util.logging.Slf4j @@ -36,19 +36,19 @@ import retrofit.RetrofitError @RequestMapping("/stash") class CommitController extends AbstractCommitController { @Autowired - StashMaster stashMaster + StashController stashController @RequestMapping(method = RequestMethod.GET, value = '/{projectKey}/{repositorySlug}/compareCommits') List compareCommits(@PathVariable(value = 'projectKey') String projectKey, @PathVariable(value='repositorySlug') String repositorySlug, @RequestParam Map requestParams) { super.compareCommits(projectKey, repositorySlug, requestParams) CompareCommitsResponse commitsResponse try { - commitsResponse = stashMaster.stashClient.getCompareCommits(projectKey, repositorySlug, requestParams) + commitsResponse = stashController.stashClient.getCompareCommits(projectKey, repositorySlug, requestParams) } catch (RetrofitError e) { if (e.getKind() == RetrofitError.Kind.NETWORK) { - throw new NotFoundException("Could not find the server ${stashMaster.baseUrl}") + throw new NotFoundException("Could not find the server ${stashController.baseUrl}") } else if (e.response.status == 404) { - return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, stashMaster.baseUrl) + return getNotFoundCommitsResponse(projectKey, repositorySlug, requestParams.to, requestParams.from, stashController.baseUrl) } log.error( "Failed to fetch commits for {}/{}, reason: {}", @@ -60,7 +60,7 @@ class CommitController extends AbstractCommitController { commitsResponse?.values?.each { result << [displayId: it?.displayId, id: it?.id, authorDisplayName: it?.author?.displayName, timestamp: it?.authorTimestamp, message : it?.message, commitUrl: - "${stashMaster.baseUrl}/projects/${projectKey}/repos/${repositorySlug}/commits/${it.id}".toString()] + "${stashController.baseUrl}/projects/${projectKey}/repos/${repositorySlug}/commits/${it.id}".toString()] } return result } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashMaster.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashController.groovy similarity index 95% rename from igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashMaster.groovy rename to igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashController.groovy index 81297df74..93e6c16b2 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashMaster.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashController.groovy @@ -16,7 +16,7 @@ package com.netflix.spinnaker.igor.scm.stash.client -import com.netflix.spinnaker.igor.scm.AbstractScmMaster +import com.netflix.spinnaker.igor.scm.AbstractScmController import com.netflix.spinnaker.igor.scm.stash.client.model.TextLinesResponse import com.netflix.spinnaker.kork.web.exceptions.NotFoundException import groovy.util.logging.Slf4j @@ -26,7 +26,7 @@ import retrofit.RetrofitError * Wrapper class for a collection of Stash clients */ @Slf4j -class StashMaster extends AbstractScmMaster { +class StashController extends AbstractScmController { public static final int DEFAULT_PAGED_RESPONSE_LIMIT = 500 StashClient stashClient diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerBuildMonitor.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerBuildMonitor.groovy index 24eca6b7c..70cfe6683 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerBuildMonitor.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerBuildMonitor.groovy @@ -96,37 +96,37 @@ class WerckerBuildMonitor extends CommonPollingMonitor - pollSingle(new PollContext(master, !sendEvents)) + buildServices.getServiceNames(BuildServiceProvider.WERCKER).parallelStream().forEach( { controller -> + pollSingle(new PollContext(controller, !sendEvents)) } ) log.info "WerckerBuildMonitor Polling cycle done in ${System.currentTimeMillis() - startTime}ms" } /** - * Gets a list of pipelines for this master & processes runs between last poll stamp and a sliding upper bound stamp, + * Gets a list of pipelines for this controller & processes runs between last poll stamp and a sliding upper bound stamp, * the cursor will be used to advanced to the upper bound when all builds are completed in the commit phase. */ @Override protected PipelinePollingDelta generateDelta(PollContext ctx) { - String master = ctx.partitionName - log.info("Checking for new builds for $master") + String controller = ctx.partitionName + log.info("Checking for new builds for $controller") def startTime = System.currentTimeMillis() List delta = [] - WerckerService werckerService = buildServices.getService(master) as WerckerService + WerckerService werckerService = buildServices.getService(controller) as WerckerService long since = System.currentTimeMillis() - (Long.valueOf(getPollInterval() * 2 * 1000)) try { Map> runs = werckerService.getRunsSince(since) runs.keySet().forEach( { pipeline -> - processRuns(werckerService, master, pipeline, delta, runs.get(pipeline)) + processRuns(werckerService, controller, pipeline, delta, runs.get(pipeline)) } ) } catch (e) { - log.error("Error processing runs for Wercker[{}]", kv("master", master), e) + log.error("Error processing runs for Wercker[{}]", kv("controller", controller), e) } - log.debug("Took ${System.currentTimeMillis() - startTime}ms to retrieve Wercker pipelines (master: {})", kv("master", master)) - return new PipelinePollingDelta(master: master, items: delta) + log.debug("Took ${System.currentTimeMillis() - startTime}ms to retrieve Wercker pipelines (controller: {})", kv("controller", controller)) + return new PipelinePollingDelta(controller: controller, items: delta) } Run getLastFinishedAt(List runs) { @@ -141,28 +141,28 @@ class WerckerBuildMonitor extends CommonPollingMonitor delta, List runs) { List allRuns = runs ?: werckerService.getBuilds(pipeline) log.info "polling Wercker pipeline: ${pipeline} got ${allRuns.size()} runs" if (allRuns.empty) { - log.debug("[{}:{}] has no runs skipping...", kv("master", master), kv("pipeline", pipeline)) + log.debug("[{}:{}] has no runs skipping...", kv("controller", controller), kv("pipeline", pipeline)) return } Run lastStartedAt = getLastStartedAt(allRuns) try { - Long cursor = cache.getLastPollCycleTimestamp(master, pipeline) + Long cursor = cache.getLastPollCycleTimestamp(controller, pipeline) //The last build/run Long lastBuildStamp = lastStartedAt.startedAt.fastTime Date upperBound = lastStartedAt.startedAt if (cursor == lastBuildStamp) { - log.debug("[${master}:${pipeline}] is up to date. skipping") + log.debug("[${controller}:${pipeline}] is up to date. skipping") return } - cache.updateBuildNumbers(master, pipeline, allRuns) + cache.updateBuildNumbers(controller, pipeline, allRuns) List allBuilds = allRuns.findAll { it?.startedAt?.fastTime > cursor } if (!cursor && !igorProperties.spinnaker.build.handleFirstBuilds) { - cache.setLastPollCycleTimestamp(master, pipeline, lastBuildStamp) + cache.setLastPollCycleTimestamp(controller, pipeline, lastBuildStamp) return } List currentlyBuilding = allBuilds.findAll { it.finishedAt == null } @@ -170,8 +170,8 @@ class WerckerBuildMonitor extends CommonPollingMonitor completedBuilds = (lastFinished && lastFinished.finishedAt)? [lastFinished]: [] - log.debug("[${master}:${pipeline}] currentlyBuilding: ${currentlyBuilding}" ) - log.debug("[${master}:${pipeline}] completedBuilds: ${completedBuilds}" ) + log.debug("[${controller}:${pipeline}] currentlyBuilding: ${currentlyBuilding}" ) + log.debug("[${controller}:${pipeline}] completedBuilds: ${completedBuilds}" ) cursor = cursor?:lastBuildStamp Date lowerBound = new Date(cursor) if (!igorProperties.spinnaker.build.processBuildsOlderThanLookBackWindow) { @@ -187,10 +187,10 @@ class WerckerBuildMonitor extends CommonPollingMonitor //job = Wercker pipeline (org/app/pipeline) // post event for latest finished run pipeline.completedBuilds.forEach { run -> //build = Wercker run - Boolean eventPosted = cache.getEventPosted(master, pipeline.name, run.id) - GenericBuild build = toBuild(master, pipeline.name, run) + Boolean eventPosted = cache.getEventPosted(controller, pipeline.name, run.id) + GenericBuild build = toBuild(controller, pipeline.name, run) if (!eventPosted && sendEvents) { - log.debug("[${master}:${pipeline.name}]:${build.id} event posted") - if(postEvent(new GenericProject(pipeline.name, build), master)) { - cache.setEventPosted(master, pipeline.name, run.id) + log.debug("[${controller}:${pipeline.name}]:${build.id} event posted") + if(postEvent(new GenericProject(pipeline.name, build), controller)) { + cache.setEventPosted(controller, pipeline.name, run.id) } } } // advance cursor when all builds have completed in the interval if (pipeline.runningBuilds.isEmpty()) { - log.info("[{}:{}] has no other builds between [${pipeline.lowerBound} - ${pipeline.upperBound}], advancing cursor to ${pipeline.lastBuildStamp}", kv("master", master), kv("pipeline", pipeline.name)) - cache.pruneOldMarkers(master, pipeline.name, pipeline.cursor) - cache.setLastPollCycleTimestamp(master, pipeline.name, pipeline.lastBuildStamp) + log.info("[{}:{}] has no other builds between [${pipeline.lowerBound} - ${pipeline.upperBound}], advancing cursor to ${pipeline.lastBuildStamp}", kv("controller", controller), kv("pipeline", pipeline.name)) + cache.pruneOldMarkers(controller, pipeline.name, pipeline.cursor) + cache.setLastPollCycleTimestamp(controller, pipeline.name, pipeline.lastBuildStamp) } } } @Override protected Integer getPartitionUpperThreshold(String partition) { - return werckerProperties.masters.find { partition == it.name }?.itemUpperThreshold + return werckerProperties.controllers.find { partition == it.name }?.itemUpperThreshold } - private boolean postEvent(GenericProject project, String master) { + private boolean postEvent(GenericProject project, String controller) { if (!echoService.isPresent()) { log.warn("Cannot send build notification: Echo is not configured") registry.counter(missedNotificationId.withTag("monitor", getName())).increment() return false } AuthenticatedRequest.allowAnonymous { - echoService.get().postEvent(new GenericBuildEvent(content: new GenericBuildContent(project: project, master: master, type: "wercker"))) + echoService.get().postEvent(new GenericBuildEvent(content: new GenericBuildContent(project: project, controller: controller, type: "wercker"))) } return true } private static class PipelinePollingDelta implements PollingDelta { - String master + String controller List items } diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerCache.java b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerCache.java index 37a562e1c..840fc19d5 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerCache.java +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerCache.java @@ -40,52 +40,52 @@ public WerckerCache( this.igorConfigurationProperties = igorConfigurationProperties; } - public void setLastPollCycleTimestamp(String master, String pipeline, Long timestamp) { - String key = makeKey(master, pipeline); + public void setLastPollCycleTimestamp(String controller, String pipeline, Long timestamp) { + String key = makeKey(controller, pipeline); redisClientDelegate.withCommandsClient( c -> { c.hset(key, POLL_STAMP, Long.toString(timestamp)); }); } - public Long getLastPollCycleTimestamp(String master, String pipeline) { + public Long getLastPollCycleTimestamp(String controller, String pipeline) { return redisClientDelegate.withCommandsClient( c -> { - String ts = c.hget(makeKey(master, pipeline), POLL_STAMP); + String ts = c.hget(makeKey(controller, pipeline), POLL_STAMP); return ts == null ? null : Long.parseLong(ts); }); } - public String getPipelineID(String master, String pipeline) { + public String getPipelineID(String controller, String pipeline) { return redisClientDelegate.withCommandsClient( c -> { - return c.hget(makeKey(master, pipeline), PIPELINE_ID); + return c.hget(makeKey(controller, pipeline), PIPELINE_ID); }); } - public String getPipelineName(String master, String id) { + public String getPipelineName(String controller, String id) { return redisClientDelegate.withCommandsClient( c -> { - return c.hget(nameKey(master, id), PIPELINE_NAME); + return c.hget(nameKey(controller, id), PIPELINE_NAME); }); } - public void setPipelineID(String master, String pipeline, String id) { - String key = makeKey(master, pipeline); + public void setPipelineID(String controller, String pipeline, String id) { + String key = makeKey(controller, pipeline); redisClientDelegate.withCommandsClient( c -> { c.hset(key, PIPELINE_ID, id); }); - String nameKey = nameKey(master, id); + String nameKey = nameKey(controller, id); redisClientDelegate.withCommandsClient( c -> { c.hset(nameKey, PIPELINE_NAME, pipeline); }); } - public String getRunID(String master, String pipeline, final int buildNumber) { - String key = makeKey(master, pipeline) + ":runs"; + public String getRunID(String controller, String pipeline, final int buildNumber) { + String key = makeKey(controller, pipeline) + ":runs"; final Map existing = redisClientDelegate.withCommandsClient( c -> { @@ -107,14 +107,14 @@ public String getRunID(String master, String pipeline, final int buildNumber) { * Creates entries in Redis for each run in the runs list (except if the run id already exists) * and generates build numbers for each run id (ordered by startedAt date) * - * @param master + * @param controller * @param appAndPipelineName * @param runs * @return a map containing the generated build numbers for each run created, keyed by run id */ public Map updateBuildNumbers( - String master, String appAndPipelineName, List runs) { - String key = makeKey(master, appAndPipelineName) + ":runs"; + String controller, String appAndPipelineName, List runs) { + String key = makeKey(controller, appAndPipelineName) + ":runs"; final Map existing = redisClientDelegate.withCommandsClient( c -> { @@ -135,66 +135,66 @@ public Map updateBuildNumbers( newRuns.sort(startedAtComparator); for (int i = 0; i < newRuns.size(); i++) { int buildNum = startNumber + i; - setBuildNumber(master, appAndPipelineName, newRuns.get(i).getId(), buildNum); + setBuildNumber(controller, appAndPipelineName, newRuns.get(i).getId(), buildNum); runIdToBuildNumber.put(newRuns.get(i).getId(), buildNum); } return runIdToBuildNumber; } - public void setBuildNumber(String master, String pipeline, String runID, int number) { - String key = makeKey(master, pipeline) + ":runs"; + public void setBuildNumber(String controller, String pipeline, String runID, int number) { + String key = makeKey(controller, pipeline) + ":runs"; redisClientDelegate.withCommandsClient( c -> { c.hset(key, runID, Integer.toString(number)); }); } - public Long getBuildNumber(String master, String pipeline, String runID) { + public Long getBuildNumber(String controller, String pipeline, String runID) { return redisClientDelegate.withCommandsClient( c -> { - String ts = c.hget(makeKey(master, pipeline) + ":runs", runID); + String ts = c.hget(makeKey(controller, pipeline) + ":runs", runID); return ts == null ? null : Long.parseLong(ts); }); } - public Boolean getEventPosted(String master, String job, String runID) { - String key = makeEventsKey(master, job); + public Boolean getEventPosted(String controller, String job, String runID) { + String key = makeEventsKey(controller, job); return redisClientDelegate.withCommandsClient(c -> c.hget(key, runID) != null); } - public void setEventPosted(String master, String job, String runID) { - String key = makeEventsKey(master, job); + public void setEventPosted(String controller, String job, String runID) { + String key = makeEventsKey(controller, job); redisClientDelegate.withCommandsClient( c -> { c.hset(key, runID, "POSTED"); }); } - public void pruneOldMarkers(String master, String job, Long cursor) { - remove(master, job); + public void pruneOldMarkers(String controller, String job, Long cursor) { + remove(controller, job); redisClientDelegate.withCommandsClient( c -> { - c.del(makeEventsKey(master, job)); + c.del(makeEventsKey(controller, job)); }); } - public void remove(String master, String job) { + public void remove(String controller, String job) { redisClientDelegate.withCommandsClient( c -> { - c.del(makeKey(master, job)); + c.del(makeKey(controller, job)); }); } - private String makeEventsKey(String master, String job) { - return makeKey(master, job) + ":" + POLL_STAMP + ":events"; + private String makeEventsKey(String controller, String job) { + return makeKey(controller, job) + ":" + POLL_STAMP + ":events"; } - private String makeKey(String master, String job) { - return prefix() + ":" + master + ":" + job.toUpperCase() + ":" + job; + private String makeKey(String controller, String job) { + return prefix() + ":" + controller + ":" + job.toUpperCase() + ":" + job; } - private String nameKey(String master, String pipelineId) { - return prefix() + ":" + master + ":all_pipelines:" + pipelineId; + private String nameKey(String controller, String pipelineId) { + return prefix() + ":" + controller + ":all_pipelines:" + pipelineId; } private String prefix() { diff --git a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerService.groovy b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerService.groovy index 380206e5c..2563fd94c 100644 --- a/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerService.groovy +++ b/igor-web/src/main/groovy/com/netflix/spinnaker/igor/wercker/WerckerService.groovy @@ -41,7 +41,7 @@ class WerckerService implements BuildOperations { String token String authHeaderValue String address - String master + String controller WerckerCache cache final Permissions permissions @@ -54,7 +54,7 @@ class WerckerService implements BuildOperations { this.user = wercker.user this.cache = cache this.address = address - this.master = wercker.name + this.controller = wercker.name this.setToken(token) this.address = wercker.address this.setToken(wercker.token) @@ -163,7 +163,7 @@ class WerckerService implements BuildOperations { //Create an entry in the WerckerCache for this new run. This will also generate //an integer build number for the run Map runIdBuildNumbers = cache.updateBuildNumbers( - master, appAndPipelineName, Collections.singletonList(run)) + controller, appAndPipelineName, Collections.singletonList(run)) log.info("Triggered run {} at URL {} with build number {}", kv("runId", run.id), kv("url", run.url), @@ -244,7 +244,7 @@ class WerckerService implements BuildOperations { } /** - * A CommandKey should be unique per group (to ensure broken circuits do not span Wercker masters) + * A CommandKey should be unique per group (to ensure broken circuits do not span Wercker controllers) */ private String buildCommandKey(String id) { return "${groupKey}-${id}" diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/ConcourseBuildMonitor.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/ConcourseBuildMonitor.java index 31a4ba2e4..b6c19c724 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/ConcourseBuildMonitor.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/ConcourseBuildMonitor.java @@ -87,7 +87,7 @@ public ConcourseBuildMonitor( @Override protected JobPollingDelta generateDelta(PollContext ctx) { ConcourseProperties.Host host = - concourseProperties.getMasters().stream() + concourseProperties.getControllers().stream() .filter(h -> h.getName().equals(ctx.partitionName)) .findFirst() .orElseThrow( @@ -199,7 +199,7 @@ private void sendEventForBuild(ConcourseProperties.Host host, Job job, GenericBu GenericBuildContent content = new GenericBuildContent(); content.setProject(project); - content.setMaster("concourse-" + host.getName()); + content.setController("concourse-" + host.getName()); content.setType("concourse"); GenericBuildEvent event = new GenericBuildEvent(); @@ -215,7 +215,7 @@ private void sendEventForBuild(ConcourseProperties.Host host, Job job, GenericBu @Override public void poll(boolean sendEvents) { - for (ConcourseProperties.Host host : concourseProperties.getMasters()) { + for (ConcourseProperties.Host host : concourseProperties.getControllers()) { pollSingle(new PollContext(host.getName(), !sendEvents)); } } diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/ConcourseController.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/ConcourseController.java index ca38054f9..f8631b21f 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/ConcourseController.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/ConcourseController.java @@ -42,19 +42,19 @@ public ConcourseController(BuildServices buildServices) { this.buildServices = buildServices; } - @GetMapping("/{buildMaster}/teams") - public List getTeams(@PathVariable("buildMaster") String buildMaster) { - return getService(buildMaster) + @GetMapping("/{buildController}/teams") + public List getTeams(@PathVariable("buildController") String buildController) { + return getService(buildController) .map( service -> service.teams().stream().map(Team::getName).sorted().collect(Collectors.toList())) .orElse(emptyList()); } - @GetMapping("/{buildMaster}/teams/{team}/pipelines") + @GetMapping("/{buildController}/teams/{team}/pipelines") public List getPipelines( - @PathVariable("buildMaster") String buildMaster, @PathVariable("team") String team) { - return getService(buildMaster) + @PathVariable("buildController") String buildController, @PathVariable("team") String team) { + return getService(buildController) .map( service -> service.pipelines().stream() @@ -65,13 +65,13 @@ public List getPipelines( .orElse(emptyList()); } - @GetMapping("/{buildMaster}/teams/{team}/pipelines/{pipeline}/jobs") + @GetMapping("/{buildController}/teams/{team}/pipelines/{pipeline}/jobs") public List getJobs( - @PathVariable("buildMaster") String buildMaster, + @PathVariable("buildController") String buildController, @PathVariable("team") String team, @PathVariable("pipeline") String pipeline) { // don't sort so that we leave the jobs in the order in which they appear in the pipeline - return getService(buildMaster) + return getService(buildController) .map( service -> service.getJobs().stream() @@ -82,12 +82,12 @@ public List getJobs( .orElse(emptyList()); } - @GetMapping("/{buildMaster}/teams/{team}/pipelines/{pipeline}/resources") + @GetMapping("/{buildController}/teams/{team}/pipelines/{pipeline}/resources") public List getResourceNames( - @PathVariable("buildMaster") String buildMaster, + @PathVariable("buildController") String buildController, @PathVariable("team") String team, @PathVariable("pipeline") String pipeline) { - return getService(buildMaster) + return getService(buildController) .map( service -> service.getResourceNames(team, pipeline).stream() @@ -96,7 +96,7 @@ public List getResourceNames( .orElse(emptyList()); } - private Optional getService(String buildMaster) { - return Optional.ofNullable((ConcourseService) buildServices.getService(buildMaster)); + private Optional getService(String buildController) { + return Optional.ofNullable((ConcourseService) buildServices.getService(buildController)); } } diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/service/ConcourseService.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/service/ConcourseService.java index a2a920623..5ad9e55c0 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/service/ConcourseService.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/concourse/service/ConcourseService.java @@ -92,13 +92,18 @@ protected ConcourseService( this.permissions = host.getPermissions().build(); } + @Deprecated(forRemoval = true) public String getMaster() { + return getController(); + } + + public String getController() { return "concourse-" + host.getName(); } @Override public String getName() { - return getMaster(); + return getController(); } @Override diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/config/ConcourseConfig.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/config/ConcourseConfig.java index e09027e6f..39d488b03 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/config/ConcourseConfig.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/config/ConcourseConfig.java @@ -22,23 +22,23 @@ @EnableConfigurationProperties(ConcourseProperties.class) public class ConcourseConfig { @Bean - public Map concourseMasters( + public Map concourseControllers( BuildServices buildServices, ConcourseCache concourseCache, Optional artifactDecorator, IgorConfigurationProperties igorConfigurationProperties, @Valid ConcourseProperties concourseProperties) { - List masters = concourseProperties.getMasters(); - if (masters == null) { + List controllers = concourseProperties.getControllers(); + if (controllers == null) { return Collections.emptyMap(); } - Map concourseMasters = - masters.stream() + Map concourseControllers = + controllers.stream() .map(m -> new ConcourseService(m, artifactDecorator)) - .collect(Collectors.toMap(ConcourseService::getMaster, Function.identity())); + .collect(Collectors.toMap(ConcourseService::getController, Function.identity())); - buildServices.addServices(concourseMasters); - return concourseMasters; + buildServices.addServices(concourseControllers); + return concourseControllers; } } diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/config/ConcourseProperties.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/config/ConcourseProperties.java index 01ced1646..6f4de3034 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/config/ConcourseProperties.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/config/ConcourseProperties.java @@ -25,8 +25,21 @@ @Data @ConfigurationProperties(prefix = "concourse") public class ConcourseProperties { + @Deprecated(forRemoval = true) private List masters; + @Deprecated(forRemoval = true) + public List getMasters() { + return controllers; + } + + @Deprecated(forRemoval = true) + public void setMasters(List controllers) { + this.controllers = controllers; + } + + private List controllers; + @Data public static class Host { private String name; diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/config/IgorConfig.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/config/IgorConfig.java index 3f509ff1a..69acd03f0 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/config/IgorConfig.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/config/IgorConfig.java @@ -63,7 +63,7 @@ public void addInterceptors(InterceptorRegistry registry) { new MetricsInterceptor( this.registry, "controller.invocations", - Collections.singletonList("master"), + Collections.singletonList("controller"), null, Collections.singletonList("BasicErrorController"))); } diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/health/EchoServiceHealthIndicator.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/health/EchoServiceHealthIndicator.java index a4c43f823..8b5929839 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/health/EchoServiceHealthIndicator.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/health/EchoServiceHealthIndicator.java @@ -94,7 +94,7 @@ private static GenericBuildEvent buildGenericEvent() { final GenericBuildEvent event = new GenericBuildEvent(); final GenericBuildContent buildContent = new GenericBuildContent(); final GenericProject project = new GenericProject("spinnaker", new GenericBuild()); - buildContent.setMaster("IgorHealthCheck"); + buildContent.setController("IgorHealthCheck"); buildContent.setProject(project); event.setContent(buildContent); return event; diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/AbstractScmMaster.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/AbstractScmController.java similarity index 93% rename from igor-web/src/main/java/com/netflix/spinnaker/igor/scm/AbstractScmMaster.java rename to igor-web/src/main/java/com/netflix/spinnaker/igor/scm/AbstractScmController.java index 671a87489..c2986a662 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/AbstractScmMaster.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/AbstractScmController.java @@ -18,7 +18,7 @@ import java.util.List; -public class AbstractScmMaster implements ScmMaster { +public class AbstractScmController implements ScmController { public List listDirectory( String projectKey, String repositorySlug, String path, String ref) { throw new UnsupportedOperationException("Not implemented"); @@ -30,7 +30,7 @@ public String getTextFileContents( } public String getTextFileContents(String projectKey, String repositorySlug, String path) { - return getTextFileContents(projectKey, repositorySlug, path, ScmMaster.DEFAULT_GIT_REF); + return getTextFileContents(projectKey, repositorySlug, path, ScmController.DEFAULT_GIT_REF); } public Object getCommitDetails(String projectKey, String repositorySlug, String commitSha) { diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ManagedDeliveryScmService.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ManagedDeliveryScmService.java index 21546ce91..d7530dd4b 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ManagedDeliveryScmService.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ManagedDeliveryScmService.java @@ -20,10 +20,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import com.netflix.spinnaker.igor.config.ManagedDeliveryConfigProperties; -import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketMaster; -import com.netflix.spinnaker.igor.scm.github.client.GitHubMaster; -import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabMaster; -import com.netflix.spinnaker.igor.scm.stash.client.StashMaster; +import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketController; +import com.netflix.spinnaker.igor.scm.github.client.GitHubController; +import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabController; +import com.netflix.spinnaker.igor.scm.stash.client.StashController; import java.util.List; import java.util.Map; import java.util.Optional; @@ -42,25 +42,25 @@ public class ManagedDeliveryScmService { private final ManagedDeliveryConfigProperties configProperties; private final ObjectMapper jsonMapper; private final ObjectMapper yamlMapper; - private final Optional stashMaster; - private final Optional gitHubMaster; - private final Optional gitLabMaster; - private final Optional bitBucketMaster; + private final Optional stashController; + private final Optional gitHubController; + private final Optional gitLabController; + private final Optional bitBucketController; public ManagedDeliveryScmService( Optional configProperties, - Optional stashMaster, - Optional gitHubMaster, - Optional gitLabMaster, - Optional bitBucketMaster) { + Optional stashController, + Optional gitHubController, + Optional gitLabController, + Optional bitBucketController) { this.configProperties = configProperties.isPresent() ? configProperties.get() : new ManagedDeliveryConfigProperties(); - this.stashMaster = stashMaster; - this.gitHubMaster = gitHubMaster; - this.gitLabMaster = gitLabMaster; - this.bitBucketMaster = bitBucketMaster; + this.stashController = stashController; + this.gitHubController = gitHubController; + this.gitLabController = gitLabController; + this.bitBucketController = bitBucketController; this.jsonMapper = new ObjectMapper(); this.yamlMapper = new ObjectMapper(new YAMLFactory()); } @@ -90,8 +90,9 @@ public List listDeliveryConfigManifests( log.debug( "Listing keel manifests at " + scmType + "://" + project + "/" + repository + "/" + path); - return getScmMaster(scmType) - .listDirectory(project, repository, path, (ref != null) ? ref : ScmMaster.DEFAULT_GIT_REF) + return getScmController(scmType) + .listDirectory( + project, repository, path, (ref != null) ? ref : ScmController.DEFAULT_GIT_REF) .stream() .filter(it -> it.endsWith("." + ((extension != null) ? extension : "yml"))) .collect(Collectors.toList()); @@ -131,7 +132,7 @@ public Map getDeliveryConfigManifest( log.debug( "Retrieving delivery config manifest from " + project + ":" + repository + "/" + path); String manifestContents = - getScmMaster(scmType).getTextFileContents(project, repository, path, ref); + getScmController(scmType).getTextFileContents(project, repository, path, ref); try { if (manifest.endsWith(".json")) { @@ -147,23 +148,23 @@ public Map getDeliveryConfigManifest( } } - private ScmMaster getScmMaster(final String scmType) { - Optional scmMaster; + private ScmController getScmController(final String scmType) { + Optional scmController; if (scmType.equalsIgnoreCase("bitbucket")) { - scmMaster = bitBucketMaster; + scmController = bitBucketController; } else if (scmType.equalsIgnoreCase("github")) { - scmMaster = gitHubMaster; + scmController = gitHubController; } else if (scmType.equalsIgnoreCase("gitlab")) { - scmMaster = gitLabMaster; + scmController = gitLabController; } else if (scmType.equalsIgnoreCase("stash")) { - scmMaster = stashMaster; + scmController = stashController; } else { throw new IllegalArgumentException("Unknown SCM type " + scmType); } - if (scmMaster.isPresent()) { - return scmMaster.get(); + if (scmController.isPresent()) { + return scmController.get(); } else { throw new IllegalArgumentException(scmType + " client requested but not configured"); } diff --git a/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ScmMaster.java b/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ScmController.java similarity index 96% rename from igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ScmMaster.java rename to igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ScmController.java index 1ae3e355e..840201271 100644 --- a/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ScmMaster.java +++ b/igor-web/src/main/java/com/netflix/spinnaker/igor/scm/ScmController.java @@ -19,7 +19,7 @@ import java.util.List; /** Abstracts underlying implementation details of each SCM system under a common interface. */ -public interface ScmMaster { +public interface ScmController { String DEFAULT_GIT_REF = "refs/heads/master"; List listDirectory(String projectKey, String repositorySlug, String path, String ref); diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/BuildCacheSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/BuildCacheSpec.groovy index 2606d98d7..2f8b929aa 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/BuildCacheSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/BuildCacheSpec.groovy @@ -35,7 +35,7 @@ class BuildCacheSpec extends Specification { @Subject BuildCache cache = new BuildCache(redisClientDelegate, new IgorConfigurationProperties()) - def master = 'master' + def controller = 'controller' def test = 'test' def int TTL = 42 @@ -48,31 +48,31 @@ class BuildCacheSpec extends Specification { void 'new build numbers get overridden'() { when: - cache.setLastBuild(master, 'job1', 78, true, TTL) + cache.setLastBuild(controller, 'job1', 78, true, TTL) then: - cache.getLastBuild(master, 'job1', true) == 78 + cache.getLastBuild(controller, 'job1', true) == 78 when: - cache.setLastBuild(master, 'job1', 80, true, TTL) + cache.setLastBuild(controller, 'job1', 80, true, TTL) then: - cache.getLastBuild(master, 'job1', true) == 80 + cache.getLastBuild(controller, 'job1', true) == 80 } void 'running and completed builds are handled separately'() { when: - cache.setLastBuild(master, 'job1', 78, true, TTL) + cache.setLastBuild(controller, 'job1', 78, true, TTL) then: - cache.getLastBuild(master, 'job1', true) == 78 + cache.getLastBuild(controller, 'job1', true) == 78 when: - cache.setLastBuild(master, 'job1', 80, false, TTL) + cache.setLastBuild(controller, 'job1', 80, false, TTL) then: - cache.getLastBuild(master, 'job1', false) == 80 - cache.getLastBuild(master, 'job1', true) == 78 + cache.getLastBuild(controller, 'job1', false) == 80 + cache.getLastBuild(controller, 'job1', true) == 78 } void 'when value is not found, -1 is returned'() { @@ -80,32 +80,32 @@ class BuildCacheSpec extends Specification { cache.getLastBuild('notthere', 'job1', true) == -1 } - void 'can set builds for multiple masters'() { + void 'can set builds for multiple controllers'() { when: - cache.setLastBuild(master, 'job1', 78, true, TTL) + cache.setLastBuild(controller, 'job1', 78, true, TTL) cache.setLastBuild('example2', 'job1', 88, true, TTL) then: - cache.getLastBuild(master, 'job1', true) == 78 + cache.getLastBuild(controller, 'job1', true) == 78 cache.getLastBuild('example2', 'job1', true) == 88 } - void 'correctly retrieves all jobsNames for a master'() { + void 'correctly retrieves all jobsNames for a controller'() { when: - cache.setLastBuild(master, 'job1', 78, true, TTL) - cache.setLastBuild(master, 'job2', 11, false, TTL) - cache.setLastBuild(master, 'blurb', 1, false, TTL) + cache.setLastBuild(controller, 'job1', 78, true, TTL) + cache.setLastBuild(controller, 'job2', 11, false, TTL) + cache.setLastBuild(controller, 'blurb', 1, false, TTL) then: - cache.getJobNames(master) == ['blurb', 'job2'] + cache.getJobNames(controller) == ['blurb', 'job2'] } @Unroll void 'retrieves all matching jobs for typeahead #query'() { when: - cache.setLastBuild(master, 'job1', 1, true, TTL) + cache.setLastBuild(controller, 'job1', 1, true, TTL) cache.setLastBuild(test, 'job1', 1, false, TTL) - cache.setLastBuild(master, 'job2', 1, false, TTL) + cache.setLastBuild(controller, 'job2', 1, false, TTL) cache.setLastBuild(test, 'job3', 1, false, TTL) then: @@ -113,10 +113,10 @@ class BuildCacheSpec extends Specification { where: query || expected - 'job' || ['master:job1', 'master:job2', 'test:job1', 'test:job3'] - 'job1' || ['master:job1', 'test:job1'] - 'ob1' || ['master:job1', 'test:job1'] - 'B2' || ['master:job2'] + 'job' || ['controller:job1', 'controller:job2', 'test:job1', 'test:job3'] + 'job1' || ['controller:job1', 'test:job1'] + 'ob1' || ['controller:job1', 'test:job1'] + 'B2' || ['controller:job2'] '3' || ['test:job3'] 'nope' || [] } @@ -128,19 +128,19 @@ class BuildCacheSpec extends Specification { BuildCache secondInstance = new BuildCache(redisClientDelegate, altCfg) when: - secondInstance.setLastBuild(master, 'job1', 1, false, TTL) + secondInstance.setLastBuild(controller, 'job1', 1, false, TTL) then: - secondInstance.getJobNames(master) == ['job1'] - cache.getJobNames(master) == [] + secondInstance.getJobNames(controller) == ['job1'] + cache.getJobNames(controller) == [] when: embeddedRedis.pool.resource.withCloseable { - it.del(cache.makeKey(master, 'job1')) + it.del(cache.makeKey(controller, 'job1')) } then: - secondInstance.getJobNames(master) == ['job1'] + secondInstance.getJobNames(controller) == ['job1'] } void 'should generate nice keys for completed jobs'() { @@ -161,10 +161,10 @@ class BuildCacheSpec extends Specification { void 'completed and running jobs should live in separate key space'() { when: - def masterKey = 'travis-ci' + def controllerKey = 'travis-ci' def slug = 'org/repo' then: - cache.makeKey(masterKey, slug, false) != cache.makeKey(masterKey, slug, true) + cache.makeKey(controllerKey, slug, false) != cache.makeKey(controllerKey, slug, true) } } diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/BuildControllerSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/BuildControllerSpec.groovy index ad88f79df..f2880ae6d 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/BuildControllerSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/BuildControllerSpec.groovy @@ -194,7 +194,7 @@ class BuildControllerSpec extends Specification { response.contentAsString == "[{\"building\":false,\"number\":111},{\"building\":false,\"number\":222}]" } - void 'get properties of a build with a bad master'() { + void 'get properties of a build with a bad controller'() { given: jenkinsService.getBuild(JOB_NAME, BUILD_NUMBER) >> new Build( number: BUILD_NUMBER, artifacts: [new BuildArtifact(fileName: "badFile.yml", relativePath: FILE_NAME)]) @@ -202,7 +202,7 @@ class BuildControllerSpec extends Specification { expect: mockMvc.perform( - get("/builds/properties/${BUILD_NUMBER}/${FILE_NAME}/badMaster/${JOB_NAME}") + get("/builds/properties/${BUILD_NUMBER}/${FILE_NAME}/badController/${JOB_NAME}") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isNotFound()) .andReturn().response @@ -238,7 +238,8 @@ class BuildControllerSpec extends Specification { response.contentAsString == "{\"foo\":\"bar\"}" } - void 'trigger a build without parameters'() { + @Deprecated + void 'trigger a build without parameters to old path'() { given: 1 * jenkinsService.getJobConfig(JOB_NAME) >> new JobConfig(buildable: true) 1 * jenkinsService.build(JOB_NAME) >> new Response("http://test.com", HTTP_201, "", [new Header("Location", "foo/${BUILD_NUMBER}")], null) @@ -254,7 +255,24 @@ class BuildControllerSpec extends Specification { 1 * pendingOperationService.setOperationStatus(_, PendingOperationsCache.OperationStatus.COMPLETED, BUILD_NUMBER.toString()) } - void 'trigger a build with parameters to a job with parameters'() { + void 'trigger a build without parameters'() { + given: + 1 * jenkinsService.getJobConfig(JOB_NAME) >> new JobConfig(buildable: true) + 1 * jenkinsService.build(JOB_NAME) >> new Response("http://test.com", HTTP_201, "", [new Header("Location", "foo/${BUILD_NUMBER}")], null) + + when: + MockHttpServletResponse response = mockMvc.perform(put("/controllers/${JENKINS_SERVICE}/jobs/${JOB_NAME}") + .accept(MediaType.APPLICATION_JSON)).andReturn().response + + then: + response.contentAsString == BUILD_NUMBER.toString() + + 1 * pendingOperationService.getAndSetOperationStatus(_, _, _) >> { new PendingOperationsCache.OperationState() } + 1 * pendingOperationService.setOperationStatus(_, PendingOperationsCache.OperationStatus.COMPLETED, BUILD_NUMBER.toString()) + } + + @Deprecated + void 'trigger a build with parameters to a job with parameters to old path'() { given: 1 * jenkinsService.getJobConfig(JOB_NAME) >> new JobConfig(buildable: true, parameterDefinitionList: [new ParameterDefinition(defaultParameterValue: [name: "name", value: null], description: "description")]) 1 * jenkinsService.buildWithParameters(JOB_NAME, [name: "myName"]) >> new Response("http://test.com", HTTP_201, "", [new Header("Location", "foo/${BUILD_NUMBER}")], null) @@ -267,7 +285,22 @@ class BuildControllerSpec extends Specification { response.contentAsString == BUILD_NUMBER.toString() } - void 'trigger a build without parameters to a job with parameters with default values'() { + void 'trigger a build with parameters to a job with parameters'() { + given: + 1 * jenkinsService.getJobConfig(JOB_NAME) >> new JobConfig(buildable: true, parameterDefinitionList: [new ParameterDefinition(defaultParameterValue: [name: "name", value: null], description: "description")]) + 1 * jenkinsService.buildWithParameters(JOB_NAME, [name: "myName"]) >> new Response("http://test.com", HTTP_201, "", [new Header("Location", "foo/${BUILD_NUMBER}")], null) + + when: + MockHttpServletResponse response = mockMvc.perform(put("/controllers/${JENKINS_SERVICE}/jobs/${JOB_NAME}") + .contentType(MediaType.APPLICATION_JSON).param("name", "myName")).andReturn().response + + then: + response.contentAsString == BUILD_NUMBER.toString() + } + + + @Deprecated + void 'trigger a build without parameters to a job with parameters with default values to old path'() { given: 1 * jenkinsService.getJobConfig(JOB_NAME) >> new JobConfig(buildable: true, parameterDefinitionList: [new ParameterDefinition(defaultParameterValue: [name: "name", value: "value"], description: "description")]) 1 * jenkinsService.buildWithParameters(JOB_NAME, ['startedBy': "igor"]) >> new Response("http://test.com", HTTP_201, "", [new Header("Location", "foo/${BUILD_NUMBER}")], null) @@ -280,7 +313,21 @@ class BuildControllerSpec extends Specification { response.contentAsString == BUILD_NUMBER.toString() } - void 'trigger a build with parameters to a job without parameters'() { + void 'trigger a build without parameters to a job with parameters with default values'() { + given: + 1 * jenkinsService.getJobConfig(JOB_NAME) >> new JobConfig(buildable: true, parameterDefinitionList: [new ParameterDefinition(defaultParameterValue: [name: "name", value: "value"], description: "description")]) + 1 * jenkinsService.buildWithParameters(JOB_NAME, ['startedBy': "igor"]) >> new Response("http://test.com", HTTP_201, "", [new Header("Location", "foo/${BUILD_NUMBER}")], null) + + when: + MockHttpServletResponse response = mockMvc.perform(put("/controllers/${JENKINS_SERVICE}/jobs/${JOB_NAME}", "") + .accept(MediaType.APPLICATION_JSON)).andReturn().response + + then: + response.contentAsString == BUILD_NUMBER.toString() + } + + @Deprecated + void 'trigger a build with parameters to a job without parameters to old path'() { given: 1 * jenkinsService.getJobConfig(JOB_NAME) >> new JobConfig(buildable: true) @@ -292,7 +339,20 @@ class BuildControllerSpec extends Specification { response.status == HttpStatus.INTERNAL_SERVER_ERROR.value() } - void 'trigger a build with an invalid choice'() { + void 'trigger a build with parameters to a job without parameters'() { + given: + 1 * jenkinsService.getJobConfig(JOB_NAME) >> new JobConfig(buildable: true) + + when: + MockHttpServletResponse response = mockMvc.perform(put("/controllers/${JENKINS_SERVICE}/jobs/${JOB_NAME}") + .contentType(MediaType.APPLICATION_JSON).param("foo", "bar")).andReturn().response + + then: + response.status == HttpStatus.INTERNAL_SERVER_ERROR.value() + } + + @Deprecated + void 'trigger a build with an invalid choice to old path'() { given: JobConfig config = new JobConfig(buildable: true) config.parameterDefinitionList = [ @@ -311,7 +371,27 @@ class BuildControllerSpec extends Specification { response.errorMessage == "`bat` is not a valid choice for `foo`. Valid choices are: bar, baz" } - void 'trigger a disabled build'() { + void 'trigger a build with an invalid choice'() { + given: + JobConfig config = new JobConfig(buildable: true) + config.parameterDefinitionList = [ + new ParameterDefinition(type: "ChoiceParameterDefinition", name: "foo", choices: ["bar", "baz"]) + ] + 1 * jenkinsService.getJobConfig(JOB_NAME) >> config + 1 * exceptionMessageDecorator.decorate(_, _) >> "`bat` is not a valid choice for `foo`. Valid choices are: bar, baz" + + when: + MockHttpServletResponse response = mockMvc.perform(put("/controllers/${JENKINS_SERVICE}/jobs/${JOB_NAME}") + .contentType(MediaType.APPLICATION_JSON).param("foo", "bat")).andReturn().response + + then: + + response.status == HttpStatus.BAD_REQUEST.value() + response.errorMessage == "`bat` is not a valid choice for `foo`. Valid choices are: bar, baz" + } + + @Deprecated + void 'trigger a disabled build to old path'() { given: JobConfig config = new JobConfig() 1 * jenkinsService.getJobConfig(JOB_NAME) >> config @@ -326,6 +406,21 @@ class BuildControllerSpec extends Specification { response.errorMessage == "Job '${JOB_NAME}' is not buildable. It may be disabled." } + void 'trigger a disabled build'() { + given: + JobConfig config = new JobConfig() + 1 * jenkinsService.getJobConfig(JOB_NAME) >> config + 1 * exceptionMessageDecorator.decorate(_, _) >> "Job '${JOB_NAME}' is not buildable. It may be disabled." + + when: + MockHttpServletResponse response = mockMvc.perform(put("/controllers/${JENKINS_SERVICE}/jobs/${JOB_NAME}") + .contentType(MediaType.APPLICATION_JSON).param("foo", "bat")).andReturn().response + + then: + response.status == HttpStatus.BAD_REQUEST.value() + response.errorMessage == "Job '${JOB_NAME}' is not buildable. It may be disabled." + } + void 'validation successful for null list of choices'() { given: Map requestParams = ["hey": "you"] @@ -361,7 +456,8 @@ class BuildControllerSpec extends Specification { } - void "doesn't trigger a build when previous request is still in progress"() { + @Deprecated + void "doesn't trigger a build when previous request is still in progress to old path"() { given: pendingOperationService = Stub(PendingOperationsCache) pendingOperationService.getAndSetOperationStatus("${JENKINS_SERVICE}:${PENDING_JOB_NAME}:NO_EXECUTION_ID:foo=bat", _, _) >> { @@ -381,7 +477,28 @@ class BuildControllerSpec extends Specification { response.status == HttpStatus.ACCEPTED.value() } - void "resets the cache once the build status has been retrieved"() { + void "doesn't trigger a build when previous request is still in progress"() { + given: + pendingOperationService = Stub(PendingOperationsCache) + pendingOperationService.getAndSetOperationStatus("${JENKINS_SERVICE}:${PENDING_JOB_NAME}:NO_EXECUTION_ID:foo=bat", _, _) >> { + return new PendingOperationsCache.OperationState(PendingOperationsCache.OperationStatus.PENDING) + } + + mockMvc = MockMvcBuilders + .standaloneSetup(new BuildController(buildServices, pendingOperationService, Optional.empty(), Optional.empty(), Optional.empty())) + .setControllerAdvice(new GenericExceptionHandlers()) + .build() + + when: + MockHttpServletResponse response = mockMvc.perform(put("/controllers/${JENKINS_SERVICE}/jobs/${PENDING_JOB_NAME}") + .contentType(MediaType.APPLICATION_JSON).param("foo", "bat")).andReturn().response + + then: + response.status == HttpStatus.ACCEPTED.value() + } + + @Deprecated + void "resets the cache once the build status has been retrieved to old path"() { given: pendingOperationService = Mock(PendingOperationsCache) pendingOperationService.getAndSetOperationStatus("${JENKINS_SERVICE}:${JOB_NAME}:NO_EXECUTION_ID:foo=bat", _, _) >> { @@ -405,7 +522,32 @@ class BuildControllerSpec extends Specification { 1 * pendingOperationService.clear("${JENKINS_SERVICE}:${JOB_NAME}:NO_EXECUTION_ID:foo=bat") } - void "updates a jenkins build description"() { + void "resets the cache once the build status has been retrieved"() { + given: + pendingOperationService = Mock(PendingOperationsCache) + pendingOperationService.getAndSetOperationStatus("${JENKINS_SERVICE}:${JOB_NAME}:NO_EXECUTION_ID:foo=bat", _, _) >> { + PendingOperationsCache.OperationState state = new PendingOperationsCache.OperationState() + state.load(PendingOperationsCache.OperationStatus.COMPLETED.toString() + ":" + BUILD_NUMBER) + return state + } + + mockMvc = MockMvcBuilders + .standaloneSetup(new BuildController(buildServices, pendingOperationService, Optional.empty(), Optional.empty(), Optional.empty())) + .setControllerAdvice(new GenericExceptionHandlers()) + .build() + + when: + MockHttpServletResponse response = mockMvc.perform(put("/controllers/${JENKINS_SERVICE}/jobs/${JOB_NAME}") + .contentType(MediaType.APPLICATION_JSON).param("foo", "bat")).andReturn().response + + then: + response.status == HttpStatus.OK.value() + response.contentAsString == BUILD_NUMBER.toString() + 1 * pendingOperationService.clear("${JENKINS_SERVICE}:${JOB_NAME}:NO_EXECUTION_ID:foo=bat") + } + + @Deprecated + void "updates a jenkins build description to old path"() { when: MockHttpServletResponse response = mockMvc.perform( patch("/masters/${JENKINS_SERVICE}/jobs/${jobName}/update/${BUILD_NUMBER}") @@ -428,4 +570,28 @@ class BuildControllerSpec extends Specification { "simpleJobName" ] } + + void "updates a jenkins build description"() { + when: + MockHttpServletResponse response = mockMvc.perform( + patch("/controllers/${JENKINS_SERVICE}/jobs/${jobName}/update/${BUILD_NUMBER}") + .contentType(MediaType.APPLICATION_JSON) + .content(""" +{ + "description": "this is my new description" +} +""") + ).andReturn().response + + then: + 1 * jenkinsService.updateBuild(jobName, BUILD_NUMBER, new UpdatedBuild("this is my new description")) + 0 * _ + response.status == 200 + + where: + jobName << [ + "complex/job/name/with/slashes", + "simpleJobName" + ] + } } diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/InfoControllerSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/InfoControllerSpec.groovy index 35a9c1e00..cb7b3841b 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/InfoControllerSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/build/InfoControllerSpec.groovy @@ -90,18 +90,31 @@ class InfoControllerSpec extends Specification { .build() } + @Deprecated void 'is able to get a list of jenkins buildMasters'() { given: - createMocks(['master2': null, 'build.buildServices.blah': null, 'master1': null]) + createMocks(['controller2': null, 'build.buildServices.blah': null, 'controller1': null]) when: MockHttpServletResponse response = mockMvc.perform(get('/masters/') .accept(MediaType.APPLICATION_JSON)).andReturn().response then: - response.contentAsString == '["build.buildServices.blah","master1","master2"]' + response.contentAsString == '["build.buildServices.blah","controller1","controller2"]' } + void 'is able to get a list of jenkins buildControllers'() { + given: + createMocks(['controller2': null, 'build.buildServices.blah': null, 'controller1': null]) + + when: + MockHttpServletResponse response = mockMvc.perform(get('/controllers/') + .accept(MediaType.APPLICATION_JSON)).andReturn().response + + then: + response.contentAsString == '["build.buildServices.blah","controller1","controller2"]' + } + void 'is able to get a list of google cloud build accounts'() { given: createMocks([:], [createGCBAccount("account1"), createGCBAccount("account2")]) @@ -133,8 +146,8 @@ class InfoControllerSpec extends Specification { void 'buildServices returns correctly if gcb is not defined'() { given: - JenkinsService jenkinsService1 = new JenkinsService('master2', null, false, Permissions.EMPTY, circuitBreakerRegistry) - createMocks(['master2': jenkinsService1]) + JenkinsService jenkinsService1 = new JenkinsService('controller2', null, false, Permissions.EMPTY, circuitBreakerRegistry) + createMocks(['controller2': jenkinsService1]) when: MockHttpServletResponse response = mockMvc.perform(get('/buildServices') @@ -143,7 +156,7 @@ class InfoControllerSpec extends Specification { then: def actualAccounts = new JsonSlurper().parseText(response.contentAsString); actualAccounts.size == 1 - actualAccounts[0].name == 'master2' + actualAccounts[0].name == 'controller2' } @@ -235,13 +248,13 @@ class InfoControllerSpec extends Specification { ) } - void 'is able to get jobs for a jenkins master'() { + void 'is able to get jobs for a jenkins controller'() { given: JenkinsService jenkinsService = Stub(JenkinsService) - createMocks(['master1': jenkinsService]) + createMocks(['controller1': jenkinsService]) when: - MockHttpServletResponse response = mockMvc.perform(get('/jobs/master1/') + MockHttpServletResponse response = mockMvc.perform(get('/jobs/controller1/') .accept(MediaType.APPLICATION_JSON)).andReturn().response then: @@ -253,13 +266,13 @@ class InfoControllerSpec extends Specification { response.contentAsString == '["job1","job2","job3"]' } - void 'is able to get jobs for a jenkins master with the folders plugin'() { + void 'is able to get jobs for a jenkins controller with the folders plugin'() { given: JenkinsService jenkinsService = Stub(JenkinsService) - createMocks(['master1': jenkinsService]) + createMocks(['controller1': jenkinsService]) when: - MockHttpServletResponse response = mockMvc.perform(get('/jobs/master1/') + MockHttpServletResponse response = mockMvc.perform(get('/jobs/controller1/') .accept(MediaType.APPLICATION_JSON)).andReturn().response then: @@ -274,30 +287,30 @@ class InfoControllerSpec extends Specification { response.contentAsString == '["folder/job/job1","folder/job/job2","job3"]' } - void 'is able to get jobs for a travis master'() { + void 'is able to get jobs for a travis controller'() { given: TravisService travisService = Stub(TravisService) - createMocks(['travis-master1': travisService]) + createMocks(['travis-controller1': travisService]) when: - MockHttpServletResponse response = mockMvc.perform(get('/jobs/travis-master1') + MockHttpServletResponse response = mockMvc.perform(get('/jobs/travis-controller1') .accept(MediaType.APPLICATION_JSON)).andReturn().response then: travisService.getBuildServiceProvider() >> BuildServiceProvider.TRAVIS - 1 * cache.getJobNames('travis-master1') >> ["some-job"] + 1 * cache.getJobNames('travis-controller1') >> ["some-job"] response.contentAsString == '["some-job"]' } - void 'is able to get jobs for a wercker master'() { + void 'is able to get jobs for a wercker controller'() { given: def werckerJob = 'myOrg/myApp/myTarget' WerckerService werckerService = Stub(WerckerService) - createMocks(['wercker-master': werckerService]) + createMocks(['wercker-controller': werckerService]) when: - MockHttpServletResponse response = mockMvc.perform(get('/jobs/wercker-master') + MockHttpServletResponse response = mockMvc.perform(get('/jobs/wercker-controller') .accept(MediaType.APPLICATION_JSON)).andReturn().response then: @@ -325,10 +338,10 @@ class InfoControllerSpec extends Specification { void 'is able to get a job config at url #url'() { given: setResponse(getJobConfig()) - createMocks(['master1': service]) + createMocks(['controller1': service]) when: - MockHttpServletResponse response = mockMvc.perform(get('/jobs/master1/MY-JOB') + MockHttpServletResponse response = mockMvc.perform(get('/jobs/controller1/MY-JOB') .accept(MediaType.APPLICATION_JSON)).andReturn().response then: @@ -340,16 +353,16 @@ class InfoControllerSpec extends Specification { output.firstBuild == null where: - url << ['/jobs/master1/MY-JOB', '/jobs/master1/folder/job/MY-JOB'] + url << ['/jobs/controller1/MY-JOB', '/jobs/controller1/folder/job/MY-JOB'] } void 'is able to get a job config where a parameter includes choices'() { given: setResponse(getJobConfigWithChoices()) - createMocks(['master1': service]) + createMocks(['controller1': service]) when: - MockHttpServletResponse response = mockMvc.perform(get('/jobs/master1/MY-JOB') + MockHttpServletResponse response = mockMvc.perform(get('/jobs/controller1/MY-JOB') .accept(MediaType.APPLICATION_JSON)).andReturn().response then: diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/gitlabci/GitlabCiBuildMonitorSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/gitlabci/GitlabCiBuildMonitorSpec.groovy index 7195f81ba..6ea919ce8 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/gitlabci/GitlabCiBuildMonitorSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/gitlabci/GitlabCiBuildMonitorSpec.groovy @@ -39,14 +39,14 @@ class GitlabCiBuildMonitorSpec extends Specification { EchoService echoService = Mock(EchoService) GitlabCiBuildMonitor buildMonitor - String MASTER = "MASTER" + String CONTROLLER = "CONTROLLER" int CACHED_JOB_TTL_SECONDS = 172800 int CACHED_JOB_TTL_DAYS = 2 void setup() { def properties = new GitlabCiProperties(cachedJobTTLDays: CACHED_JOB_TTL_DAYS) def buildServices = new BuildServices() - buildServices.addServices([MASTER: service]) + buildServices.addServices([CONTROLLER: service]) buildMonitor = new GitlabCiBuildMonitor( new IgorConfigurationProperties(), new NoopRegistry(), @@ -70,15 +70,15 @@ class GitlabCiBuildMonitorSpec extends Specification { service.getProjects() >> [project] service.getPipelines(project, _) >> [pipeline] - buildCache.getJobNames(MASTER) >> jobsInCache - buildCache.getLastBuild(MASTER, _, false) >> lastBuildNr + buildCache.getJobNames(CONTROLLER) >> jobsInCache + buildCache.getLastBuild(CONTROLLER, _, false) >> lastBuildNr when: - buildMonitor.pollSingle(new PollContext(MASTER)) + buildMonitor.pollSingle(new PollContext(CONTROLLER)) then: - 1 * buildCache.setLastBuild(MASTER, "user1/project1", 101, false, CACHED_JOB_TTL_SECONDS) - 1 * buildCache.setLastBuild(MASTER, "user1/project1/master", 101, false, CACHED_JOB_TTL_SECONDS) + 1 * buildCache.setLastBuild(CONTROLLER, "user1/project1", 101, false, CACHED_JOB_TTL_SECONDS) + 1 * buildCache.setLastBuild(CONTROLLER, "user1/project1/master", 101, false, CACHED_JOB_TTL_SECONDS) and: 1 * echoService.postEvent({ @@ -104,15 +104,15 @@ class GitlabCiBuildMonitorSpec extends Specification { service.getProjects() >> [project] service.getPipelines(project, _) >> [pipeline] - buildCache.getJobNames(MASTER) >> jobsInCache - buildCache.getLastBuild(MASTER, _, false) >> lastBuildNr + buildCache.getJobNames(CONTROLLER) >> jobsInCache + buildCache.getLastBuild(CONTROLLER, _, false) >> lastBuildNr when: - buildMonitor.pollSingle(new PollContext(MASTER).fastForward()) + buildMonitor.pollSingle(new PollContext(CONTROLLER).fastForward()) then: - 1 * buildCache.setLastBuild(MASTER, "user1/project1", 101, false, CACHED_JOB_TTL_SECONDS) - 1 * buildCache.setLastBuild(MASTER, "user1/project1/master", 101, false, CACHED_JOB_TTL_SECONDS) + 1 * buildCache.setLastBuild(CONTROLLER, "user1/project1", 101, false, CACHED_JOB_TTL_SECONDS) + 1 * buildCache.setLastBuild(CONTROLLER, "user1/project1/master", 101, false, CACHED_JOB_TTL_SECONDS) and: 0 * echoService.postEvent(_) @@ -130,10 +130,10 @@ class GitlabCiBuildMonitorSpec extends Specification { service.getProjects() >> [project] service.getPipelines(project, _) >> [pipeline] - buildCache.getJobNames(MASTER) >> [] + buildCache.getJobNames(CONTROLLER) >> [] when: - buildMonitor.pollSingle(new PollContext(MASTER)) + buildMonitor.pollSingle(new PollContext(CONTROLLER)) then: 0 * buildCache.setLastBuild(_, _, _, _, _) @@ -149,11 +149,11 @@ class GitlabCiBuildMonitorSpec extends Specification { service.getProjects() >> [project] service.getPipelines(project, _) >> [pipeline] - buildCache.getJobNames(MASTER) >> ["user1/project1/master"] - buildCache.getLastBuild(MASTER, "user1/project1/master", false) >> 102 + buildCache.getJobNames(CONTROLLER) >> ["user1/project1/master"] + buildCache.getLastBuild(CONTROLLER, "user1/project1/master", false) >> 102 when: - buildMonitor.pollSingle(new PollContext(MASTER)) + buildMonitor.pollSingle(new PollContext(CONTROLLER)) then: 0 * buildCache.setLastBuild(_, _, _, _, _) diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsBuildMonitorSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsBuildMonitorSpec.groovy index fc614ad5d..eaa4c602b 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsBuildMonitorSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsBuildMonitorSpec.groovy @@ -45,11 +45,11 @@ class JenkinsBuildMonitorSpec extends Specification { IgorConfigurationProperties igorConfigurationProperties = new IgorConfigurationProperties() JenkinsBuildMonitor monitor - def MASTER = 'MASTER' + def CONTROLLER = 'CONTROLLER' void setup() { def buildServices = new BuildServices() - buildServices.addServices([MASTER: jenkinsService]) + buildServices.addServices([CONTROLLER: jenkinsService]) monitor = new JenkinsBuildMonitor( igorConfigurationProperties, new NoopRegistry(), @@ -70,7 +70,7 @@ class JenkinsBuildMonitorSpec extends Specification { jenkinsService.getProjects().getList() >> new Exception("failed") when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: notThrown(Exception) @@ -81,10 +81,10 @@ class JenkinsBuildMonitorSpec extends Specification { jenkinsService.getProjects() >> new ProjectsList(list: [new Project(name: 'job2', lastBuild: null)]) when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: - 0 * cache.getLastPollCycleTimestamp(MASTER, 'job2') + 0 * cache.getLastPollCycleTimestamp(CONTROLLER, 'job2') 0 * cache.setLastPollCycleTimestamp(_,_,_) } @@ -94,13 +94,13 @@ class JenkinsBuildMonitorSpec extends Specification { def lastBuild = new Build(number: 1, timestamp: '1494624092610', building: false, result: 'SUCCESS') and: - cache.getLastPollCycleTimestamp(MASTER, 'job') >> previousCursor + cache.getLastPollCycleTimestamp(CONTROLLER, 'job') >> previousCursor jenkinsService.getProjects() >> new ProjectsList(list: [ new Project(name: 'job', lastBuild: lastBuild) ]) cache.getEventPosted(_,_,_,_) >> false jenkinsService.getBuilds('job') >> [lastBuild ] when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 1 * echoService.postEvent({ it.content.project.lastBuild.number == 1 && it.content.project.lastBuild.result == 'SUCCESS'} as Event) @@ -112,13 +112,13 @@ class JenkinsBuildMonitorSpec extends Specification { def lastBuild = new Build(number: 1, timestamp: '1494624092610', building: false, result: 'SUCCESS') and: - cache.getLastPollCycleTimestamp(MASTER, 'job') >> previousCursor + cache.getLastPollCycleTimestamp(CONTROLLER, 'job') >> previousCursor jenkinsService.getProjects() >> new ProjectsList(list: [ new Project(name: 'job', lastBuild: lastBuild) ]) cache.getEventPosted(_,_,_,_) >> false jenkinsService.getBuilds('job') >> [lastBuild ] when: - monitor.pollSingle(new PollContext(MASTER).fastForward()) + monitor.pollSingle(new PollContext(CONTROLLER).fastForward()) then: 0 * echoService.postEvent(_) @@ -139,7 +139,7 @@ class JenkinsBuildMonitorSpec extends Specification { assert new Date(stamp3 as Long) < new Date(stamp4 as Long) and: - cache.getLastPollCycleTimestamp(MASTER, 'job') >> (previousCursor as Long) + cache.getLastPollCycleTimestamp(CONTROLLER, 'job') >> (previousCursor as Long) jenkinsService.getProjects() >> new ProjectsList(list: [ new Project(name: 'job', lastBuild: lastBuild) ]) cache.getEventPosted(_,_,_,_) >> false jenkinsService.getBuilds('job') >> [ @@ -151,7 +151,7 @@ class JenkinsBuildMonitorSpec extends Specification { ] when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 'only builds between lowerBound(previousCursor) and upperbound(stamp3) will fire events' 1 * echoService.postEvent({ it.content.project.lastBuild.number == 1 && it.content.project.lastBuild.result == 'SUCCESS'} as Event) @@ -173,7 +173,7 @@ class JenkinsBuildMonitorSpec extends Specification { assert new Date(stamp3 as Long) < new Date(stamp4 as Long) and: - cache.getLastPollCycleTimestamp(MASTER, 'job') >> (previousCursor as Long) + cache.getLastPollCycleTimestamp(CONTROLLER, 'job') >> (previousCursor as Long) jenkinsService.getProjects() >> new ProjectsList(list: [ new Project(name: 'job', lastBuild: lastBuild) ]) cache.getEventPosted(_,_,_,_) >> false jenkinsService.getBuilds('job') >> [ @@ -184,7 +184,7 @@ class JenkinsBuildMonitorSpec extends Specification { ] when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 'only builds between lowerBound(previousCursor) and upperbound(stamp3) will fire events' 1 * echoService.postEvent({ it.content.project.lastBuild.number == 1 && it.content.project.lastBuild.result == 'SUCCESS'} as Event) @@ -192,8 +192,8 @@ class JenkinsBuildMonitorSpec extends Specification { 1 * echoService.postEvent({ it.content.project.lastBuild.number == 3 && it.content.project.lastBuild.result == 'SUCCESS'} as Event) and: 'prune old markers and set new cursor' - 1 * cache.pruneOldMarkers(MASTER, 'job', 1494624092609) - 1 * cache.setLastPollCycleTimestamp(MASTER, 'job', 1494624092612) + 1 * cache.pruneOldMarkers(CONTROLLER, 'job', 1494624092609) + 1 * cache.setLastPollCycleTimestamp(CONTROLLER, 'job', 1494624092612) } @@ -228,7 +228,7 @@ class JenkinsBuildMonitorSpec extends Specification { ] when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 'build #3 only will be processed' 0 * echoService.postEvent({ it.content.project.lastBuild.number == 1 && it.content.project.lastBuild.result == 'SUCCESS'} as Event) @@ -236,7 +236,7 @@ class JenkinsBuildMonitorSpec extends Specification { 1 * echoService.postEvent({ it.content.project.lastBuild.number == 3 && it.content.project.lastBuild.result == 'SUCCESS'} as Event) } - def 'should continue processing other builds from a master even if one or more build fetches fail'() { + def 'should continue processing other builds from a controller even if one or more build fetches fail'() { given: long now = System.currentTimeMillis() long nowMinus30min = now - (30 * 60 * 1000) // 30 minutes ago @@ -244,7 +244,7 @@ class JenkinsBuildMonitorSpec extends Specification { igorConfigurationProperties.spinnaker.build.processBuildsOlderThanLookBackWindow = true - and: 'three jobs in a master' + and: 'three jobs in a controller' jenkinsService.getProjects() >> new ProjectsList(list: [ new Project(name: 'job1', lastBuild: new Build(number: 1, timestamp: now)), new Project(name: 'job2', lastBuild: new Build(number: 2, timestamp: now)), @@ -267,7 +267,7 @@ class JenkinsBuildMonitorSpec extends Specification { monitor.log = Mock(Logger); when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 'Builds are processed for job1' 1 * echoService.postEvent({ it.content.project.name == 'job1'} as Event) diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsCacheSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsCacheSpec.groovy index 629aaa527..f1458cef1 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsCacheSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/jenkins/JenkinsCacheSpec.groovy @@ -34,7 +34,7 @@ class JenkinsCacheSpec extends Specification { @Subject JenkinsCache cache = new JenkinsCache(redisClientDelegate, new IgorConfigurationProperties()) - def master = 'master' + def controller = 'controller' def test = 'test' void cleanup() { @@ -46,30 +46,30 @@ class JenkinsCacheSpec extends Specification { void 'new build numbers get overridden'() { when: - cache.setLastBuild(master, 'job1', 78, true) + cache.setLastBuild(controller, 'job1', 78, true) then: - cache.getLastBuild(master, 'job1').lastBuildLabel == 78 + cache.getLastBuild(controller, 'job1').lastBuildLabel == 78 when: - cache.setLastBuild(master, 'job1', 80, false) + cache.setLastBuild(controller, 'job1', 80, false) then: - cache.getLastBuild(master, 'job1').lastBuildLabel == 80 + cache.getLastBuild(controller, 'job1').lastBuildLabel == 80 } void 'statuses get overridden'() { when: - cache.setLastBuild(master, 'job1', 78, true) + cache.setLastBuild(controller, 'job1', 78, true) then: - cache.getLastBuild(master, 'job1').lastBuildBuilding == true + cache.getLastBuild(controller, 'job1').lastBuildBuilding == true when: - cache.setLastBuild(master, 'job1', 78, false) + cache.setLastBuild(controller, 'job1', 78, false) then: - cache.getLastBuild(master, 'job1').lastBuildBuilding == false + cache.getLastBuild(controller, 'job1').lastBuildBuilding == false } @@ -78,41 +78,41 @@ class JenkinsCacheSpec extends Specification { cache.getLastBuild('notthere', 'job1') == [:] } - void 'can set builds for multiple masters'() { + void 'can set builds for multiple controllers'() { when: - cache.setLastBuild(master, 'job1', 78, true) + cache.setLastBuild(controller, 'job1', 78, true) cache.setLastBuild('example2', 'job1', 88, true) then: - cache.getLastBuild(master, 'job1').lastBuildLabel == 78 + cache.getLastBuild(controller, 'job1').lastBuildLabel == 78 cache.getLastBuild('example2', 'job1').lastBuildLabel == 88 } - void 'correctly retrieves all jobsNames for a master'() { + void 'correctly retrieves all jobsNames for a controller'() { when: - cache.setLastBuild(master, 'job1', 78, true) - cache.setLastBuild(master, 'job2', 11, false) - cache.setLastBuild(master, 'blurb', 1, false) + cache.setLastBuild(controller, 'job1', 78, true) + cache.setLastBuild(controller, 'job2', 11, false) + cache.setLastBuild(controller, 'blurb', 1, false) then: - cache.getJobNames(master) == ['blurb', 'job1', 'job2'] + cache.getJobNames(controller) == ['blurb', 'job1', 'job2'] } void 'can remove details for a build'() { when: - cache.setLastBuild(master, 'job1', 78, true) - cache.remove(master, 'job1') + cache.setLastBuild(controller, 'job1', 78, true) + cache.remove(controller, 'job1') then: - cache.getLastBuild(master, 'job1') == [:] + cache.getLastBuild(controller, 'job1') == [:] } @Unroll void 'retrieves all matching jobs for typeahead #query'() { when: - cache.setLastBuild(master, 'job1', 1, true) + cache.setLastBuild(controller, 'job1', 1, true) cache.setLastBuild(test, 'job1', 1, false) - cache.setLastBuild(master, 'job2', 1, false) + cache.setLastBuild(controller, 'job2', 1, false) cache.setLastBuild(test, 'job3', 1, false) then: @@ -120,10 +120,10 @@ class JenkinsCacheSpec extends Specification { where: query || expected - 'job' || ['master:job1', 'master:job2', 'test:job1', 'test:job3'] - 'job1' || ['master:job1', 'test:job1'] - 'ob1' || ['master:job1', 'test:job1'] - 'B2' || ['master:job2'] + 'job' || ['controller:job1', 'controller:job2', 'test:job1', 'test:job3'] + 'job1' || ['controller:job1', 'test:job1'] + 'ob1' || ['controller:job1', 'test:job1'] + 'B2' || ['controller:job2'] '3' || ['test:job3'] 'nope' || [] } @@ -135,16 +135,16 @@ class JenkinsCacheSpec extends Specification { JenkinsCache secondInstance = new JenkinsCache(redisClientDelegate, cfg) when: - secondInstance.setLastBuild(master, 'job1', 1, false) + secondInstance.setLastBuild(controller, 'job1', 1, false) then: - secondInstance.getJobNames(master) == ['job1'] - cache.getJobNames(master) == [] + secondInstance.getJobNames(controller) == ['job1'] + cache.getJobNames(controller) == [] when: - cache.remove(master, 'job1') + cache.remove(controller, 'job1') then: - secondInstance.getJobNames(master) == ['job1'] + secondInstance.getJobNames(controller) == ['job1'] } } diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/ManagedDeliveryScmServiceSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/ManagedDeliveryScmServiceSpec.groovy index 3b1b0ac5e..2f0673d90 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/ManagedDeliveryScmServiceSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/ManagedDeliveryScmServiceSpec.groovy @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.dataformat.yaml.YAMLFactory import com.netflix.spinnaker.igor.config.ManagedDeliveryConfigProperties import com.netflix.spinnaker.igor.scm.stash.client.StashClient -import com.netflix.spinnaker.igor.scm.stash.client.StashMaster +import com.netflix.spinnaker.igor.scm.stash.client.StashController import com.netflix.spinnaker.igor.scm.stash.client.model.DirectoryChild import com.netflix.spinnaker.igor.scm.stash.client.model.DirectoryChildren import com.netflix.spinnaker.igor.scm.stash.client.model.DirectoryListingResponse @@ -29,7 +29,7 @@ import com.netflix.spinnaker.igor.scm.stash.client.model.TextLinesResponse import spock.lang.Specification import spock.lang.Subject -import static com.netflix.spinnaker.igor.scm.stash.client.StashMaster.DEFAULT_PAGED_RESPONSE_LIMIT +import static com.netflix.spinnaker.igor.scm.stash.client.StashController.DEFAULT_PAGED_RESPONSE_LIMIT class ManagedDeliveryScmServiceSpec extends Specification { @Subject @@ -44,7 +44,7 @@ class ManagedDeliveryScmServiceSpec extends Specification { void setup() { service = new ManagedDeliveryScmService( Optional.of(new ManagedDeliveryConfigProperties(manifestBasePath: ".spinnaker")), - Optional.of(new StashMaster(stashClient: client, baseUrl : STASH_ADDRESS)), + Optional.of(new StashController(stashClient: client, baseUrl : STASH_ADDRESS)), Optional.empty(), Optional.empty(), Optional.empty() diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/ScmInfoControllerSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/ScmInfoControllerSpec.groovy index 835f3eeb1..576af8a7c 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/ScmInfoControllerSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/ScmInfoControllerSpec.groovy @@ -17,11 +17,11 @@ package com.netflix.spinnaker.igor.scm import com.netflix.spinnaker.igor.scm.github.client.GitHubClient -import com.netflix.spinnaker.igor.scm.github.client.GitHubMaster +import com.netflix.spinnaker.igor.scm.github.client.GitHubController import com.netflix.spinnaker.igor.scm.stash.client.StashClient -import com.netflix.spinnaker.igor.scm.stash.client.StashMaster +import com.netflix.spinnaker.igor.scm.stash.client.StashController import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketClient -import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketMaster +import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketController import spock.lang.Specification import spock.lang.Subject @@ -38,18 +38,29 @@ class ScmInfoControllerSpec extends Specification { BitBucketClient bitBucketClient = Mock(BitBucketClient) void setup() { - controller = new ScmInfoController(gitHubMaster: new GitHubMaster(gitHubClient: gitHubClient, baseUrl: "https://github.com"), - stashMaster: new StashMaster(stashClient: stashClient, baseUrl: "http://stash.com"), - bitBucketMaster: new BitBucketMaster(bitBucketClient: bitBucketClient, baseUrl: "https://api.bitbucket.org")) + controller = new ScmInfoController(gitHubController: new GitHubController(gitHubClient: gitHubClient, baseUrl: "https://github.com"), + stashController: new StashController(stashClient: stashClient, baseUrl: "http://stash.com"), + bitBucketController: new BitBucketController(bitBucketClient: bitBucketClient, baseUrl: "https://api.bitbucket.org")) } + @Deprecated(forRemoval = true) void 'list masters'() { when: - Map listMastersResponse = controller.listMasters() + Map listControllersResponse = controller.listMasters() then: - listMastersResponse.stash == "http://stash.com" - listMastersResponse.gitHub == "https://github.com" - listMastersResponse.bitBucket == "https://api.bitbucket.org" + listControllersResponse.stash == "http://stash.com" + listControllersResponse.gitHub == "https://github.com" + listControllersResponse.bitBucket == "https://api.bitbucket.org" + } + + void 'list controllers'() { + when: + Map listControllersResponse = controller.listControllers() + + then: + listControllersResponse.stash == "http://stash.com" + listControllersResponse.gitHub == "https://github.com" + listControllersResponse.bitBucket == "https://api.bitbucket.org" } } diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/bitbucket/CommitControllerSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/bitbucket/CommitControllerSpec.groovy index 8dee934e8..9d553df20 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/bitbucket/CommitControllerSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/bitbucket/CommitControllerSpec.groovy @@ -19,7 +19,7 @@ package com.netflix.spinnaker.igor.scm.bitbucket import com.netflix.spinnaker.igor.config.BitBucketProperties import com.netflix.spinnaker.igor.scm.AbstractCommitController import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketClient -import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketMaster +import com.netflix.spinnaker.igor.scm.bitbucket.client.BitBucketController import com.netflix.spinnaker.igor.scm.bitbucket.client.model.Author import com.netflix.spinnaker.igor.scm.bitbucket.client.model.Commit import com.netflix.spinnaker.igor.scm.bitbucket.client.model.CompareCommitsResponse @@ -44,7 +44,7 @@ class CommitControllerSpec extends Specification { def BITBUCKET_ADDRESS = "https://api.bitbucket.org" void setup() { - controller = new CommitController(executor: Executors.newSingleThreadExecutor(), bitBucketMaster: new BitBucketMaster(bitBucketClient: client, baseUrl : BITBUCKET_ADDRESS), bitBucketProperties: new BitBucketProperties(commitDisplayLength: 7)) + controller = new CommitController(executor: Executors.newSingleThreadExecutor(), bitBucketController: new BitBucketController(bitBucketClient: client, baseUrl : BITBUCKET_ADDRESS), bitBucketProperties: new BitBucketProperties(commitDisplayLength: 7)) } void 'missing query params'() { diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/CommitControllerSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/CommitControllerSpec.groovy index 8383cd1fe..5a7eec424 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/CommitControllerSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/CommitControllerSpec.groovy @@ -19,7 +19,7 @@ package com.netflix.spinnaker.igor.scm.github import com.netflix.spinnaker.igor.config.GitHubProperties import com.netflix.spinnaker.igor.scm.AbstractCommitController import com.netflix.spinnaker.igor.scm.github.client.GitHubClient -import com.netflix.spinnaker.igor.scm.github.client.GitHubMaster +import com.netflix.spinnaker.igor.scm.github.client.GitHubController import com.netflix.spinnaker.igor.scm.github.client.model.Author import com.netflix.spinnaker.igor.scm.github.client.model.Commit import com.netflix.spinnaker.igor.scm.github.client.model.CommitInfo @@ -45,7 +45,7 @@ class CommitControllerSpec extends Specification { def GITHUB_ADDRESS = "https://github.com" void setup() { - controller = new CommitController(executor: Executors.newSingleThreadExecutor(), master: new GitHubMaster(gitHubClient: client, baseUrl : GITHUB_ADDRESS), gitHubProperties: new GitHubProperties(commitDisplayLength: 8)) + controller = new CommitController(executor: Executors.newSingleThreadExecutor(), controller: new GitHubController(gitHubClient: client, baseUrl : GITHUB_ADDRESS), gitHubProperties: new GitHubProperties(commitDisplayLength: 8)) } void 'missing query params'() { diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubMasterSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubControllerSpec.groovy similarity index 83% rename from igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubMasterSpec.groovy rename to igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubControllerSpec.groovy index 3416ecd0a..99a35e02b 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubMasterSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/github/client/GitHubControllerSpec.groovy @@ -21,14 +21,14 @@ import com.netflix.spinnaker.igor.scm.github.client.model.GetRepositoryContentRe import spock.lang.Specification import spock.lang.Subject -class GitHubMasterSpec extends Specification { +class GitHubControllerSpec extends Specification { @Subject - GitHubMaster gitHubMaster + GitHubController gitHubController GitHubClient gitHubClient = Mock(GitHubClient) void setup() { - gitHubMaster = new GitHubMaster(gitHubClient: gitHubClient, baseUrl: "") + gitHubController = new GitHubController(gitHubClient: gitHubClient, baseUrl: "") } void 'list directory'() { @@ -36,7 +36,7 @@ class GitHubMasterSpec extends Specification { 1 * gitHubClient.listDirectory(project, repo, dir, ref) >> gitHubClientResponse when: - List response = gitHubMaster.listDirectory(project, repo, dir, ref) + List response = gitHubController.listDirectory(project, repo, dir, ref) then: response == expectedResponse @@ -60,7 +60,7 @@ class GitHubMasterSpec extends Specification { 1 * gitHubClient.getFileContent(project, repo, dir, ref) >> gitHubClientResponse when: - String response = gitHubMaster.getTextFileContents(project, repo, dir, ref) + String response = gitHubController.getTextFileContents(project, repo, dir, ref) then: response == expectedResponse diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/gitlab/CommitControllerSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/gitlab/CommitControllerSpec.groovy index 73b6768bd..532551a72 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/gitlab/CommitControllerSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/gitlab/CommitControllerSpec.groovy @@ -19,7 +19,7 @@ package com.netflix.spinnaker.igor.scm.gitlab import com.netflix.spinnaker.igor.config.GitLabProperties import com.netflix.spinnaker.igor.scm.AbstractCommitController import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabClient -import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabMaster +import com.netflix.spinnaker.igor.scm.gitlab.client.GitLabController import com.netflix.spinnaker.igor.scm.gitlab.client.model.Commit import com.netflix.spinnaker.igor.scm.gitlab.client.model.CompareCommitsResponse import retrofit.RetrofitError @@ -27,9 +27,6 @@ import retrofit.client.Response import spock.lang.Specification import spock.lang.Subject -import java.time.Instant -import java.util.concurrent.Executors - /** * Tests for GitLab CommitController */ @@ -46,7 +43,7 @@ class CommitControllerSpec extends Specification { def props = new GitLabProperties() props.baseUrl = GITLAB_ADDRESS props.commitDisplayLength = 8 - controller = new CommitController(new GitLabMaster(client, GITLAB_ADDRESS), props) + controller = new CommitController(new GitLabController(client, GITLAB_ADDRESS), props) } void 'missing query params'() { diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/stash/CommitControllerSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/stash/CommitControllerSpec.groovy index e90265f68..b564ec5f1 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/stash/CommitControllerSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/stash/CommitControllerSpec.groovy @@ -18,7 +18,7 @@ package com.netflix.spinnaker.igor.scm.stash import com.netflix.spinnaker.igor.scm.AbstractCommitController import com.netflix.spinnaker.igor.scm.stash.client.StashClient -import com.netflix.spinnaker.igor.scm.stash.client.StashMaster +import com.netflix.spinnaker.igor.scm.stash.client.StashController import com.netflix.spinnaker.igor.scm.stash.client.model.Author import com.netflix.spinnaker.igor.scm.stash.client.model.Commit import com.netflix.spinnaker.igor.scm.stash.client.model.CompareCommitsResponse @@ -42,7 +42,7 @@ class CommitControllerSpec extends Specification { def STASH_ADDRESS = "https://stash.com" void setup() { - controller = new CommitController(executor: Executors.newSingleThreadExecutor(), stashMaster: new StashMaster(stashClient: client, baseUrl : STASH_ADDRESS)) + controller = new CommitController(executor: Executors.newSingleThreadExecutor(), stashController: new StashController(stashClient: client, baseUrl : STASH_ADDRESS)) } diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashClientSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashClientSpec.groovy index e91efccaa..bf98b12c1 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashClientSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/scm/stash/client/StashClientSpec.groovy @@ -17,7 +17,7 @@ package com.netflix.spinnaker.igor.scm.stash.client import com.netflix.spinnaker.igor.config.StashConfig -import com.netflix.spinnaker.igor.scm.ScmMaster +import com.netflix.spinnaker.igor.scm.ScmController import com.netflix.spinnaker.igor.scm.stash.client.model.CompareCommitsResponse import com.netflix.spinnaker.igor.scm.stash.client.model.DirectoryListingResponse import com.netflix.spinnaker.igor.scm.stash.client.model.TextLinesResponse @@ -108,7 +108,7 @@ class StashClientSpec extends Specification { setResponse('application/json', listDirectoryResponse) when: - DirectoryListingResponse dirListResponse = client.listDirectory('foo', 'repo', '.spinnaker', ScmMaster.DEFAULT_GIT_REF) + DirectoryListingResponse dirListResponse = client.listDirectory('foo', 'repo', '.spinnaker', ScmController.DEFAULT_GIT_REF) then: dirListResponse.children.size == 2 @@ -133,7 +133,7 @@ class StashClientSpec extends Specification { setResponse('application/json', contents) when: - TextLinesResponse response = client.getTextFileContents('foo', 'repo', 'bananas.txt', ScmMaster.DEFAULT_GIT_REF, 1, start) + TextLinesResponse response = client.getTextFileContents('foo', 'repo', 'bananas.txt', ScmController.DEFAULT_GIT_REF, 1, start) then: response.size == size diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerBuildMonitorSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerBuildMonitorSpec.groovy index 6469a136f..614a19057 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerBuildMonitorSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerBuildMonitorSpec.groovy @@ -35,19 +35,19 @@ class WerckerBuildMonitorSpec extends Specification { WerckerService mockService = Mock(WerckerService) WerckerService werckerService String werckerDev = 'https://dev.wercker.com/' - String master = 'WerckerTestMaster' + String controller = 'WerckerTestController' void setup() { client = Mock(WerckerClient) werckerService = new WerckerService( - new WerckerHost(name: master, address: werckerDev), cache, client, Permissions.EMPTY) + new WerckerHost(name: controller, address: werckerDev), cache, client, Permissions.EMPTY) } - def MASTER = 'MASTER' + def CONTROLLER = 'CONTROLLER' BuildServices mockBuildServices() { BuildServices buildServices = new BuildServices() - buildServices.addServices([MASTER: mockService]) + buildServices.addServices([CONTROLLER: mockService]) return buildServices } @@ -67,7 +67,7 @@ class WerckerBuildMonitorSpec extends Specification { mockService.getBuildServiceProvider() >> BuildServiceProvider.WERCKER when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 'initial poll' 0 * echoService.postEvent(_) @@ -89,7 +89,7 @@ class WerckerBuildMonitorSpec extends Specification { mockService.getBuildServiceProvider() >> BuildServiceProvider.WERCKER when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 'initial poll' 1 * echoService.postEvent(_) @@ -103,7 +103,7 @@ class WerckerBuildMonitorSpec extends Specification { mockService.getBuildServiceProvider() >> BuildServiceProvider.WERCKER when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 'initial poll' 0 * echoService.postEvent(_) @@ -119,30 +119,30 @@ class WerckerBuildMonitorSpec extends Specification { cache.getLastPollCycleTimestamp(_, _) >> (now - 1000) 1 * mockService.getRunsSince(_) >> [pipeline: runs1] cache.getBuildNumber(*_) >> 1 - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: - 1 * cache.setEventPosted('MASTER', 'pipeline', 'init') + 1 * cache.setEventPosted('CONTROLLER', 'pipeline', 'init') 1 * echoService.postEvent(_) } void 'get runs of multiple pipelines'() { setup: BuildServices buildServices = new BuildServices() - buildServices.addServices([MASTER: werckerService]) + buildServices.addServices([CONTROLLER: werckerService]) monitor = monitor(buildServices) cache.getBuildNumber(*_) >> 1 client.getRunsSince(_, _, _, _, _) >> [] mockService.getBuildServiceProvider() >> BuildServiceProvider.WERCKER when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 'initial poll' 0 * echoService.postEvent(_) when: - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: 0 * echoService.postEvent(_) @@ -172,14 +172,14 @@ class WerckerBuildMonitorSpec extends Specification { client.getRunsSince(_,_,_,_,_) >> runs1 cache.getLastPollCycleTimestamp(_, _) >> (now - 1000) cache.getBuildNumber(*_) >> 1 - monitor.pollSingle(new PollContext(MASTER)) + monitor.pollSingle(new PollContext(CONTROLLER)) then: - 1 * cache.setEventPosted('MASTER', 'myOrg/app0/p00', 'run0') - 1 * cache.setEventPosted('MASTER', 'myOrg/app1/p10', 'run1') - 1 * cache.setEventPosted('MASTER', 'myOrg/app1/p11', 'run3') - 1 * cache.setEventPosted('MASTER', 'myOrg/app2/p20', 'run4') - 0 * cache.setEventPosted('MASTER', 'myOrg/app3/p30', 'run5') + 1 * cache.setEventPosted('CONTROLLER', 'myOrg/app0/p00', 'run0') + 1 * cache.setEventPosted('CONTROLLER', 'myOrg/app1/p10', 'run1') + 1 * cache.setEventPosted('CONTROLLER', 'myOrg/app1/p11', 'run3') + 1 * cache.setEventPosted('CONTROLLER', 'myOrg/app2/p20', 'run4') + 0 * cache.setEventPosted('CONTROLLER', 'myOrg/app3/p30', 'run5') 4 * echoService.postEvent(_) } diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerCacheSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerCacheSpec.groovy index 264165a1f..89c0ebf55 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerCacheSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerCacheSpec.groovy @@ -26,8 +26,7 @@ class WerckerCacheSpec extends Specification { @Subject WerckerCache cache = new WerckerCache(redisClientDelegate, new IgorConfigurationProperties()) - def master = 'testWerckerMaster' - def test = 'test' + def controller = 'testWerckerController' def pipeline = 'myOrg/myApp/myTestPipeline' void cleanup() { @@ -38,15 +37,15 @@ class WerckerCacheSpec extends Specification { void 'lastPollCycleTimestamp get overridden'() { long now1 = System.currentTimeMillis(); when: - cache.setLastPollCycleTimestamp(master, 'myOrg/myApp/myPipeline', now1) + cache.setLastPollCycleTimestamp(controller, 'myOrg/myApp/myPipeline', now1) then: - cache.getLastPollCycleTimestamp(master, 'myOrg/myApp/myPipeline') == now1 + cache.getLastPollCycleTimestamp(controller, 'myOrg/myApp/myPipeline') == now1 long now2 = System.currentTimeMillis(); when: - cache.setLastPollCycleTimestamp(master, 'myOrg/myApp/myPipeline', now2) + cache.setLastPollCycleTimestamp(controller, 'myOrg/myApp/myPipeline', now2) then: - cache.getLastPollCycleTimestamp(master, 'myOrg/myApp/myPipeline') == now2 + cache.getLastPollCycleTimestamp(controller, 'myOrg/myApp/myPipeline') == now2 } void 'generates buildNumbers ordered by startedAt'() { @@ -56,17 +55,17 @@ class WerckerCacheSpec extends Specification { new Run(id:"a", createdAt: new Date(now-11)), new Run(id:"init"), ] - cache.updateBuildNumbers(master, pipeline, runs1) + cache.updateBuildNumbers(controller, pipeline, runs1) List runs2 = [ new Run(id:"now", startedAt: new Date(now)), new Run(id:"d", createdAt: new Date(now-1)), new Run(id:"c", startedAt: new Date(now-2)), ] - cache.updateBuildNumbers(master, pipeline, runs2) + cache.updateBuildNumbers(controller, pipeline, runs2) expect: - cache.getBuildNumber(master, pipeline, runId) == buildNumber + cache.getBuildNumber(controller, pipeline, runId) == buildNumber where: runId | buildNumber @@ -85,17 +84,17 @@ class WerckerCacheSpec extends Specification { new Run(id:"x", startedAt: new Date(now-11)), new Run(id:"zero", createdAt: new Date(now-12)), ] - cache.updateBuildNumbers(master, pipeline, runs1) + cache.updateBuildNumbers(controller, pipeline, runs1) List runs2 = [ new Run(id:"latest", createdAt: new Date(now)), new Run(id:"4", startedAt: new Date(now-1)), new Run(id:"3", createdAt: new Date(now-2)), ] - cache.updateBuildNumbers(master, pipeline, runs2) + cache.updateBuildNumbers(controller, pipeline, runs2) expect: - cache.getBuildNumber(master, pipeline, runId) == buildNumber + cache.getBuildNumber(controller, pipeline, runId) == buildNumber where: runId | buildNumber diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerClientSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerClientSpec.groovy index a4c79c8ed..53ebcefb4 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerClientSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerClientSpec.groovy @@ -100,7 +100,7 @@ class WerckerClientSpec extends Specification { .setHeader('Content-Type', 'application/json; charset=utf-8') ) server.start() - def host = new WerckerHost(name: 'werckerMaster', address: server.url('/').toString()) + def host = new WerckerHost(name: 'werckerCONTROLLER', address: server.url('/').toString()) client = new WerckerConfig().werckerClient(host, 30000, new OkHttpClientProvider([new InsecureOkHttpClientBuilderProvider(new OkHttpClient())]), RestAdapter.LogLevel.BASIC) } diff --git a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerServiceSpec.groovy b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerServiceSpec.groovy index f1f6e0cd1..4f6619339 100644 --- a/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerServiceSpec.groovy +++ b/igor-web/src/test/groovy/com/netflix/spinnaker/igor/wercker/WerckerServiceSpec.groovy @@ -26,12 +26,12 @@ class WerckerServiceSpec extends Specification { @Shared WerckerService service String werckerDev = 'https://dev.wercker.com/' - String master = 'WerckerTestMaster' + String controller = 'WerckerTestController' void setup() { client = Mock(WerckerClient) service = new WerckerService( - new WerckerHost(name: master, address: werckerDev), cache, client, Permissions.EMPTY) + new WerckerHost(name: controller, address: werckerDev), cache, client, Permissions.EMPTY) } void 'get pipelines as jobs'() { @@ -130,7 +130,7 @@ class WerckerServiceSpec extends Specification { def runId = "testGenericBuild_werckerRunId" int buildNumber = 6 setup: - cache.getRunID(master, job, buildNumber) >> runId + cache.getRunID(controller, job, buildNumber) >> runId client.getRunById(_, runId) >> new Run(id: runId) expect: @@ -156,7 +156,7 @@ class WerckerServiceSpec extends Specification { ] client.triggerBuild(_, _) >> ['id': runId] client.getRunById(_, runId) >> new Run(id: runId) - cache.updateBuildNumbers(master, pipeline, _) >> ['test_triggerBuild_runId': buildNumber] + cache.updateBuildNumbers(controller, pipeline, _) >> ['test_triggerBuild_runId': buildNumber] expect: service.triggerBuildWithParameters(pipeline, [:]) == buildNumber diff --git a/igor-web/src/test/java/com/netflix/spinnaker/igor/concourse/ConcourseBuildMonitorTest.java b/igor-web/src/test/java/com/netflix/spinnaker/igor/concourse/ConcourseBuildMonitorTest.java index ecf0bcdfb..df96592fb 100644 --- a/igor-web/src/test/java/com/netflix/spinnaker/igor/concourse/ConcourseBuildMonitorTest.java +++ b/igor-web/src/test/java/com/netflix/spinnaker/igor/concourse/ConcourseBuildMonitorTest.java @@ -59,7 +59,7 @@ void before() throws Exception { host.setPassword("fake"); ConcourseProperties props = new ConcourseProperties(); - props.setMasters(Collections.singletonList(host)); + props.setControllers(Collections.singletonList(host)); BuildServices buildServices = new BuildServices(); buildServices.addServices(