3737import com .yahoo .vespa .curator .Curator ;
3838import com .yahoo .vespa .curator .transaction .CuratorOperations ;
3939import com .yahoo .vespa .curator .transaction .CuratorTransaction ;
40- import com .yahoo .vespa .flags .BooleanFlag ;
4140import com .yahoo .vespa .flags .FlagSource ;
42- import com .yahoo .vespa .flags .Flags ;
43- import com .yahoo .vespa .flags .LongFlag ;
4441import org .apache .curator .framework .CuratorFramework ;
4542import org .apache .curator .framework .recipes .cache .PathChildrenCacheEvent ;
4643import org .apache .curator .framework .state .ConnectionState ;
@@ -112,7 +109,6 @@ public class TenantRepository {
112109 private final FileDistributionFactory fileDistributionFactory ;
113110 private final ExecutorService deployHelperExecutor ;
114111 private final FlagSource flagSource ;
115- private final BooleanFlag softDeleteTenantFlag ;
116112 private final HostProvisionerProvider hostProvisionerProvider ;
117113 private final ConfigserverConfig configserverConfig ;
118114 private final ConfigServerDB configServerDB ;
@@ -128,7 +124,6 @@ public class TenantRepository {
128124 private final List <EndpointCertificateSecretStore > endpointCertificateSecretStores ;
129125 private final OnnxModelCost onnxModelCost ;
130126 private final InheritableApplications inheritableApplications ;
131- private final LongFlag deleteIdleTenantSecondsFlag ;
132127
133128 /**
134129 * Creates a new tenant repository
@@ -204,7 +199,6 @@ public TenantRepository(HostRegistry hostRegistry,
204199 this .zkSessionWatcherExecutor = zkSessionWatcherExecutor ;
205200 this .fileDistributionFactory = fileDistributionFactory ;
206201 this .flagSource = flagSource ;
207- this .softDeleteTenantFlag = Flags .SOFT_DELETE_TENANT .bindTo (flagSource );
208202 this .hostProvisionerProvider = hostProvisionerProvider ;
209203 this .configServerDB = configServerDB ;
210204 this .zone = zone ;
@@ -215,7 +209,6 @@ public TenantRepository(HostRegistry hostRegistry,
215209 this .tenantListener = tenantListener ;
216210 this .zookeeperServerConfig = zookeeperServerConfig ;
217211 this .endpointCertificateSecretStores = endpointCertificateSecretStores ;
218- this .deleteIdleTenantSecondsFlag = Flags .DELETE_IDLE_TENANT_SECONDS .bindTo (flagSource );
219212 // This we should control with a feature flag.
220213 this .deployHelperExecutor = createModelBuilderExecutor ();
221214 this .onnxModelCost = onnxModelCost ;
@@ -270,7 +263,7 @@ private TenantMetaData createMetaData(Tenant tenant) {
270263 Instant now = tenant .getSessionRepository ().clock ().instant ();
271264 TenantMetaData metadata = getTenantMetaData (tenant );
272265 Instant deployTime = metadata .lastDeployTimestamp ();
273- if (deployTime .equals (Instant .EPOCH ) || deleteIdleTenantSecondsFlag . with ( tenant . getName ()). value () < 0 )
266+ if (deployTime .equals (Instant .EPOCH ))
274267 deployTime = now ;
275268 Instant createdTime = metadata .createdTimestamp ();
276269 if (createdTime .equals (Instant .EPOCH ))
@@ -489,22 +482,17 @@ public void deleteTenant(TenantName name) {
489482
490483 notifyRemovedTenant (name );
491484 tenant .close ();
492- if (softDeleteTenantFlag .with (name ).value ()) {
493- // Because each config server has a PathDirectoryCache on the `sessions` and `applications` children:
494- // 1. Once the first config server (say cfg1) reaches this point, the caches on cfg2-3 will recreate
495- // `sessions` and `applications` immediately after they are deleted by this tryDelete(), likely
496- // failing this deletion.
497- // 2. Once the next config server (say cfg2) also reaches this point, the caches on cfg3 will recreate
498- // `sessions` and `applications`, possibly failing this deletion.
499- // 3. Once the last config server (cfg3) reaches this point, the delete should succeed.
500- if (curator .tryDelete (tenant .getPath ())) {
501- log .log (Level .INFO , "Deleted tenant " + name );
502- } else {
503- log .log (Level .INFO , "Deleted tenant " + name + " (" + tenant .getPath () + " to be removed by other cfgs)" );
504- }
485+ // Because each config server has a PathDirectoryCache on the `sessions` and `applications` children:
486+ // 1. Once the first config server (say cfg1) reaches this point, the caches on cfg2-3 will recreate
487+ // `sessions` and `applications` immediately after they are deleted by this tryDelete(), likely
488+ // failing this deletion.
489+ // 2. Once the next config server (say cfg2) also reaches this point, the caches on cfg3 will recreate
490+ // `sessions` and `applications`, possibly failing this deletion.
491+ // 3. Once the last config server (cfg3) reaches this point, the delete should succeed.
492+ if (curator .tryDelete (tenant .getPath ())) {
493+ log .log (Level .INFO , "Deleted tenant " + name );
505494 } else {
506- curator .delete (tenant .getPath ());
507- log .log (Level .INFO , "Deleted tenant '" + name + "'" );
495+ log .log (Level .INFO , "Deleted tenant " + name + " (" + tenant .getPath () + " to be removed by other cfgs)" );
508496 }
509497 }
510498 }
@@ -661,11 +649,7 @@ public Set<TenantName> deleteUnusedTenants(Duration ttlForUnusedTenant, Instant
661649 .filter (tenantName -> activeApplications (tenantName ).isEmpty ())
662650 .filter (tenantName -> !tenantName .equals (TenantName .defaultName ())) // Not allowed to remove 'default' tenant
663651 .filter (tenantName -> !tenantName .equals (HOSTED_VESPA_TENANT )) // Not allowed to remove 'hosted-vespa' tenant
664- .filter (tenantName -> {
665- long ttlSeconds = deleteIdleTenantSecondsFlag .with (tenantName ).value ();
666- Duration ttl = ttlSeconds < 0 ? ttlForUnusedTenant : Duration .ofSeconds (ttlSeconds );
667- return getTenantMetaData (getTenant (tenantName )).lastDeployTimestamp ().isBefore (now .minus (ttl ));
668- })
652+ .filter (tenantName -> getTenantMetaData (getTenant (tenantName )).lastDeployTimestamp ().isBefore (now .minus (ttlForUnusedTenant )))
669653 .peek (this ::deleteTenant )
670654 .collect (Collectors .toSet ());
671655 }
0 commit comments