Skip to content

Commit

Permalink
Glue DC node tasks together
Browse files Browse the repository at this point in the history
The first phase of `jira-node-X` tasks was merely building objects,
without actual provisioning, so it was instant.
Previously the `provision jira-node-X` task was happening after
the `provision load balancer` task, but those tasks are independent.
They can run in parallel, so `provision jira-node-X` can be shifted
earlier. Now it's called `install jira-node-X` and publishes SSH and EC2
instance details as events as early as possible.
  • Loading branch information
dagguh committed Jan 9, 2024
1 parent 2ce0c72 commit 34d6dfd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Dropping a requirement of a major version of a dependency is a new contract.
[Unreleased]: https://github.com/atlassian/aws-infrastructure/compare/release-3.1.4...master

### Fixed
- Provision Jira nodes in parallel to the load balancer.
- Glue `jira-node-X` and `provision jira-node-X` tasks together into `install jira-node-X`.
- Clean up `start node X` task name.

## [3.1.4] - 2024-01-03
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,36 +184,33 @@ class DataCenterFormula private constructor(
sharedHome
}

val nodeFormulas = jiraNodes
.asSequence()
.mapIndexed { i: Int, instance ->
val config = configs[i]
task(config.name, Callable {
EventBus.publish(instance)
val sshIpAddress = instance.publicIpAddress
val ssh = Ssh(SshHost(sshIpAddress, "ubuntu", keyPath), connectivityPatience = 5)
key.get().file.facilitateSsh(sshIpAddress)
DiagnosableNodeFormula(
delegate = DataCenterNodeFormula(
base = StandaloneNodeFormula(
resultsTransport = resultsTransport,
databaseIp = databaseMachine.privateIpAddress,
jiraHomeSource = jiraHomeSource,
pluginsTransport = pluginsTransport,
productDistribution = productDistribution,
ssh = ssh,
waitForUpgrades = waitForUpgrades,
config = config,
computer = computer,
adminPasswordPlainText = adminPasswordPlainText
),
sharedHome = sharedHome,
privateIpAddress = instance.privateIpAddress
)
)
})
val nodesProvisioning = jiraNodes.mapIndexed { i: Int, instance ->
val nodeConfig = configs[i]
executor.submitWithLogContext("install ${nodeConfig.name}") {
EventBus.publish(instance)
val sshIpAddress = instance.publicIpAddress
val ssh = Ssh(SshHost(sshIpAddress, "ubuntu", keyPath), connectivityPatience = 5)
key.get().file.facilitateSsh(sshIpAddress)
val baseNode = StandaloneNodeFormula(
resultsTransport = resultsTransport,
databaseIp = databaseMachine.privateIpAddress,
jiraHomeSource = jiraHomeSource,
pluginsTransport = pluginsTransport,
productDistribution = productDistribution,
ssh = ssh,
waitForUpgrades = waitForUpgrades,
config = nodeConfig,
computer = computer,
adminPasswordPlainText = adminPasswordPlainText
)
val dcNode = DataCenterNodeFormula(
base = baseNode,
sharedHome = sharedHome,
privateIpAddress = instance.privateIpAddress
)
DiagnosableNodeFormula(dcNode).provision()
}
.toList()
}

val provisionedLoadBalancer = futureLoadBalancer.get()
val loadBalancer = provisionedLoadBalancer.loadBalancer
Expand Down Expand Up @@ -289,15 +286,12 @@ class DataCenterFormula private constructor(
}
}

val nodesProvisioning = nodeFormulas.map {
executor.submitWithLogContext("provision ${it.name}") { it.provision() }
}

val databaseDataLocation = setupDatabase.get()

val updateJiraConfiguration =
if (loadBalancer is ApacheProxyLoadBalancer) listOf(loadBalancer::updateJiraConfiguration) else emptyList()

// official docs require nodes to be added one by one: https://confluence.atlassian.com/adminjiraserver/installing-jira-data-center-938846870.html
val nodes = nodesProvisioning
.map { it.get() }
.map { node -> task("start $node", Callable { node.start(updateJiraConfiguration) }) }
Expand Down

0 comments on commit 34d6dfd

Please sign in to comment.