Skip to content

Commit

Permalink
[ASI-836] [CN] Add reconfigNodewhitelist envvar & consume in reconfig (
Browse files Browse the repository at this point in the history
  • Loading branch information
SidSethi committed Apr 6, 2022
1 parent 0605556 commit 85cc8c0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
6 changes: 6 additions & 0 deletions creator-node/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,12 @@ const config = convict({
env: 'openRestyCacheCIDEnabled',
default: false
},
reconfigNodeWhitelist: {
doc: 'Comma separated string - list of Content Nodes to select from for reconfig. Empty string = whitelist all.',
format: String,
env: 'reconfigNodeWhitelist',
default: ''
},
minimumTranscodingSlotsAvailable: {
doc: 'The minimum number of slots needed to be available for TranscodingQueue to accept more jobs',
format: 'nat',
Expand Down
8 changes: 7 additions & 1 deletion creator-node/src/snapbackSM/snapbackSM.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class SnapbackSM {
'maxSyncMonitoringDurationInMs'
)

const reconfigNodeWhitelist = this.nodeConfig.get('reconfigNodeWhitelist')
this.reconfigNodeWhitelist = reconfigNodeWhitelist
? new Set(reconfigNodeWhitelist.split(','))
: null

// Throw an error if no libs are provided
if (
!this.audiusLibs ||
Expand Down Expand Up @@ -1040,7 +1045,8 @@ class SnapbackSM {
const { services: healthyServicesMap } =
await this.audiusLibs.ServiceProvider.autoSelectCreatorNodes({
performSyncCheck: false,
log: false
whitelist: this.reconfigNodeWhitelist,
log: true
})

const healthyNodes = Object.keys(healthyServicesMap)
Expand Down
39 changes: 38 additions & 1 deletion libs/src/services/creatorNode/CreatorNodeSelection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,43 @@ describe('test CreatorNodeSelection', () => {
)
})

it('Return nothing if whitelist is empty set', async function () {
const healthy = 'https://healthy.audius.co'
nock(healthy)
.get('/health_check/verbose')
.reply(200, { data: defaultHealthCheckData })

const healthyButSlow = 'https://healthybutslow.audius.co'
nock(healthyButSlow)
.get('/health_check/verbose')
.delay(100)
.reply(200, { data: defaultHealthCheckData })

const healthyButSlowest = 'https://healthybutslowest.audius.co'
nock(healthyButSlowest)
.get('/health_check/verbose')
.delay(200)
.reply(200, { data: defaultHealthCheckData })

const cns = new CreatorNodeSelection({
creatorNode: mockCreatorNode,
numberOfNodes: 3,
ethContracts: mockEthContracts(
[healthy, healthyButSlow, healthyButSlowest],
'1.2.3'
),
whitelist: new Set([]),
blacklist: null
})

const { primary, secondaries, services } = await cns.select()
assert(primary === undefined)
assert(secondaries.length === 0)

const returnedHealthyServices = new Set(Object.keys(services))
assert(returnedHealthyServices.size === 0)
})

it('select healthy nodes as the primary and secondary, and do not select unhealthy nodes', async () => {
const upToDate = 'https://upToDate.audius.co'
nock(upToDate)
Expand Down Expand Up @@ -183,7 +220,7 @@ describe('test CreatorNodeSelection', () => {
const { primary, secondaries, services } = await cns.select(true, false)

// All unhealthy are bad candidates so don't select anything
assert(!primary)
assert(primary === undefined)
assert(secondaries.length === 0)

const returnedHealthyServices = new Set(Object.keys(services))
Expand Down

0 comments on commit 85cc8c0

Please sign in to comment.