Skip to content

Refactor reconciliation step for conciseness #710

Open
@tilacog

Description

@tilacog

There are seemingly redundant conditionals in the reconciliation loop code that could be improved for conciseness.

// Log details if active deployments are different from target deployments
const isReconciliationNeeded = !isEqual(
deploymentIDSet(activeDeployments),
deploymentIDSet(targetDeployments),
)
if (isReconciliationNeeded) {
// TODO: Return early in here case reconciliation is not needed
this.logger.debug('Reconcile deployments', {
syncing: activeDeployments.map(id => id.display),
target: targetDeployments.map(id => id.display),
withActiveOrRecentlyClosedAllocation: eligibleAllocationDeployments.map(
id => id.display,
),
})
}
// Identify which subgraphs to deploy and which to remove
const deploy = targetDeployments.filter(
deployment => !deploymentInList(activeDeployments, deployment),
)
const remove = activeDeployments.filter(
deployment =>
!deploymentInList(targetDeployments, deployment) &&
!deploymentInList(eligibleAllocationDeployments, deployment),
)
// TODO: Same as before: Should we return early in here case reconciliation is not needed? Also,
// this conditional seems the be doing the same work as the previous one, we should consolidate
// them.
if (deploy.length + remove.length !== 0) {
this.logger.info('Deployment changes', {
deploy: deploy.map(id => id.display),
remove: remove.map(id => id.display),
})
} else {
this.logger.debug('No deployment changes are necessary')
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🙏 Feature Requests

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions