Skip to content

Commit

Permalink
[PLAT-15205] YBA callhome improvements
Browse files Browse the repository at this point in the history
Summary: Change YBA callhome url to the new diagnostics endpoint and only collect email domains.

Test Plan: Manually verfied that YBA is able to send the correct payload to the new endpoint.

Reviewers: #yba-api-review!, svarshney

Reviewed By: svarshney

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D38072
  • Loading branch information
asharma-yb committed Sep 19, 2024
1 parent e6bb890 commit 1552321
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public CallHomeManager(ApiHelper apiHelper, ConfigHelper configHelper) {
}

// Email address from YugaByte to which to send diagnostics, if enabled.
private final String YB_CALLHOME_URL = "https://yw-diagnostics.yugabyte.com";
private final String YB_CALLHOME_URL = "https://diagnostics.yugabyte.com";

public static final Logger LOG = LoggerFactory.getLogger(CallHomeManager.class);

Expand All @@ -81,7 +81,11 @@ public void sendDiagnostics(Customer c) {
if (!callhomeLevel.isDisabled()) {
LOG.info("Starting collecting diagnostics");
JsonNode payload = collectDiagnostics(c, callhomeLevel);
LOG.info("Sending collected diagnostics to " + YB_CALLHOME_URL);
LOG.trace(
"Sending collected diagnostics to "
+ YB_CALLHOME_URL
+ " with payload "
+ payload.toPrettyString());
// Api Helper handles exceptions
Map<String, String> headers = new HashMap<>();
headers.put(
Expand All @@ -97,7 +101,7 @@ public JsonNode collectDiagnostics(Customer c, CollectionLevel callhomeLevel) {
// Build customer details json
payload.put("customer_uuid", c.getUuid().toString());
payload.put("code", c.getCode());
payload.put("email", Users.getAllEmailsForCustomer(c.getUuid()));
payload.put("email", Users.getAllEmailDomainsForCustomer(c.getUuid()));
payload.put("creation_date", c.getCreationDate().toString());

// k8s operator info
Expand Down
8 changes: 6 additions & 2 deletions managed/src/main/java/com/yugabyte/yw/models/Users.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,13 @@ public void deleteAuthToken() {
save();
}

public static String getAllEmailsForCustomer(UUID customerUUID) {
public static String getAllEmailDomainsForCustomer(UUID customerUUID) {
List<Users> users = Users.getAll(customerUUID);
return users.stream().map(user -> user.getEmail()).collect(Collectors.joining(","));
return users.stream()
.map(user -> user.getEmail().substring(user.getEmail().indexOf("@") + 1))
.collect(Collectors.toSet())
.stream()
.collect(Collectors.joining(","));
}

public static List<Users> getAllReadOnly() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void testSendDiagnostics() {
String expectedToken =
Base64.getEncoder().encodeToString(defaultCustomer.getUuid().toString().getBytes());
assertEquals(expectedToken, headers.getValue().get("X-AUTH-TOKEN"));
assertEquals("https://yw-diagnostics.yugabyte.com", url.getValue());
assertEquals("https://diagnostics.yugabyte.com", url.getValue());
}

@Test
Expand Down

0 comments on commit 1552321

Please sign in to comment.