Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always require syncMode to be defined #3497

Merged
merged 6 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const _ = require('lodash')
const axios = require('axios')
const { logger } = require('../../../logging')
const Utils = require('../../../utils')
const { SyncType, JOB_NAMES } = require('../stateMachineConstants')
const { SyncType, JOB_NAMES, SYNC_MODES } = require('../stateMachineConstants')
const SyncRequestDeDuplicator = require('./SyncRequestDeDuplicator')

/**
Expand All @@ -21,6 +21,17 @@ const getNewOrExistingSyncReq = ({
syncMode,
immediate = false
}) => {
if (
!userWallet ||
!primaryEndpoint ||
!secondaryEndpoint ||
!syncType ||
!syncMode
) {
throw new Error(
`getNewOrExistingSyncReq missing parameter - userWallet: ${userWallet}, primaryEndpoint: ${primaryEndpoint}, secondaryEndpoint: ${secondaryEndpoint}, syncType: ${syncType}, syncMode: ${syncMode}`
)
}
/**
* If duplicate sync already exists, do not add and instead return existing sync job info
* Ignore syncMode when checking for duplicates, since it doesn't matter
Expand Down Expand Up @@ -99,6 +110,7 @@ const issueSyncRequestsUntilSynced = async (
secondaryEndpoint: secondaryUrl,
primaryEndpoint: primaryUrl,
syncType: SyncType.Manual,
syncMode: SYNC_MODES.SyncSecondaryFromPrimary,
immediate: true
})
if (!_.isEmpty(duplicateSyncReq)) {
Expand Down Expand Up @@ -139,7 +151,8 @@ const issueSyncRequestsUntilSynced = async (
userWallet: wallet,
secondaryEndpoint: secondaryUrl,
primaryEndpoint: primaryUrl,
syncType: SyncType.Manual
syncType: SyncType.Manual,
syncMode: SYNC_MODES.SyncSecondaryFromPrimary
})
if (!_.isEmpty(duplicateSyncReq)) {
// Log duplicate and return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const {
SyncType,
RECONFIG_MODES,
MAX_SELECT_NEW_REPLICA_SET_ATTEMPTS,
QUEUE_NAMES
QUEUE_NAMES,
SYNC_MODES
} = require('../stateMachineConstants')
const { retrieveClockValueForUserFromReplica } = require('../stateMachineUtils')
const CNodeToSpIdMapManager = require('../CNodeToSpIdMapManager')
Expand Down Expand Up @@ -536,7 +537,8 @@ const _issueUpdateReplicaSetOp = async (
userWallet: wallet,
primaryEndpoint: newPrimary,
secondaryEndpoint: newSecondary1,
syncType: SyncType.Recurring
syncType: SyncType.Recurring,
syncMode: SYNC_MODES.SyncSecondaryFromPrimary
})
if (!_.isEmpty(duplicateSyncReq)) {
logger.warn(
Expand All @@ -554,7 +556,8 @@ const _issueUpdateReplicaSetOp = async (
userWallet: wallet,
primaryEndpoint: newPrimary,
secondaryEndpoint: newSecondary2,
syncType: SyncType.Recurring
syncType: SyncType.Recurring,
syncMode: SYNC_MODES.SyncSecondaryFromPrimary
})
if (!_.isEmpty(duplicateSyncReq2)) {
logger.warn(
Expand Down
5 changes: 4 additions & 1 deletion creator-node/test/updateReplicaSet.jobProcessor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const config = require('../src/config')
const {
SyncType,
RECONFIG_MODES,
QUEUE_NAMES
QUEUE_NAMES,
SYNC_MODES
} = require('../src/services/stateMachineManager/stateMachineConstants')

chai.use(require('sinon-chai'))
Expand Down Expand Up @@ -174,12 +175,14 @@ describe('test updateReplicaSet job processor', function () {
primaryEndpoint: primary,
secondaryEndpoint: secondary2,
syncType: SyncType.Recurring,
syncMode: SYNC_MODES.SyncSecondaryFromPrimary,
userWallet: wallet
},
{
primaryEndpoint: primary,
secondaryEndpoint: fourthHealthyNode,
syncType: SyncType.Recurring,
syncMode: SYNC_MODES.SyncSecondaryFromPrimary,
userWallet: wallet
}
]
Expand Down