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

HL-1205 Postgres support #80

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ Adding a requirement of a major version of a dependency is breaking a contract.
Dropping a requirement of a major version of a dependency is a new contract.

## [Unreleased]
[Unreleased]: https://github.com/atlassian/aws-infrastructure/compare/release-2.20.0...master
[Unreleased]: https://github.com/atlassian/aws-infrastructure/compare/release-2.20.1...master

## [2.20.1] - 2020-01-31
[2.20.1]: https://github.com/atlassian/aws-infrastructure/compare/release-2.20.0...2.20.1

### Fixed
- Eliminate sudo warnings emitted when the hostname was not resolvable. Fix [JPERF-595].
Expand Down
8 changes: 4 additions & 4 deletions gradle/dependency-locks/apiDependenciesMetadata.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ com.amazonaws:aws-java-sdk-sts:1.11.424
com.amazonaws:aws-java-sdk-support:1.11.424
com.amazonaws:jmespath-java:1.11.424
com.atlassian.performance.tools:aws-resources:1.4.0
com.atlassian.performance.tools:concurrency:1.0.0
com.atlassian.performance.tools:infrastructure:4.13.0
com.atlassian.performance.tools:concurrency:1.1.0
com.atlassian.performance.tools:infrastructure:4.14.5-SNAPSHOT
com.atlassian.performance.tools:io:1.2.0
com.atlassian.performance.tools:jira-actions:3.3.0
com.atlassian.performance.tools:jira-software-actions:1.3.1
com.atlassian.performance.tools:jira-software-actions:1.3.2
com.atlassian.performance.tools:jvm-tasks:1.0.1
com.atlassian.performance.tools:ssh:2.3.0
com.atlassian.performance.tools:virtual-users:3.6.4
com.atlassian.performance.tools:virtual-users:3.10.0
com.fasterxml.jackson.core:jackson-annotations:2.6.0
com.fasterxml.jackson.core:jackson-core:2.9.4
com.fasterxml.jackson.core:jackson-databind:2.6.7.1
Expand Down
8 changes: 3 additions & 5 deletions gradle/dependency-locks/compileClasspath.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ com.amazonaws:aws-java-sdk-sts:1.11.424
com.amazonaws:aws-java-sdk-support:1.11.424
com.amazonaws:jmespath-java:1.11.424
com.atlassian.performance.tools:aws-resources:1.4.0
com.atlassian.performance.tools:concurrency:1.0.0
com.atlassian.performance.tools:infrastructure:4.13.0
com.atlassian.performance.tools:concurrency:1.1.0
com.atlassian.performance.tools:infrastructure:4.14.5-SNAPSHOT
com.atlassian.performance.tools:io:1.2.0
com.atlassian.performance.tools:jira-actions:3.3.0
com.atlassian.performance.tools:jvm-tasks:1.0.1
com.atlassian.performance.tools:ssh:2.3.0
com.atlassian.performance.tools:virtual-users:3.6.4
com.atlassian.performance.tools:virtual-users:3.10.0
com.atlassian.performance.tools:workspace:2.0.0
com.fasterxml.jackson.core:jackson-annotations:2.6.0
com.fasterxml.jackson.core:jackson-core:2.9.4
Expand Down Expand Up @@ -58,8 +58,6 @@ org.glassfish:javax.json:1.1
org.jetbrains.kotlin:kotlin-stdlib-common:1.2.70
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.70
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.70
org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.70
org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.70
org.jetbrains.kotlin:kotlin-stdlib:1.2.70
org.jetbrains:annotations:13.0
org.jvnet.staxex:stax-ex:1.7.8
Expand Down
8 changes: 4 additions & 4 deletions gradle/dependency-locks/default.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ com.amazonaws:aws-java-sdk-sts:1.11.424
com.amazonaws:aws-java-sdk-support:1.11.424
com.amazonaws:jmespath-java:1.11.424
com.atlassian.performance.tools:aws-resources:1.4.0
com.atlassian.performance.tools:concurrency:1.0.0
com.atlassian.performance.tools:infrastructure:4.13.0
com.atlassian.performance.tools:concurrency:1.1.0
com.atlassian.performance.tools:infrastructure:4.14.5-SNAPSHOT
com.atlassian.performance.tools:io:1.2.0
com.atlassian.performance.tools:jira-actions:3.3.0
com.atlassian.performance.tools:jira-software-actions:1.3.1
com.atlassian.performance.tools:jira-software-actions:1.3.2
com.atlassian.performance.tools:jvm-tasks:1.0.1
com.atlassian.performance.tools:ssh:2.3.0
com.atlassian.performance.tools:virtual-users:3.6.4
com.atlassian.performance.tools:virtual-users:3.10.0
com.atlassian.performance.tools:workspace:2.0.0
com.fasterxml.jackson.core:jackson-annotations:2.6.0
com.fasterxml.jackson.core:jackson-core:2.9.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ com.amazonaws:aws-java-sdk-sts:1.11.424
com.amazonaws:aws-java-sdk-support:1.11.424
com.amazonaws:jmespath-java:1.11.424
com.atlassian.performance.tools:aws-resources:1.4.0
com.atlassian.performance.tools:concurrency:1.0.0
com.atlassian.performance.tools:infrastructure:4.13.0
com.atlassian.performance.tools:concurrency:1.1.0
com.atlassian.performance.tools:infrastructure:4.14.5-SNAPSHOT
com.atlassian.performance.tools:io:1.2.0
com.atlassian.performance.tools:jira-actions:3.3.0
com.atlassian.performance.tools:jira-software-actions:1.3.1
com.atlassian.performance.tools:jira-software-actions:1.3.2
com.atlassian.performance.tools:jvm-tasks:1.0.1
com.atlassian.performance.tools:ssh:2.3.0
com.atlassian.performance.tools:virtual-users:3.6.4
com.atlassian.performance.tools:virtual-users:3.10.0
com.atlassian.performance.tools:workspace:2.0.0
com.fasterxml.jackson.core:jackson-annotations:2.6.0
com.fasterxml.jackson.core:jackson-core:2.9.4
Expand Down
8 changes: 4 additions & 4 deletions gradle/dependency-locks/runtimeClasspath.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ com.amazonaws:aws-java-sdk-sts:1.11.424
com.amazonaws:aws-java-sdk-support:1.11.424
com.amazonaws:jmespath-java:1.11.424
com.atlassian.performance.tools:aws-resources:1.4.0
com.atlassian.performance.tools:concurrency:1.0.0
com.atlassian.performance.tools:infrastructure:4.13.0
com.atlassian.performance.tools:concurrency:1.1.0
com.atlassian.performance.tools:infrastructure:4.14.5-SNAPSHOT
com.atlassian.performance.tools:io:1.2.0
com.atlassian.performance.tools:jira-actions:3.3.0
com.atlassian.performance.tools:jira-software-actions:1.3.1
com.atlassian.performance.tools:jira-software-actions:1.3.2
com.atlassian.performance.tools:jvm-tasks:1.0.1
com.atlassian.performance.tools:ssh:2.3.0
com.atlassian.performance.tools:virtual-users:3.6.4
com.atlassian.performance.tools:virtual-users:3.10.0
com.atlassian.performance.tools:workspace:2.0.0
com.fasterxml.jackson.core:jackson-annotations:2.6.0
com.fasterxml.jackson.core:jackson-core:2.9.4
Expand Down
8 changes: 3 additions & 5 deletions gradle/dependency-locks/testCompileClasspath.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ com.amazonaws:aws-java-sdk-sts:1.11.424
com.amazonaws:aws-java-sdk-support:1.11.424
com.amazonaws:jmespath-java:1.11.424
com.atlassian.performance.tools:aws-resources:1.4.0
com.atlassian.performance.tools:concurrency:1.0.0
com.atlassian.performance.tools:infrastructure:4.13.0
com.atlassian.performance.tools:concurrency:1.1.0
com.atlassian.performance.tools:infrastructure:4.14.5-SNAPSHOT
com.atlassian.performance.tools:io:1.2.0
com.atlassian.performance.tools:jira-actions:3.3.0
com.atlassian.performance.tools:jvm-tasks:1.0.1
com.atlassian.performance.tools:ssh:2.3.0
com.atlassian.performance.tools:virtual-users:3.6.4
com.atlassian.performance.tools:virtual-users:3.10.0
com.atlassian.performance.tools:workspace:2.0.0
com.fasterxml.jackson.core:jackson-annotations:2.6.0
com.fasterxml.jackson.core:jackson-core:2.9.4
Expand Down Expand Up @@ -62,8 +62,6 @@ org.hamcrest:hamcrest-library:1.3
org.jetbrains.kotlin:kotlin-stdlib-common:1.2.70
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.70
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.70
org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.70
org.jetbrains.kotlin:kotlin-stdlib-jre8:1.2.70
org.jetbrains.kotlin:kotlin-stdlib:1.2.70
org.jetbrains:annotations:13.0
org.jvnet.staxex:stax-ex:1.7.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ com.amazonaws:aws-java-sdk-sts:1.11.424
com.amazonaws:aws-java-sdk-support:1.11.424
com.amazonaws:jmespath-java:1.11.424
com.atlassian.performance.tools:aws-resources:1.4.0
com.atlassian.performance.tools:concurrency:1.0.0
com.atlassian.performance.tools:infrastructure:4.13.0
com.atlassian.performance.tools:concurrency:1.1.0
com.atlassian.performance.tools:infrastructure:4.14.5-SNAPSHOT
com.atlassian.performance.tools:io:1.2.0
com.atlassian.performance.tools:jira-actions:3.3.0
com.atlassian.performance.tools:jira-software-actions:1.3.1
com.atlassian.performance.tools:jira-software-actions:1.3.2
com.atlassian.performance.tools:jvm-tasks:1.0.1
com.atlassian.performance.tools:ssh:2.3.0
com.atlassian.performance.tools:virtual-users:3.6.4
com.atlassian.performance.tools:virtual-users:3.10.0
com.atlassian.performance.tools:workspace:2.0.0
com.fasterxml.jackson.core:jackson-annotations:2.6.0
com.fasterxml.jackson.core:jackson-core:2.9.4
Expand Down
8 changes: 4 additions & 4 deletions gradle/dependency-locks/testRuntimeClasspath.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ com.amazonaws:aws-java-sdk-sts:1.11.424
com.amazonaws:aws-java-sdk-support:1.11.424
com.amazonaws:jmespath-java:1.11.424
com.atlassian.performance.tools:aws-resources:1.4.0
com.atlassian.performance.tools:concurrency:1.0.0
com.atlassian.performance.tools:infrastructure:4.13.0
com.atlassian.performance.tools:concurrency:1.1.0
com.atlassian.performance.tools:infrastructure:4.14.5-SNAPSHOT
com.atlassian.performance.tools:io:1.2.0
com.atlassian.performance.tools:jira-actions:3.3.0
com.atlassian.performance.tools:jira-software-actions:1.3.1
com.atlassian.performance.tools:jira-software-actions:1.3.2
com.atlassian.performance.tools:jvm-tasks:1.0.1
com.atlassian.performance.tools:ssh:2.3.0
com.atlassian.performance.tools:virtual-users:3.6.4
com.atlassian.performance.tools:virtual-users:3.10.0
com.atlassian.performance.tools:workspace:2.0.0
com.fasterxml.jackson.core:jackson-annotations:2.6.0
com.fasterxml.jackson.core:jackson-core:2.9.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.atlassian.performance.tools.awsinfrastructure.jira.home.SharedHomeFor
import com.atlassian.performance.tools.concurrency.api.submitWithLogContext
import com.atlassian.performance.tools.infrastructure.api.app.Apps
import com.atlassian.performance.tools.infrastructure.api.database.Database
import com.atlassian.performance.tools.infrastructure.api.database.PostgresDatabase
import com.atlassian.performance.tools.infrastructure.api.distribution.ProductDistribution
import com.atlassian.performance.tools.infrastructure.api.jira.JiraHomeSource
import com.atlassian.performance.tools.infrastructure.api.jira.JiraNodeConfig
Expand Down Expand Up @@ -210,6 +211,7 @@ class DataCenterFormula private constructor(
.mapIndexed { i: Int, instance ->
val ipAddress = InstanceAddressSelector.getReachableIpAddress(instance)
val ssh = Ssh(SshHost(ipAddress, "ubuntu", keyPath), connectivityPatience = 5)
val isPostgres = database.type() == "postgres"
DiagnosableNodeFormula(
delegate = DataCenterNodeFormula(
base = StandaloneNodeFormula(
Expand All @@ -220,7 +222,8 @@ class DataCenterFormula private constructor(
productDistribution = productDistribution,
ssh = ssh,
config = configs[i],
computer = computer
computer = computer,
isPostgres = isPostgres
),
nodeIndex = i,
sharedHome = sharedHome,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.atlassian.performance.tools.awsinfrastructure.api.jira

import com.amazonaws.services.cloudformation.model.Parameter
import com.amazonaws.services.ec2.model.Tag
import com.atlassian.performance.tools.aws.api.*
import com.atlassian.performance.tools.awsinfrastructure.ApplicationStorageWrapper
import com.atlassian.performance.tools.awsinfrastructure.TemplateBuilder
Expand All @@ -18,6 +17,7 @@ import com.atlassian.performance.tools.awsinfrastructure.jira.StandaloneNodeForm
import com.atlassian.performance.tools.concurrency.api.submitWithLogContext
import com.atlassian.performance.tools.infrastructure.api.app.Apps
import com.atlassian.performance.tools.infrastructure.api.database.Database
import com.atlassian.performance.tools.infrastructure.api.database.PostgresDatabase
import com.atlassian.performance.tools.infrastructure.api.distribution.ProductDistribution
import com.atlassian.performance.tools.infrastructure.api.jira.JiraHomeSource
import com.atlassian.performance.tools.infrastructure.api.jira.JiraNodeConfig
Expand Down Expand Up @@ -180,6 +180,7 @@ class StandaloneFormula private constructor(
CloseableThreadContext.push("Jira node").use {
key.get().file.facilitateSsh(jiraIp)
}
val isPostgres = database.type() == "postgres"
val nodeFormula = StandaloneNodeFormula(
config = config,
jiraHomeSource = jiraHomeSource,
Expand All @@ -188,7 +189,8 @@ class StandaloneFormula private constructor(
databaseIp = databaseIp,
productDistribution = productDistribution,
ssh = ssh,
computer = computer
computer = computer,
isPostgres = isPostgres
)

uploadPlugins.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.atlassian.performance.tools.infrastructure.api.jira.JiraHomeSource
import com.atlassian.performance.tools.infrastructure.api.jira.JiraNodeConfig
import com.atlassian.performance.tools.infrastructure.api.jira.SetenvSh
import com.atlassian.performance.tools.infrastructure.api.os.Ubuntu
import com.atlassian.performance.tools.io.api.readResourceText
import com.atlassian.performance.tools.jvmtasks.api.Backoff
import com.atlassian.performance.tools.jvmtasks.api.IdempotentAction
import com.atlassian.performance.tools.ssh.api.Ssh
Expand All @@ -29,7 +30,8 @@ internal class StandaloneNodeFormula(
private val productDistribution: ProductDistribution,
private val ssh: Ssh,
private val config: JiraNodeConfig,
private val computer: Computer
private val computer: Computer,
private val isPostgres: Boolean
) : NodeFormula {
private val logger: Logger = LogManager.getLogger(this::class.java)
private val jdk = config.jdk
Expand Down Expand Up @@ -114,6 +116,12 @@ internal class StandaloneNodeFormula(
connection: SshConnection,
dbconfigXml: String
) {
if (isPostgres) {
connection.execute("sudo rm -f $dbconfigXml")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It nicely explains the current tribal knowledge: the MySQL datasets have predefined dbconfig.xml 👍

var dbconfigContent = readResourceText("postgres/dbconfig.xml")
connection.execute("sudo printf '$dbconfigContent' > $dbconfigXml")
}

Sed().replace(
connection = connection,
expression = "(<url>.*(@(//)?|//))" + "([^:/]+)" + "(.*</url>)",
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/aws/2-nodes-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Resources:
SecurityGroupIds:
- Ref: SshSecurityGroup
- Ref: MySqlSecurityGroup
- Ref: PostgresSecurityGroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit shoehorned, but shouldn't have negative consequences AFAIK

KeyName:
Ref: KeyName
ImageId: !Ref Ami
Expand Down Expand Up @@ -183,6 +184,17 @@ Resources:
FromPort: 3306
ToPort: 3306
CidrIp: 0.0.0.0/0
PostgresSecurityGroup:
Type: AWS::EC2::SecurityGroup
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mini-disadvantage is that it will allocate two Security Groups even tho only one is used. It's an AWS resource, so it'll cost a little and might increase CloudFormation provisioning time. OTOH SecurityGroups are relatively cheap, so I guess we're fine here. Just FYI.

Properties:
VpcId:
Ref: Vpc
GroupDescription: Enables Postgres access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 5432
ToPort: 5432
CidrIp: 0.0.0.0/0
SubnetSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/aws/single-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Resources:
SecurityGroupIds:
- Ref: SshSecurityGroup
- Ref: MySqlSecurityGroup
- Ref: PostgresSecurityGroup
KeyName:
Ref: KeyName
ImageId: !Ref Ami
Expand Down Expand Up @@ -104,3 +105,14 @@ Resources:
FromPort: 3306
ToPort: 3306
CidrIp: 0.0.0.0/0
PostgresSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId:
Ref: Vpc
GroupDescription: Enables Postgres access
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 5432
ToPort: 5432
CidrIp: 0.0.0.0/0
25 changes: 25 additions & 0 deletions src/main/resources/postgres/dbconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type>postgres72</database-type>
<schema-name>public</schema-name>
<jdbc-datasource>
<url>jdbc:postgresql://localhost:3306/jira</url>
<driver-class>org.postgresql.Driver</driver-class>
<username>jira</username>
<password>jira</password>
<pool-min-size>20</pool-min-size>
<pool-max-size>20</pool-max-size>
<pool-max-wait>30000</pool-max-wait>
<validation-query>select 1</validation-query>
<min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
<time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
<pool-max-idle>20</pool-max-idle>
<pool-remove-abandoned>true</pool-remove-abandoned>
<pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
<pool-test-on-borrow>false</pool-test-on-borrow>
<pool-test-while-idle>true</pool-test-while-idle>
</jdbc-datasource>
</jira-database-config>