From a6d623335a1060d1f695dca391cd2d1f2cd23a8e Mon Sep 17 00:00:00 2001 From: Theo Ilie Date: Tue, 6 Sep 2022 21:40:17 +0000 Subject: [PATCH 1/2] Gate reconfig of primary to node endpoint changing --- .../updateReplicaSet.jobProcessor.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/creator-node/src/services/stateMachineManager/stateReconciliation/updateReplicaSet.jobProcessor.ts b/creator-node/src/services/stateMachineManager/stateReconciliation/updateReplicaSet.jobProcessor.ts index da9ea835c93..343da459566 100644 --- a/creator-node/src/services/stateMachineManager/stateReconciliation/updateReplicaSet.jobProcessor.ts +++ b/creator-node/src/services/stateMachineManager/stateReconciliation/updateReplicaSet.jobProcessor.ts @@ -592,7 +592,16 @@ const _issueUpdateReplicaSetOp = async ( throw new Error(errorMsg) } - if (!issueReconfig) { + /** + * TODO: Remove this after rollout. This is an extra gating condition to NOT issue reconfigs of primaries + * except when the cause of the reconfig is that the primary endpoint was deregistered or changed. + */ + const causeOfReconfigIsPrimaryChanged = + !!ContentNodeInfoManager.getCNodeEndpointToSpIdMap()[primary] + const dontIssueEvenIfEnabled = + causeOfReconfigIsPrimaryChanged && + reconfigType === RECONFIG_MODES.PRIMARY_AND_OR_SECONDARIES + if (!issueReconfig || dontIssueEvenIfEnabled) { response.result = UpdateReplicaSetJobResult.SuccessIssueReconfigDisabled return response } From 3a47acf7c6766cfdc437c5f6f773b8726c9774b5 Mon Sep 17 00:00:00 2001 From: Theo Ilie Date: Wed, 7 Sep 2022 16:03:30 +0000 Subject: [PATCH 2/2] Fix inverse logic --- .../updateReplicaSet.jobProcessor.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/creator-node/src/services/stateMachineManager/stateReconciliation/updateReplicaSet.jobProcessor.ts b/creator-node/src/services/stateMachineManager/stateReconciliation/updateReplicaSet.jobProcessor.ts index 343da459566..4644eb0ccde 100644 --- a/creator-node/src/services/stateMachineManager/stateReconciliation/updateReplicaSet.jobProcessor.ts +++ b/creator-node/src/services/stateMachineManager/stateReconciliation/updateReplicaSet.jobProcessor.ts @@ -592,16 +592,20 @@ const _issueUpdateReplicaSetOp = async ( throw new Error(errorMsg) } + if (!issueReconfig) { + response.result = UpdateReplicaSetJobResult.SuccessIssueReconfigDisabled + return response + } /** - * TODO: Remove this after rollout. This is an extra gating condition to NOT issue reconfigs of primaries - * except when the cause of the reconfig is that the primary endpoint was deregistered or changed. + * TODO: Remove this after rollout. This is an extra gating condition that only applies to primary reconfigs: + * ONLY issue reconfigs of primaries when the cause of the reconfig is that the primary endpoint was deregistered or changed. */ - const causeOfReconfigIsPrimaryChanged = - !!ContentNodeInfoManager.getCNodeEndpointToSpIdMap()[primary] - const dontIssueEvenIfEnabled = - causeOfReconfigIsPrimaryChanged && + const primaryExistsOnChain = + ContentNodeInfoManager.getCNodeEndpointToSpIdMap().hasOwnProperty(primary) + const isPrimaryReconfig = reconfigType === RECONFIG_MODES.PRIMARY_AND_OR_SECONDARIES - if (!issueReconfig || dontIssueEvenIfEnabled) { + const shouldSkipPrimaryReconfig = isPrimaryReconfig && primaryExistsOnChain + if (shouldSkipPrimaryReconfig) { response.result = UpdateReplicaSetJobResult.SuccessIssueReconfigDisabled return response }