Skip to content

Commit

Permalink
[PLAT-13679][PLAT-13746][PLAT-12372]: Add uptime for master nodes as …
Browse files Browse the repository at this point in the history
…well in case of DEDICATED mode

Summary:
Uptime for master nodes was never there in case of DEDICATED mode.
This affected 2 scenarios
1. Any cloud provider based universe in DEDICATED mode
2. K8 universe

This task does the following tasks
1. Remove /masters/info (I added it 6 months ago, but its not necessary as it is just a duplicate)
2. Use /master_info
3. Display Master and TServer UUID as a tooltip using the above API
4. Display Master Uptime seconds (we never display this information in K8 or in cloud provider dedicated mode)
5. We will not be displaying SSD, RAM and etc for master at this point as YBClient does not have the above info (we can create a new task if needed or if its a priority)

Test Plan:
Please refer to the screenshot
{F174619}

Reviewers: jmak, #yba-api-review, yshchetinin, anijhawan

Reviewed By: jmak, #yba-api-review, yshchetinin, anijhawan

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D34639
  • Loading branch information
rajmaddy89 committed May 3, 2024
1 parent 5d5cb9c commit 1626058
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
import com.google.inject.Inject;
import com.yugabyte.yw.commissioner.tasks.UniverseTaskBase.ServerType;
import com.yugabyte.yw.common.KubernetesManagerFactory;
import com.yugabyte.yw.common.PlatformServiceException;
import com.yugabyte.yw.common.Util;
import com.yugabyte.yw.common.rbac.PermissionInfo.Action;
import com.yugabyte.yw.common.rbac.PermissionInfo.ResourceType;
import com.yugabyte.yw.common.services.YBClientService;
import com.yugabyte.yw.forms.MasterNodesInfo;
import com.yugabyte.yw.forms.PlatformResults;
import com.yugabyte.yw.models.Customer;
import com.yugabyte.yw.models.Universe;
import com.yugabyte.yw.models.common.YbaApi;
import com.yugabyte.yw.models.common.YbaApi.YbaApiVisibility;
import com.yugabyte.yw.models.helpers.CloudSpecificInfo;
import com.yugabyte.yw.models.helpers.NodeDetails;
import com.yugabyte.yw.rbac.annotations.AuthzPath;
Expand All @@ -31,9 +28,6 @@
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yb.client.ListMastersResponse;
import org.yb.client.YBClient;
import org.yb.util.ServerInfo;
import play.mvc.Controller;
import play.mvc.Result;

Expand Down Expand Up @@ -69,54 +63,6 @@ public Result get(UUID universeUUID) {
return PlatformResults.withData(masters);
}

@ApiOperation(
notes = "Available since YBA version 2.21.1.0.",
value = "Lists all master nodes details",
response = MasterNodesInfo.class,
responseContainer = "List")
@YbaApi(visibility = YbaApiVisibility.PUBLIC, sinceYBAVersion = "2.21.1.0")
@AuthzPath({
@RequiredPermissionOnResource(
requiredPermission =
@PermissionAttribute(resourceType = ResourceType.UNIVERSE, action = Action.READ),
resourceLocation = @Resource(path = Util.UNIVERSES, sourceType = SourceType.ENDPOINT))
})
public Result getMasterNodesInfo(UUID customerUUID, UUID universeUUID) {
// Validate customer UUID.
Customer.getOrBadRequest(customerUUID);
// Validate universe UUID.
Universe universe = Universe.getOrBadRequest(universeUUID);
List<MasterNodesInfo> masters = new ArrayList<>();
YBClient client = null;
String masterAddresses = universe.getMasterAddresses();
String certificate = universe.getCertificateNodetoNode();

if (masterAddresses == null || masterAddresses.isEmpty()) {
throw new IllegalStateException("No master host/ports ");
}

try {
client = ybService.getClient(masterAddresses, certificate);
ListMastersResponse listMastersResp = client.listMasters();
if (listMastersResp != null) {
for (ServerInfo master : listMastersResp.getMasters()) {
MasterNodesInfo masterInfo = new MasterNodesInfo(master);
// masterInfo.masterUUID = master.getUuid();
// masterInfo.port = master.getPort();
// masterInfo.isLeader = master.isLeader();
// masterInfo.host = master.getHost();
masters.add(masterInfo);
}
}
} catch (Exception e) {
LOG.warn("Failed to get list of masters in universe {} - {} ", universeUUID, e.getMessage());
throw new PlatformServiceException(INTERNAL_SERVER_ERROR, e.getMessage());
} finally {
ybService.closeClient(client, masterAddresses);
}
return PlatformResults.withData(masters);
}

