Skip to content

Commit

Permalink
[PLAT-15349] Fix update_lb_config automated NLB updates
Browse files Browse the repository at this point in the history
Summary:
The subtask created in the lockAndFreeze callback does not actually run because
lockAndFreeze clears out all sub task groups at the end of its run.

Test Plan: Call update_lb_config on a GCP univ and verify LB is actually reconciled.

Reviewers: amalyshev, nsingh

Reviewed By: amalyshev, nsingh

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D38129
  • Loading branch information
iSignal committed Sep 18, 2024
1 parent 9feb6e8 commit 2cc1480
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ protected List<Backend> ensureBackends(
backendToZoneMap.entrySet().stream()
.filter(mapEntry -> zonesToRemove.contains(mapEntry.getKey()))
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
log.info("About to remove LB backends for zones {}", backendToZoneMap.keySet());
try {
apiClient.deleteBackends(backendsInZonesToRemove);
} catch (Exception e) {
Expand Down Expand Up @@ -473,7 +474,7 @@ protected void manageNodeGroup(
getAzToInstanceReferenceMap(apiClient, azToNodeIDs);
BackendService backendService = apiClient.getBackendService(regionCode, backendServiceName);
List<Backend> backends = backendService.getBackends();
log.debug("Checking backends....");
log.debug("Reconciling LB backends....");
backends = ensureBackends(apiClient, nodeAzMap, backends);
backendService.setConnectionDraining((new ConnectionDraining()).setDrainingTimeoutSec(3600));
backendService.setBackends(backends);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ public String createNewInstanceGroupInZone(String zone) throws IOException {
String instanceGroupName = "ig-" + UUID.randomUUID().toString();
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setName(instanceGroupName);
log.info("About to create new instance group " + instanceGroupName);
Operation response = compute.instanceGroups().insert(project, zone, instanceGroup).execute();
operationPoller.waitForOperationCompletion(response);
log.info("New instance group created with name: " + instanceGroupName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import play.libs.Json;

@Slf4j
public class UpdateLoadBalancerConfig extends UniverseDefinitionTaskBase {
Expand All @@ -39,20 +40,20 @@ public void run() {
try {
// Update the universe DB with the changes to be performed and set the 'updateInProgress' flag
// to prevent other updates from happening.
universe =
lockAndFreezeUniverseForUpdate(
taskParams().expectedUniverseVersion,
u -> {
// Get expected LB config
Map<LoadBalancerPlacement, LoadBalancerConfig> newLbMap =
createLoadBalancerMap(taskParams(), null, null, null);
// Get current LB config
Map<ClusterAZ, String> currentLBs = taskParams().existingLBs;
// Add old LBs to newLbMap so that nodes are removed from old LBs
compareLBs(taskParams(), newLbMap, currentLBs);
// Create manage load balancer task
createManageLoadBalancerTasks(newLbMap);
});
universe = lockAndFreezeUniverseForUpdate(taskParams().expectedUniverseVersion, null);

// Get expected LB config
Map<LoadBalancerPlacement, LoadBalancerConfig> newLbMap =
createLoadBalancerMap(taskParams(), null, null, null);

// Get current LB config
Map<ClusterAZ, String> currentLBs = taskParams().existingLBs;
// Add old LBs to newLbMap so that nodes are removed from old LBs
log.info("Original newLbMap {}, currentLBs {}", Json.toJson(newLbMap), currentLBs);
compareLBs(taskParams(), newLbMap, currentLBs);
log.info("After comparing, newLbMap {}, currentLBs {}", Json.toJson(newLbMap), currentLBs);
// Create manage load balancer task
createManageLoadBalancerTasks(newLbMap);

// Update universe to new LB config
Universe.UniverseUpdater updater =
Expand Down
2 changes: 1 addition & 1 deletion managed/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ yb {
status_polling_interval = 5s

# Timeout interval for operations to complete
timeout_interval = 30s
timeout_interval = 180s
}


Expand Down

0 comments on commit 2cc1480

Please sign in to comment.