summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorValerij Fredriksen <freva@users.noreply.github.com>2018-11-20 10:04:32 +0100
committerGitHub <noreply@github.com>2018-11-20 10:04:32 +0100
commit9c813fc4307ac4218850a36397c38d77fae786ee (patch)
tree918b6a50c5730a84d83ed94382bc6d3d4277c23d /configserver
parent4028b6d396b2b96bfb899fcfe4fa8f6b74245801 (diff)
parent3a1fa473131b02f0f06b2f466d0f464a7f147fb7 (diff)
Merge pull request #7693 from vespa-engine/hmusum/more-robust-handling-of-errors-for-config-server-maintainers
More robust handling of exceptions for config server maintainers
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java40
1 files changed, 33 insertions, 7 deletions
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 0594524af37..e7b9012483f 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
@@ -409,10 +409,17 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
// Find all file references in use
Set<String> fileReferencesInUse = new HashSet<>();
Set<ApplicationId> applicationIds = listApplications();
- applicationIds.forEach(applicationId -> fileReferencesInUse.addAll(getApplication(applicationId).getModel().fileReferences()
- .stream()
- .map(FileReference::value)
- .collect(Collectors.toSet())));
+ applicationIds.forEach(applicationId -> {
+ try {
+ Set<String> fileReferences = getApplication(applicationId).getModel().fileReferences()
+ .stream()
+ .map(FileReference::value)
+ .collect(Collectors.toSet());
+ fileReferencesInUse.addAll(fileReferences);
+ } catch (IllegalArgumentException e) {
+ log.log(LogLevel.WARNING, "Failed deleting unused file references for ': " + applicationId + "'", e);
+ }
+ });
log.log(LogLevel.DEBUG, "File references in use : " + fileReferencesInUse);
// Find those on disk that are not in use
@@ -447,6 +454,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
private Application getApplication(ApplicationId applicationId) {
try {
Tenant tenant = tenantRepository.getTenant(applicationId.tenant());
+ if (tenant == null) throw new IllegalArgumentException("Tenant '" + applicationId.tenant() + "' not found");
long sessionId = getSessionIdForApplication(tenant, applicationId);
RemoteSession session = tenant.getRemoteSessionRepo().getSession(sessionId, 0);
return session.ensureApplicationLoaded().getForVersionOrLatest(Optional.empty(), clock.instant());
@@ -513,7 +521,11 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
public long getSessionIdForApplication(Tenant tenant, ApplicationId applicationId) {
- return tenant.getApplicationRepo().getSessionIdForApplication(applicationId);
+ TenantApplications applicationRepo = tenant.getApplicationRepo();
+ if (applicationRepo == null)
+ throw new IllegalArgumentException("Application repo for tenant '" + tenant.getName() + "' not found");
+
+ return applicationRepo.getSessionIdForApplication(applicationId);
}
public void validateThatRemoteSessionIsNotActive(Tenant tenant, long sessionId) {
@@ -563,13 +575,27 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
}
public void deleteExpiredLocalSessions() {
- listApplications().forEach(app -> tenantRepository.getTenant(app.tenant()).getLocalSessionRepo().purgeOldSessions());
+ listApplications().forEach(app -> {
+ Tenant tenant = tenantRepository.getTenant(app.tenant());
+ if (tenant == null)
+ log.log(LogLevel.WARNING, "Cannot delete expired local sessions for tenant '" + app.tenant() + "', tenant not found");
+ else
+ tenant.getLocalSessionRepo().purgeOldSessions();
+ });
}
public int deleteExpiredRemoteSessions(Duration expiryTime) {
return listApplications()
.stream()
- .map(app -> tenantRepository.getTenant(app.tenant()).getRemoteSessionRepo().deleteExpiredSessions(expiryTime))
+ .map(app -> {
+ Tenant tenant = tenantRepository.getTenant(app.tenant());
+ if (tenant == null) {
+ log.log(LogLevel.WARNING, "Cannot delete expired remote sessions for tenant '" + app.tenant() + "', tenant not found");
+ return 0;
+ } else {
+ return tenant.getRemoteSessionRepo().deleteExpiredSessions(expiryTime);
+ }
+ })
.mapToInt(i -> i)
.sum();
}