@ApiOperation(
notes = "Available since YBA version 2.2.0.0.",
value = "List a master node's addresses",
Expand Down
12 changes: 12 additions & 0 deletions managed/src/main/java/com/yugabyte/yw/models/MasterInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class MasterInfo {
private String privateIp;
private Long uptimeSeconds;
private PeerRole peerRole;
private String instanceUUID;
private int port;

public enum PeerRole {
FOLLOWER,
Expand All @@ -31,7 +33,17 @@ public static MasterInfo convertFrom(GetMasterRegistrationResponse masterRegistr
.getPrivateRpcAddressesList()
.get(0)
.getHost());
result.setPort(
masterRegistrationResponse
.getServerRegistration()
.getPrivateRpcAddressesList()
.get(0)
.getPort());
}

result.setInstanceUUID(
masterRegistrationResponse.getInstanceId().getPermanentUuid().toStringUtf8());

result.setUptimeSeconds(
(System.currentTimeMillis()
- masterRegistrationResponse.getInstanceId().getStartTimeUs() / 1000)
Expand Down
74 changes: 8 additions & 66 deletions managed/src/main/resources/swagger-strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -6777,10 +6777,17 @@
"MasterInfo" : {
"description" : "Information about master",
"properties" : {
"instanceUUID" : {
"type" : "string"
},
"peerRole" : {
"enum" : [ "FOLLOWER", "LEADER", "LEARNER", "NON_PARTICIPANT", "READ_REPLICA", "UNKNOWN_ROLE" ],
"type" : "string"
},
"port" : {
"format" : "int32",
"type" : "integer"
},
"privateIp" : {
"type" : "string"
},
Expand All @@ -6789,7 +6796,7 @@
"type" : "integer"
}
},
"required" : [ "peerRole", "privateIp", "uptimeSeconds" ],
"required" : [ "instanceUUID", "peerRole", "port", "privateIp", "uptimeSeconds" ],
"type" : "object"
},
"MasterNode" : {
Expand All @@ -6805,25 +6812,6 @@
"required" : [ "cloudInfo", "masterRpcPort" ],
"type" : "object"
},
"MasterNodesInfo" : {
"properties" : {
"host" : {
"type" : "string"
},
"isLeader" : {
"type" : "boolean"
},
"masterUUID" : {
"type" : "string"
},
"port" : {
"format" : "int32",
"type" : "integer"
}
},
"required" : [ "host", "isLeader", "masterUUID", "port" ],
"type" : "object"
},
"MastersList" : {
"properties" : {
"masters" : {
Expand Down Expand Up @@ -24209,52 +24197,6 @@
"tags" : [ "Universe node metadata (metamaster)" ]
}
},
"/api/v1/customers/{cUUID}/universes/{uniUUID}/masters/info" : {
"get" : {
"description" : "Available since YBA version 2.21.1.0.",
"operationId" : "getMasterNodesInfo",
"parameters" : [ {
"format" : "uuid",
"in" : "path",
"name" : "cUUID",
"required" : true,
"type" : "string"
}, {
"format" : "uuid",
"in" : "path",
"name" : "uniUUID",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"items" : {
"$ref" : "#/definitions/MasterNodesInfo"
},
"type" : "array"
}
}
},
"responsesObject" : {
"200" : {
"description" : "successful operation",
"schema" : {
"items" : {
"$ref" : "#/definitions/MasterNodesInfo"
},
"type" : "array"
}
}
},
"security" : [ {
"apiKeyAuth" : [ ]
} ],
"summary" : "Lists all master nodes details",
"tags" : [ "Universe node metadata (metamaster)" ]
}
},
"/api/v1/customers/{cUUID}/universes/{uniUUID}/need_bootstrap" : {
"post" : {
"description" : "WARNING: This is a preview API that could change.",
Expand Down
74 changes: 8 additions & 66 deletions managed/src/main/resources/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6824,10 +6824,17 @@
"MasterInfo" : {
"description" : "Information about master",
"properties" : {
"instanceUUID" : {
"type" : "string"
},
"peerRole" : {
"enum" : [ "FOLLOWER", "LEADER", "LEARNER", "NON_PARTICIPANT", "READ_REPLICA", "UNKNOWN_ROLE" ],
"type" : "string"
},
"port" : {
"format" : "int32",
"type" : "integer"
},
"privateIp" : {
"type" : "string"
},
Expand All @@ -6836,7 +6843,7 @@
"type" : "integer"
}
},
"required" : [ "peerRole", "privateIp", "uptimeSeconds" ],
"required" : [ "instanceUUID", "peerRole", "port", "privateIp", "uptimeSeconds" ],
"type" : "object"
},
"MasterNode" : {
Expand All @@ -6852,25 +6859,6 @@
"required" : [ "cloudInfo", "masterRpcPort" ],
"type" : "object"
},
"MasterNodesInfo" : {
"properties" : {
"host" : {
"type" : "string"
},
"isLeader" : {
"type" : "boolean"
},
"masterUUID" : {
"type" : "string"
},
"port" : {
"format" : "int32",
"type" : "integer"
}
},
"required" : [ "host", "isLeader", "masterUUID", "port" ],
"type" : "object"
},
"MastersList" : {
"properties" : {
"masters" : {
Expand Down Expand Up @@ -25416,52 +25404,6 @@
"tags" : [ "Universe node metadata (metamaster)" ]
}
},
"/api/v1/customers/{cUUID}/universes/{uniUUID}/masters/info" : {
"get" : {
"description" : "Available since YBA version 2.21.1.0.",
"operationId" : "getMasterNodesInfo",
"parameters" : [ {
"format" : "uuid",
"in" : "path",
"name" : "cUUID",
"required" : true,
"type" : "string"
}, {
"format" : "uuid",
"in" : "path",
"name" : "uniUUID",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"items" : {
"$ref" : "#/definitions/MasterNodesInfo"
},
"type" : "array"
}
}
},
"responsesObject" : {
"200" : {
"description" : "successful operation",
"schema" : {
"items" : {
"$ref" : "#/definitions/MasterNodesInfo"
},
"type" : "array"
}
}
},
"security" : [ {
"apiKeyAuth" : [ ]
} ],
"summary" : "Lists all master nodes details",
"tags" : [ "Universe node metadata (metamaster)" ]
}
},
"/api/v1/customers/{cUUID}/universes/{uniUUID}/multi_table_backup" : {
"put" : {
"deprecated" : true,
Expand Down
1 change: 0 additions & 1 deletion managed/src/main/resources/v1.routes
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ POST /customers/:cUUID/universes/:uniUUID/delete_metadata c

# Universe - info about Yugabyte DB master node
GET /customers/:cUUID/universes/:uniUUID/masters com.yugabyte.yw.controllers.MetaMasterController.getMasterAddresses(cUUID: java.util.UUID, uniUUID: java.util.UUID)
GET /customers/:cUUID/universes/:uniUUID/masters/info com.yugabyte.yw.controllers.MetaMasterController.getMasterNodesInfo(cUUID: java.util.UUID, uniUUID: java.util.UUID)
GET /customers/:cUUID/universes/:uniUUID/yqlservers com.yugabyte.yw.controllers.MetaMasterController.getYQLServerAddresses(cUUID: java.util.UUID, uniUUID: java.util.UUID)
GET /customers/:cUUID/universes/:uniUUID/ysqlservers com.yugabyte.yw.controllers.MetaMasterController.getYSQLServerAddresses(cUUID: java.util.UUID, uniUUID: java.util.UUID)
GET /customers/:cUUID/universes/:uniUUID/redisservers com.yugabyte.yw.controllers.MetaMasterController.getRedisServerAddresses(cUUID: java.util.UUID, uniUUID: java.util.UUID)
Expand Down

0 comments on commit 1626058

Please sign in to comment.