Skip to content

Commit ff88790

Browse files
committed
chore: address comments
1 parent 30faeaf commit ff88790

File tree

6 files changed

+30
-67
lines changed

6 files changed

+30
-67
lines changed

common/lib/plugins/bluegreen/blue_green_interim_status.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ export class BlueGreenInterimStatus {
7777
port: ${this.port},
7878
hostNames:
7979
${!allHostNamesStr ? "-" : allHostNamesStr}
80-
Start ${!startTopologyStr ? "-" : startTopologyStr}
80+
startTopology: ${!startTopologyStr ? "-" : startTopologyStr}
8181
start IP map:
8282
${!startIpMap ? "-" : startIpMap}
83-
Current ${!currentTopologyStr ? "-" : currentTopologyStr}
83+
currentTopology: ${!currentTopologyStr ? "-" : currentTopologyStr}
8484
current IP map:
8585
${!currentIpMap ? "-" : currentIpMap}
8686
allStartTopologyIpChanged: ${this.allStartTopologyIpChanged}

common/lib/plugins/bluegreen/blue_green_status_monitor.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ export class BlueGreenStatusMonitor {
195195
this.intervalRate = blueGreenIntervalRate;
196196
}
197197

198-
setCollectIpAddresses(collectIpAddresses: boolean): void {
199-
this.collectedIpAddresses = collectIpAddresses;
198+
setCollectedIpAddresses(collectedIpAddresses: boolean): void {
199+
this.collectedIpAddresses = collectedIpAddresses;
200200
}
201201

202202
setCollectedTopology(collectedTopology: boolean): void {
@@ -231,7 +231,6 @@ export class BlueGreenStatusMonitor {
231231
this.currentIpAddressesByHostMap.set(host, await this.getIpAddress(host));
232232
}
233233
if (this.collectedIpAddresses) {
234-
this.startIpAddressesByHostMap.clear();
235234
this.startIpAddressesByHostMap = new Map([...this.currentIpAddressesByHostMap]);
236235
}
237236
}
@@ -342,7 +341,7 @@ export class BlueGreenStatusMonitor {
342341
logger.debug(Messages.get("Bgd.statusNotAvailable", this.role.name, BlueGreenPhase.NOT_CREATED.name));
343342
} else {
344343
this.clientWrapper = null;
345-
// this.currentPhase = null;
344+
this.currentPhase = null;
346345
this.panicMode = true;
347346
}
348347
return;

common/lib/plugins/bluegreen/blue_green_status_provider.ts

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,7 @@ export class BlueGreenStatusProvider {
253253
}
254254
}
255255
}
256-
if (
257-
sourceInterimStatus?.startTopology &&
258-
sourceInterimStatus?.hostNames?.size > 0 &&
259-
targetInterimStatus?.startTopology &&
260-
targetInterimStatus?.hostNames?.size > 0
261-
) {
256+
if (sourceInterimStatus?.hostNames?.size > 0 && targetInterimStatus?.hostNames?.size > 0) {
262257
const blueHosts: Set<string> = sourceInterimStatus.hostNames;
263258
const greenHosts: Set<string> = targetInterimStatus.hostNames;
264259

@@ -375,7 +370,7 @@ export class BlueGreenStatusProvider {
375370
case BlueGreenPhase.NOT_CREATED:
376371
for (const monitor of this.monitors) {
377372
monitor.setIntervalRate(BlueGreenIntervalRate.BASELINE);
378-
monitor.setCollectIpAddresses(false);
373+
monitor.setCollectedIpAddresses(false);
379374
monitor.setCollectedTopology(false);
380375
monitor.setUseIpAddress(false);
381376
}
@@ -384,7 +379,7 @@ export class BlueGreenStatusProvider {
384379
case BlueGreenPhase.CREATED:
385380
for (const monitor of this.monitors) {
386381
monitor.setIntervalRate(BlueGreenIntervalRate.INCREASED);
387-
monitor.setCollectIpAddresses(true);
382+
monitor.setCollectedIpAddresses(true);
388383
monitor.setCollectedTopology(true);
389384
monitor.setUseIpAddress(false);
390385
if (this.rollback) {
@@ -398,7 +393,7 @@ export class BlueGreenStatusProvider {
398393
case BlueGreenPhase.POST:
399394
this.monitors.forEach((monitor) => {
400395
monitor.setIntervalRate(BlueGreenIntervalRate.HIGH);
401-
monitor.setCollectIpAddresses(false);
396+
monitor.setCollectedIpAddresses(false);
402397
monitor.setCollectedTopology(false);
403398
monitor.setUseIpAddress(true);
404399
});
@@ -407,7 +402,7 @@ export class BlueGreenStatusProvider {
407402
case BlueGreenPhase.COMPLETED:
408403
this.monitors.forEach((monitor) => {
409404
monitor.setIntervalRate(BlueGreenIntervalRate.BASELINE);
410-
monitor.setCollectIpAddresses(false);
405+
monitor.setCollectedIpAddresses(false);
411406
monitor.setCollectedTopology(false);
412407
monitor.setUseIpAddress(false);
413408
monitor.resetCollectedData();
@@ -473,8 +468,6 @@ export class BlueGreenStatusProvider {
473468
* Execute database calls: default behaviour; no action
474469
*/
475470
protected getStatusOfPreparation(): BlueGreenStatus {
476-
// We want to limit switchover duration to DEFAULT_POST_STATUS_DURATION_NANO.
477-
478471
if (this.isSwitchoverTimerExpired()) {
479472
logger.debug(Messages.get("Bgd.switchoverTimeout"));
480473
if (this.rollback) {
@@ -498,15 +491,10 @@ export class BlueGreenStatusProvider {
498491

499492
connectRouting.push(new SubstituteConnectRouting(host, role, substituteHostSpecWithIp, [hostSpec], null));
500493

501-
connectRouting.push(
502-
new SubstituteConnectRouting(
503-
this.getHostAndPort(host, this.interimStatuses[role.value].port),
504-
role,
505-
substituteHostSpecWithIp,
506-
[hostSpec],
507-
null
508-
)
509-
);
494+
const status = this.interimStatuses[role.value];
495+
if (status) {
496+
connectRouting.push(new SubstituteConnectRouting(this.getHostAndPort(host, status.port), role, substituteHostSpecWithIp, [hostSpec], null));
497+
}
510498
});
511499

512500
return connectRouting;
@@ -520,7 +508,6 @@ export class BlueGreenStatusProvider {
520508
* Execute database calls: suspend
521509
*/
522510
protected getStatusOfInProgress(): BlueGreenStatus {
523-
// We want to limit switchover duration to DEFAULT_POST_STATUS_DURATION_NANO.
524511
if (this.isSwitchoverTimerExpired()) {
525512
logger.debug(Messages.get("Bgd.switchoverTimeout"));
526513
if (this.rollback) {
@@ -618,7 +605,6 @@ export class BlueGreenStatusProvider {
618605
}
619606

620607
protected getStatusOfPost(): BlueGreenStatus {
621-
// We want to limit switchover duration to DEFAULT_POST_STATUS_DURATION_NANO.
622608
if (this.isSwitchoverTimerExpired()) {
623609
logger.debug(Messages.get("Bgd.switchoverTimeout"));
624610
if (this.rollback) {
@@ -701,8 +687,6 @@ export class BlueGreenStatusProvider {
701687
}
702688

703689
protected getStatusOfCompleted(): BlueGreenStatus {
704-
// We want to limit switchover duration to DEFAULT_POST_STATUS_DURATION_NANO.
705-
706690
if (this.isSwitchoverTimerExpired()) {
707691
logger.debug(Messages.get("Bgd.switchoverTimeout"));
708692
if (this.rollback) {

common/lib/plugins/bluegreen/routing/suspend_until_corresponding_host_found_connect_routing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class SuspendUntilCorrespondingHostFoundConnectRouting extends BaseConnec
7878
correspondingPair = bgStatus?.correspondingHosts.get(hostInfo.host);
7979
}
8080

81-
if (!bgStatus || bgStatus.currentPhase !== BlueGreenPhase.COMPLETED) {
81+
if (!bgStatus || bgStatus.currentPhase === BlueGreenPhase.COMPLETED) {
8282
logger.debug(Messages.get("Bgd.completedContinueWithConnect", `${convertNanosToMs(getTimeInNanos() - suspendStartTime)}`));
8383
} else if (getTimeInNanos() > endTime) {
8484
throw new TimeoutError(

tests/integration/container/tests/blue_green_deployment.test.ts

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,6 @@ describe("blue green", () => {
331331

332332
const stop = new BooleanContainer(false);
333333
const promises: Promise<void>[] = [];
334-
let promiseCount: number = 0;
335-
let promiseFinishCount: number = 0;
336334

337335
const instance: TestInstanceInfo = instances[0];
338336
const dbName: string = info.defaultDbName;
@@ -347,54 +345,35 @@ describe("blue green", () => {
347345
if (rdsUtil.isNotGreenAndOldPrefixInstance(host)) {
348346
// Direct topology monitoring
349347
promises.push(getDirectTopologyMonitoringPromise(hostId, host, instance.port, dbName, stop, results.get(hostId)));
350-
promiseCount++;
351-
promiseFinishCount++;
352348

353349
// Direct blue connectivity monitoring
354350
promises.push(getDirectBlueConnectivityMonitoringPromise(hostId, host, instance.port, dbName, stop, results.get(hostId)));
355-
promiseCount++;
356-
promiseFinishCount++;
357351

358352
// Direct blue idle connectivity monitoring
359353
promises.push(getDirectBlueIdleConnectivityMonitoringPromise(hostId, host, instance.port, dbName, stop, results.get(hostId)));
360-
promiseCount++;
361-
promiseFinishCount++;
362354

363355
// Wrapper blue idle connectivity monitoring
364356
promises.push(getWrapperBlueIdleConnectivityMonitoringPromise(hostId, host, instance.port, dbName, stop, results.get(hostId)));
365-
promiseCount++;
366-
promiseFinishCount++;
367357

368358
// Wrapper blue executing connectivity monitoring
369359
promises.push(getWrapperBlueExecutingConnectivityMonitoringPromise(hostId, host, instance.port, dbName, stop, results.get(hostId)));
370-
promiseCount++;
371-
promiseFinishCount++;
372360

373361
// Wrapper blue new connection monitoring
374362
promises.push(getWrapperBlueNewConnectionMonitoringPromise(hostId, host, instance.port, dbName, stop, results.get(hostId)));
375-
promiseCount++;
376363

377364
// Blue DNS monitoring
378365
promises.push(getBlueDnsMonitoringPromise(hostId, host, stop, results.get(hostId)));
379-
promiseCount++;
380-
promiseFinishCount++;
381366
}
382367

383368
if (rdsUtil.isGreenInstance(host)) {
384369
// Direct topology monitoring
385370
promises.push(getDirectTopologyMonitoringPromise(hostId, host, instance.port, dbName, stop, results.get(hostId)));
386-
promiseCount++;
387-
promiseFinishCount++;
388371

389372
// Wrapper green connectivity monitoring
390373
promises.push(getWrapperGreenConnectivityMonitoringPromise(hostId, host, instance.port, dbName, stop, results.get(hostId)));
391-
promiseCount++;
392-
promiseFinishCount++;
393374

394375
// Green DNS monitoring
395376
promises.push(getGreenDnsMonitoringPromise(hostId, host, stop, results.get(hostId)));
396-
promiseCount++;
397-
promiseFinishCount++;
398377

399378
if (iamEnabled) {
400379
promises.push(
@@ -413,9 +392,6 @@ describe("blue green", () => {
413392
)
414393
);
415394

416-
promiseCount++;
417-
promiseFinishCount++;
418-
419395
promises.push(
420396
getGreenIamConnectivityMonitoringPromise(
421397
hostId,
@@ -431,16 +407,11 @@ describe("blue green", () => {
431407
false
432408
)
433409
);
434-
435-
promiseCount++;
436-
promiseFinishCount++;
437410
}
438411
}
439412
}
440413

441414
promises.push(getBlueGreenSwitchoverTriggerPromise(info.blueGreenDeploymentId, results));
442-
promiseCount++;
443-
promiseFinishCount++;
444415

445416
results.forEach((value, key) => (value.startTime = startTimeNano));
446417

@@ -453,8 +424,12 @@ describe("blue green", () => {
453424

454425
if (unhandledErrors.length > 0) {
455426
logUnhandledErrors();
427+
await PluginManager.releaseResources();
456428
fail("There are unhandled errors.");
457429
}
430+
431+
stop.set(true);
432+
await PluginManager.releaseResources();
458433
});
459434
});
460435

@@ -576,7 +551,7 @@ async function getDirectBlueConnectivityMonitoringPromise(
576551

577552
logger.debug(`[DirectBlueConnectivity @ ${hostId}] Starting connectivity monitoring.`);
578553

579-
while (!stop) {
554+
while (!stop.get()) {
580555
try {
581556
await client.query("SELECT 1");
582557
await sleep(1000);
@@ -902,7 +877,7 @@ async function getGreenIamConnectivityMonitoringPromise(
902877

903878
logger.debug(`[DirectGreenIamIp${prefix} @ ${hostId}] Starting connectivity monitoring ${iamTokenHost}.`);
904879

905-
while (!stop) {
880+
while (!stop.get()) {
906881
const signer = new Signer({
907882
hostname: iamTokenHost,
908883
port: port,

tests/integration/host/src/test/java/integration/host/TestEnvironmentConfig.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ private static void initEnv(TestEnvironmentConfig env) {
380380
env.reuseDb = Boolean.parseBoolean(System.getenv("REUSE_RDS_DB"));
381381
env.rdsDbName = System.getenv("RDS_DB_NAME"); // "cluster-mysql", "instance-name", "cluster-multi-az-name"
382382
env.rdsDbDomain = System.getenv("RDS_DB_DOMAIN"); // "XYZ.us-west-2.rds.amazonaws.com"
383-
env.rdsEndpoint = System.getenv("RDS_ENDPOINT"); // "XYZ.us-west-2.rds.amazonaws.com"
383+
env.rdsEndpoint = System.getenv("RDS_ENDPOINT"); // "https://rds-int.amazon.com"
384384

385385
env.auroraMySqlDbEngineVersion = System.getenv("MYSQL_VERSION");
386386
env.auroraPgDbEngineVersion = System.getenv("PG_VERSION");
@@ -749,9 +749,14 @@ private static void deAuthorizeIP(TestEnvironmentConfig env) {
749749
throw new RuntimeException(e);
750750
}
751751
}
752-
env.auroraUtil.ec2DeauthorizesIP(env.runnerIP);
753-
LOGGER.finest(String.format("Test runner IP %s de-authorized. Usage count: %d",
754-
env.runnerIP, ipAddressUsageRefCount.get()));
752+
if (!env.reuseDb) {
753+
env.auroraUtil.ec2DeauthorizesIP(env.runnerIP);
754+
LOGGER.finest(String.format("Test runner IP %s de-authorized. Usage count: %d",
755+
env.runnerIP, ipAddressUsageRefCount.get()));
756+
} else {
757+
LOGGER.finest("The IP address usage count hit 0, but the REUSE_RDS_DB was set to true, so IP "
758+
+ "de-authorization was skipped.");
759+
}
755760
} else {
756761
LOGGER.finest("IP usage count: " + ipAddressUsageRefCount.get());
757762
}

0 commit comments

Comments
 (0)