diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-01-19 15:18:43 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-01-19 15:18:43 +0100 |
commit | fe37921c3e6acc4086af13c204df657121b7b14d (patch) | |
tree | 77a1c29e654af1621cd94cc35391a21d21abd5fa /controller-server/src | |
parent | a2d8de649adb14d00c2294dc659c2c6e4c1dfc30 (diff) |
Separate out some logic
Diffstat (limited to 'controller-server/src')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index 27ae406afe6..f9db2eca72d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -332,23 +332,15 @@ public class ApplicationController { " the current version " + existingDeployment.version()); } + application = withRotation(application, zone); + Set<String> rotationNames = new HashSet<>(); Set<String> cnames = new HashSet<>(); - if (zone.environment() == Environment.prod && application.deploymentSpec().globalServiceId().isPresent()) { - try (RotationLock rotationLock = rotationRepository.lock()) { - Rotation rotation = rotationRepository.getRotation(application, rotationLock); - application = application.with(rotation.id()); - store(application); // store assigned rotation even if deployment fails - - rotationNames.add(rotation.id().asString()); - application.rotation().ifPresent(applicationRotation -> { - registerRotationInDns(rotation, applicationRotation.dnsName()); - cnames.add(applicationRotation.dnsName()); - registerRotationInDns(rotation, applicationRotation.secureDnsName()); - cnames.add(applicationRotation.secureDnsName()); - }); - } - } + application.rotation().ifPresent(applicationRotation -> { + rotationNames.add(applicationRotation.id().asString()); + cnames.add(applicationRotation.dnsName()); + cnames.add(applicationRotation.secureDnsName()); + }); // Carry out deployment options = withVersion(version, options); @@ -364,6 +356,21 @@ public class ApplicationController { } } + /** Makes sure the application has a global rotation, if eligible. */ + private LockedApplication withRotation(LockedApplication application, ZoneId zone) { + if (zone.environment() == Environment.prod && application.deploymentSpec().globalServiceId().isPresent()) { + try (RotationLock rotationLock = rotationRepository.lock()) { + Rotation rotation = rotationRepository.getRotation(application, rotationLock); + application = application.with(rotation.id()); + store(application); // store assigned rotation even if deployment fails + + registerRotationInDns(rotation, application.rotation().get().dnsName()); + registerRotationInDns(rotation, application.rotation().get().secureDnsName()); + } + } + return application; + } + private ActivateResult unexpectedDeployment(ApplicationId applicationId, ZoneId zone, ApplicationPackage applicationPackage) { Log logEntry = new Log(); logEntry.level = "WARNING"; |