diff options
author | jonmv <venstad@gmail.com> | 2023-03-07 10:40:45 +0100 |
---|---|---|
committer | jonmv <venstad@gmail.com> | 2023-03-07 10:40:45 +0100 |
commit | d4644f2712d1196c99df925f8c24759e0a11b708 (patch) | |
tree | 03536efaf2095fd07a7f40634335d5df3da7500e /controller-api | |
parent | e5e8a097195ac5866f4dffccf9fdd938b564af9f (diff) |
Normalise connection status for UI display
Diffstat (limited to 'controller-api')
2 files changed, 12 insertions, 10 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MockVpcEndpointService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MockVpcEndpointService.java index 563b343dab5..39975138140 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MockVpcEndpointService.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/MockVpcEndpointService.java @@ -18,7 +18,7 @@ import java.util.concurrent.atomic.AtomicBoolean; public class MockVpcEndpointService implements VpcEndpointService { public final AtomicBoolean enabled = new AtomicBoolean(); - public final Map<RecordName, State> outcomes = new ConcurrentHashMap<>(); + public final Map<RecordName, ChallengeState> outcomes = new ConcurrentHashMap<>(); private final Clock clock; private final NameService nameService; @@ -36,20 +36,20 @@ public class MockVpcEndpointService implements VpcEndpointService { "service-id", account, clock.instant(), - State.pending); + ChallengeState.pending); return Optional.ofNullable(enabled.get() && nameService.findRecords(Type.TXT, challenge.name()).isEmpty() ? challenge : null); } @Override - public synchronized State process(DnsChallenge challenge) { + public synchronized ChallengeState process(DnsChallenge challenge) { if (outcomes.containsKey(challenge.name())) return outcomes.get(challenge.name()); if (nameService.findRecords(Type.TXT, challenge.name()).isEmpty()) throw new RuntimeException("No TXT record found for " + challenge.name()); - return State.done; + return ChallengeState.done; } @Override public synchronized List<VpcEndpoint> getConnections(ClusterId cluster, Optional<CloudAccount> account) { - return List.of(new VpcEndpoint("endpoint-1", "available")); + return List.of(new VpcEndpoint("endpoint-1", "available", EndpointState.open)); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/VpcEndpointService.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/VpcEndpointService.java index 74459792987..a3ee7681e2a 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/VpcEndpointService.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/dns/VpcEndpointService.java @@ -17,7 +17,7 @@ public interface VpcEndpointService { /** Create a TXT record with this name and token, and then complete the challenge. */ record DnsChallenge(RecordName name, RecordData data, ClusterId clusterId, String serviceId, - Optional<CloudAccount> account, Instant createdAt, State state) { + Optional<CloudAccount> account, Instant createdAt, ChallengeState state) { public DnsChallenge { requireNonNull(name, "name must be non-null"); @@ -29,22 +29,24 @@ public interface VpcEndpointService { requireNonNull(state, "state must be non-null"); } - public DnsChallenge withState(State state) { + public DnsChallenge withState(ChallengeState state) { return new DnsChallenge(name, data, clusterId, serviceId, account, createdAt, state); } } - enum State { pending, ready, running, done } + enum ChallengeState { pending, ready, running, done } /** Sets the private DNS name for any VPC endpoint for the given cluster, potentially guarded by a challenge. */ Optional<DnsChallenge> setPrivateDns(DomainName privateDnsName, ClusterId clusterId, Optional<CloudAccount> account); /** Attempts to complete the challenge, and returns the updated challenge state. */ - State process(DnsChallenge challenge); + ChallengeState process(DnsChallenge challenge); /** A connection made to an endpoint service. */ - record VpcEndpoint(String endpointId, String state) { } + record VpcEndpoint(String endpointId, String stateString, EndpointState stateValue) { } + + enum EndpointState { pending, open, failed, closed } /** Lists all endpoints connected to an endpoint service (owned by account) for the given cluster. */ List<VpcEndpoint> getConnections(ClusterId cluster, Optional<CloudAccount> account); |