Skip to content

Commit

Permalink
Revert "KNOX-2962 - Knox readiness check gateway-status endpoint shou…
Browse files Browse the repository at this point in the history
…ld return the list of topologies for which it is waiting for (#800)"

This reverts commit ff6bcbc.
  • Loading branch information
zeroflag authored Oct 11, 2023
1 parent 838dcd8 commit 9b5af7f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ public synchronized boolean status() {
LOG.noTopologiesToCheck();
return false;
}
Set<String> missing = pendingTopologies();
LOG.checkingGatewayStatus(deployedTopologies, missing);
return missing.isEmpty();
}

public synchronized Set<String> pendingTopologies() {
Set<String> missing = new HashSet<>(topologyNamesToCheck);
missing.removeAll(deployedTopologies);
return missing;
LOG.checkingGatewayStatus(deployedTopologies, missing);
return missing.isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
*/
package org.apache.knox.gateway.services.topology.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;

import org.apache.knox.gateway.config.GatewayConfig;
Expand All @@ -45,20 +43,4 @@ public void testReadyStatus() throws Exception {
statusService.onTopologyReady("t2");
assertTrue(statusService.status());
}

@Test
public void testPendingTopologies() throws Exception {
GatewayStatusService statusService = new GatewayStatusService();
GatewayConfig config = EasyMock.createNiceMock(GatewayConfig.class);
statusService.init(config, null);
assertFalse(statusService.status());
EasyMock.expect(config.getHealthCheckTopologies()).andReturn(new HashSet<>(Arrays.asList("t1", "t2"))).anyTimes();
EasyMock.replay(config);
statusService.initTopologiesToCheck();
assertEquals(new HashSet<>(Arrays.asList("t1", "t2")), statusService.pendingTopologies());
statusService.onTopologyReady("t1");
assertEquals(new HashSet<>(Arrays.asList("t2")), statusService.pendingTopologies());
statusService.onTopologyReady("t2");
assertEquals(Collections.emptySet(), statusService.pendingTopologies());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Response status() {
.getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE);
GatewayStatusService statusService = services.getService(ServiceType.GATEWAY_STATUS_SERVICE);
try (PrintWriter writer = response.getWriter()) {
writer.println(statusService.status() ? OK : PENDING + ": " + statusService.pendingTopologies());
writer.println(statusService.status() ? OK : PENDING);
} catch (IOException e) {
log.logException("status", e);
return Response.serverError().entity(String.format(Locale.ROOT, "Failed to reply correctly due to : %s ", e)).build();
Expand Down

0 comments on commit 9b5af7f

Please sign in to comment.