summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-12-10 09:43:04 +0100
committerGitHub <noreply@github.com>2018-12-10 09:43:04 +0100
commitd23084a0a2d4447d3fa9748c3239fa4ec9773e6b (patch)
tree7b9056eb96778d2ef0947a2bab739cd2c6a1dbdd
parenta9dd5777914f35762f785bc963293bbb42997fce (diff)
parent03836e891c1753a871f0c5b556d16a3222739291 (diff)
Merge pull request #7914 from vespa-engine/hmusum/remove-legacy-code-for-deleting-application
Remove unused legacy code for deleting an application
-rw-r--r--configdefinitions/src/vespa/configserver.def1
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java47
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java19
3 files changed, 5 insertions, 62 deletions
diff --git a/configdefinitions/src/vespa/configserver.def b/configdefinitions/src/vespa/configserver.def
index 583e04e1f38..999a25d32f7 100644
--- a/configdefinitions/src/vespa/configserver.def
+++ b/configdefinitions/src/vespa/configserver.def
@@ -67,7 +67,6 @@ maxDurationOfBootstrap long default=7200
sleepTimeWhenRedeployingFails long default=30
# Feature Flags (poor man's feature flags, to be overridden in configserver-config.xml if needed)
-deleteApplicationLegacy bool default=false
buildMinimalSetOfConfigModels bool default=true
useDedicatedNodeForLogserver bool default=true
throwIfBootstrappingTenantRepoFails bool default=true
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index d9714c7c9af..3284c9fb6c4 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -294,16 +294,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
* @throws RuntimeException if the delete transaction fails. This method is exception safe.
*/
public boolean delete(ApplicationId applicationId) {
- return configserverConfig.deleteApplicationLegacy() ? deleteApplicationLegacy(applicationId) : deleteApplication(applicationId);
- }
-
- /**
- * Deletes an application
- *
- * @return true if the application was found and deleted, false if it was not present
- * @throws RuntimeException if the delete transaction fails. This method is exception safe.
- */
- boolean deleteApplication(ApplicationId applicationId) {
Tenant tenant = tenantRepository.getTenant(applicationId.tenant());
if (tenant == null) return false;
@@ -340,43 +330,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
return true;
}
- /**
- * Deletes an application the legacy way (if there is more than one config server, the call needs to be done
- * on the config server the application was deployed)
- *
- * @return true if the application was found and deleted, false if it was not present
- * @throws RuntimeException if the delete transaction fails. This method is exception safe.
- */
- // TODO: Remove this method, use delete(ApplicationId) instead
- boolean deleteApplicationLegacy(ApplicationId applicationId) {
- Optional<Tenant> owner = Optional.ofNullable(tenantRepository.getTenant(applicationId.tenant()));
- if (!owner.isPresent()) return false;
-
- TenantApplications tenantApplications = owner.get().getApplicationRepo();
- if (!tenantApplications.listApplications().contains(applicationId)) return false;
-
- // TODO: Push lookup logic down
- long sessionId = tenantApplications.getSessionIdForApplication(applicationId);
- LocalSessionRepo localSessionRepo = owner.get().getLocalSessionRepo();
- LocalSession session = localSessionRepo.getSession(sessionId);
- if (session == null) return false;
-
- NestedTransaction transaction = new NestedTransaction();
- localSessionRepo.removeSession(session.getSessionId(), transaction);
- session.delete(transaction); // TODO: Not unit tested
-
- transaction.add(new Rotations(owner.get().getCurator(), owner.get().getPath()).delete(applicationId)); // TODO: Not unit tested
- // (When rotations are updated in zk, we need to redeploy the zone app, on the right config server
- // this is done asynchronously in application maintenance by the node repository)
- transaction.add(tenantApplications.deleteApplication(applicationId));
-
- hostProvisioner.ifPresent(provisioner -> provisioner.remove(transaction, applicationId));
- transaction.onCommitted(() -> log.log(LogLevel.INFO, "Deleted " + applicationId));
- transaction.commit();
-
- return true;
- }
-
public HttpResponse clusterControllerStatusPage(ApplicationId applicationId, String hostName, String pathSuffix) {
// WARNING: pathSuffix may be given by the external user. Make sure no security issues arise...
// We should be OK here, because at most, pathSuffix may change the parent path, but cannot otherwise
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index 694464ee578..79ed2767d7a 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -242,7 +242,7 @@ public class ApplicationRepositoryTest {
assertNotNull(applicationRepository.getActiveSession(applicationId()));
// Delete app and verify that it has been deleted from repos and provisioner
- assertTrue(applicationRepository.deleteApplication(applicationId()));
+ assertTrue(applicationRepository.delete(applicationId()));
assertNull(applicationRepository.getActiveSession(applicationId()));
assertNull(tenant.getLocalSessionRepo().getSession(sessionId));
assertNull(tenant.getRemoteSessionRepo().getSession(sessionId));
@@ -250,12 +250,12 @@ public class ApplicationRepositoryTest {
assertThat(provisioner.lastApplicationId.tenant(), is(tenant.getName()));
assertThat(provisioner.lastApplicationId, is(applicationId()));
- assertFalse(applicationRepository.deleteApplication(applicationId()));
+ assertFalse(applicationRepository.delete(applicationId()));
}
{
deployApp(testApp);
- assertTrue(applicationRepository.deleteApplication(applicationId()));
+ assertTrue(applicationRepository.delete(applicationId()));
deployApp(testApp);
// Deploy another app (with id fooId)
@@ -265,24 +265,15 @@ public class ApplicationRepositoryTest {
assertNotNull(applicationRepository.getActiveSession(fooId));
// Delete app with id fooId, should not affect original app
- assertTrue(applicationRepository.deleteApplication(fooId));
+ assertTrue(applicationRepository.delete(fooId));
assertThat(provisioner.lastApplicationId, is(fooId));
assertNotNull(applicationRepository.getActiveSession(applicationId()));
- assertTrue(applicationRepository.deleteApplication(applicationId()));
+ assertTrue(applicationRepository.delete(applicationId()));
}
}
@Test
- public void deleteLegacy() {
- deployApp(testApp);
- assertNotNull(applicationRepository.getActiveSession(applicationId()));
- assertTrue(applicationRepository.deleteApplicationLegacy(applicationId()));
- assertNull(applicationRepository.getActiveSession(applicationId()));
- assertFalse(applicationRepository.deleteApplicationLegacy(applicationId()));
- }
-
- @Test
public void testDeletingInactiveSessions() {
ManualClock clock = new ManualClock(Instant.now());
ConfigserverConfig configserverConfig =