blob: b05a8c357fb1ab4d1e826f03cf13c1bff0b6b249 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.maintenance;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.tenant.Tenant;
import java.time.Duration;
public class TenantRoleCleanupMaintainer extends ControllerMaintainer {
public TenantRoleCleanupMaintainer(Controller controller, Duration interval) {
super(controller, interval);
}
@Override
protected double maintain() {
var roleService = controller().serviceRegistry().roleService();
var deletedTenants = controller().tenants().asList(true).stream()
.filter(tenant -> tenant.type() == Tenant.Type.deleted)
.map(Tenant::name)
.toList();
roleService.cleanupRoles(deletedTenants);
return 1.0;
}
}
|