Skip to content

Commit

Permalink
CN Reconfig mode primary only override (#4161)
Browse files Browse the repository at this point in the history
  • Loading branch information
SidSethi committed Oct 25, 2022
1 parent 59b086a commit b1cfbcb
Show file tree
Hide file tree
Showing 4 changed files with 459 additions and 22 deletions.
38 changes: 19 additions & 19 deletions creator-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions creator-node/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ const config = convict({
env: 'snapbackHighestReconfigMode',
default: 'PRIMARY_AND_OR_SECONDARIES'
},
reconfigModePrimaryOnly: {
doc: 'Override for `snapbackHighestReconfigMode` to only reconfig primary from replica set',
format: Boolean,
env: 'reconfigModePrimaryOnly',
default: false
},
devMode: {
doc: 'Used to differentiate production vs dev mode for node',
format: 'BooleanCustom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const reconfigNodeWhitelist = config.get('reconfigNodeWhitelist')
: null

const RECONFIG_SP_IDS_BLACKLIST: number[] = config.get('reconfigSPIdBlacklist')
const RECONFIG_MODE_PRIMARY_ONLY: Boolean = config.get(
'reconfigModePrimaryOnly'
)

/**
* Updates replica sets of a user who has one or more unhealthy nodes as their primary or secondaries.
Expand Down Expand Up @@ -820,6 +823,15 @@ const _issueUpdateReplicaSetOp = async (
*/
const _isReconfigEnabled = (enabledReconfigModes: string[], mode: string) => {
if (mode === RECONFIG_MODES.RECONFIG_DISABLED.key) return false

// If primary only override is enabled, only issue reconfig if mode is in enabled modes set and indicates a primary reconfig
if (RECONFIG_MODE_PRIMARY_ONLY) {
return (
enabledReconfigModes.includes(mode) &&
mode === RECONFIG_MODES.PRIMARY_AND_OR_SECONDARIES.key
)
}

return enabledReconfigModes.includes(mode)
}

Expand Down

0 comments on commit b1cfbcb

Please sign in to comment.