summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2019-03-11 20:34:15 +0100
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2019-03-11 20:34:15 +0100
commitc0a254da00503daffff8f28b57b0b878cbf735e0 (patch)
treeda4e8af7d086e25e9bf7e0c02731144ddf9e2659 /controller-server
parentcd5eea426bee652127c2073c40847d2b242e8edf (diff)
Simplify, and account for cloud tenants in maintainers
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java19
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java20
2 files changed, 20 insertions, 19 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java
index ac71fca6de9..a3b1aab8f40 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ApplicationOwnershipConfirmer.java
@@ -52,11 +52,13 @@ public class ApplicationOwnershipConfirmer extends Maintainer {
.forEach(application -> {
try {
Tenant tenant = tenantOf(application.id());
- Optional<IssueId> ourIssueId = application.ownershipIssueId();
- Contact contact = tenant.contact().orElseThrow(RuntimeException::new);
- User assignee = determineAssignee(tenant, application);
- ourIssueId = ownershipIssues.confirmOwnership(ourIssueId, application.id(), assignee, contact);
- ourIssueId.ifPresent(issueId -> store(issueId, application.id()));
+ tenant.contact().ifPresent(contact -> { // TODO jvenstad: Makes sense to require, and run this only in main?
+ ownershipIssues.confirmOwnership(application.ownershipIssueId(),
+ application.id(),
+ determineAssignee(tenant, application),
+ contact)
+ .ifPresent(newIssueId -> store(newIssueId, application.id()));
+ });
}
catch (RuntimeException e) { // Catch errors due to wrong data in the controller, or issues client timeout.
log.log(Level.INFO, "Exception caught when attempting to file an issue for '" + application.id() + "': " + Exceptions.toMessageString(e));
@@ -70,11 +72,8 @@ public class ApplicationOwnershipConfirmer extends Maintainer {
for (Application application : controller().applications().asList())
application.ownershipIssueId().ifPresent(issueId -> {
try {
- Optional<Contact> contact = Optional.of(application.id())
- .map(this::tenantOf)
- .filter(t -> t instanceof AthenzTenant)
- .flatMap(Tenant::contact);
- ownershipIssues.ensureResponse(issueId, contact);
+ Tenant tenant = tenantOf(application.id());
+ ownershipIssues.ensureResponse(issueId, tenant.type() == Tenant.Type.athenz ? tenant.contact() : Optional.empty());
}
catch (RuntimeException e) {
log.log(Level.INFO, "Exception caught when attempting to escalate issue with id '" + issueId + "': " + Exceptions.toMessageString(e));
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java
index 06b1a4f9827..48e2702b9e0 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/DeploymentIssueReporter.java
@@ -116,10 +116,12 @@ public class DeploymentIssueReporter extends Maintainer {
private void fileDeploymentIssueFor(ApplicationId applicationId) {
try {
Tenant tenant = ownerOf(applicationId);
- User asignee = tenant instanceof UserTenant ? userFor(tenant) : null;
- Optional<IssueId> ourIssueId = controller().applications().require(applicationId).deploymentJobs().issueId();
- IssueId issueId = deploymentIssues.fileUnlessOpen(ourIssueId, applicationId, asignee, tenant.contact().get());
- store(applicationId, issueId);
+ tenant.contact().ifPresent(contact -> {
+ User assignee = tenant.type() == Tenant.Type.user ? userFor(tenant) : null;
+ Optional<IssueId> ourIssueId = controller().applications().require(applicationId).deploymentJobs().issueId();
+ IssueId issueId = deploymentIssues.fileUnlessOpen(ourIssueId, applicationId, assignee, contact);
+ store(applicationId, issueId);
+ });
}
catch (RuntimeException e) { // Catch errors due to wrong data in the controller, or issues client timeout.
log.log(Level.INFO, "Exception caught when attempting to file an issue for '" + applicationId + "': " + Exceptions.toMessageString(e));
@@ -130,11 +132,10 @@ public class DeploymentIssueReporter extends Maintainer {
private void escalateInactiveDeploymentIssues(Collection<Application> applications) {
applications.forEach(application -> application.deploymentJobs().issueId().ifPresent(issueId -> {
try {
- AthenzTenant tenant = Optional.of(application.id())
- .map(this::ownerOf)
- .filter(t -> t instanceof AthenzTenant)
- .map(AthenzTenant.class::cast).orElseThrow(RuntimeException::new);
- deploymentIssues.escalateIfInactive(issueId, maxInactivity, tenant.contact());
+ Tenant tenant = ownerOf(application.id());
+ deploymentIssues.escalateIfInactive(issueId,
+ maxInactivity,
+ tenant.type() == Tenant.Type.athenz ? tenant.contact() : Optional.empty());
}
catch (RuntimeException e) {
log.log(Level.INFO, "Exception caught when attempting to escalate issue with id '" + issueId + "': " + Exceptions.toMessageString(e));
@@ -146,4 +147,5 @@ public class DeploymentIssueReporter extends Maintainer {
controller().applications().lockIfPresent(id, application ->
controller().applications().store(application.withDeploymentIssueId(issueId)));
}
+
}