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

Improvements to VPCs and RDS #814

Draft
wants to merge 60 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
002c986
feat: allow disabling the proxy server and customize client server ur…
fmartingr Sep 3, 2024
d2467c9
Allow bypassing ES setup through DISABLE_ES_SETUP env var
streamer45 Sep 4, 2024
1ded5bc
[MM-60371] Update Pyroscope to v1 (#793)
streamer45 Sep 4, 2024
dfd403f
fix: use proxy_instance_count for the security group (#795)
fmartingr Sep 9, 2024
f3bf239
MM-56605: Create results file and print to file (#729)
DHaussermann Sep 10, 2024
1ddbd16
Restore the saml-idp.crt file in assets (#792)
agnivade Sep 13, 2024
42e42f5
fix: updateuserauth
fmartingr Sep 18, 2024
155c12e
chore: changed openid/saml button labels (#803)
fmartingr Sep 19, 2024
0497039
feat(ltkeycloak): added flag to force migrate all users (#802)
fmartingr Sep 19, 2024
e4a29f0
Setup VPC parameter for all resources and allow custom database engin…
fmartingr Sep 26, 2024
86222d4
added keycloak support for the ssh commands
fmartingr Sep 27, 2024
7535b0a
BRANCH SPECIFIC: avoid s3 creation, use specific policy in app servers
fmartingr Oct 7, 2024
7c21c7f
BRANCH: disable es log stream
fmartingr Oct 7, 2024
2c6c729
BRANCH: Use private_ip for ec2 connection
fmartingr Oct 7, 2024
dc68578
BRANCH: keycloak private ip
fmartingr Oct 7, 2024
59020dc
BRANCH: Disable cloudwatchpolicy license check
fmartingr Oct 7, 2024
e051958
BRANCH: Use privateIP for connections
fmartingr Oct 7, 2024
d41273e
BRANCH: publicDNS -> privateDNS
fmartingr Oct 7, 2024
93d5166
BRANCH: Quote password
fmartingr Oct 7, 2024
d46c448
typo
fmartingr Oct 7, 2024
737fc20
BRANCH: use double quotes for password
fmartingr Oct 7, 2024
f2c6466
BRANCH: Escape singlequotes
fmartingr Oct 7, 2024
ef654a5
BRANCH: trigger keycloak destroy
fmartingr Oct 7, 2024
e6da243
BRANCH: Use region from deployer.json in AWS SDK call
fmartingr Oct 8, 2024
baef7cc
BRANCH: Subnet fix and disable public ips
fmartingr Oct 8, 2024
ef0492a
BRANCH: All PublicIP to PrivateIP
fmartingr Oct 8, 2024
b8ecc1a
BRANCH: All PublicDNS to PrivateDNS
fmartingr Oct 8, 2024
b11850f
BRANCH: Disable init data if providing external database
fmartingr Oct 8, 2024
862c4e3
[MM-61113] Allow multiple customizable subnets (#833)
fmartingr Oct 22, 2024
e85cc89
fix duplicate attribute from merge
fmartingr Oct 22, 2024
62f7793
fix incorrect waitgroups from merge
fmartingr Oct 22, 2024
032b359
merge fixes
fmartingr Oct 22, 2024
b3e69d1
use AppAttachIAMProfile
fmartingr Oct 22, 2024
b733c03
avoid newlines in logs
fmartingr Oct 22, 2024
24e7a30
Format cluster.tf
agarciamontoro Oct 23, 2024
8c4e3e4
Fix typo
agarciamontoro Oct 23, 2024
b7a4ed2
Remove deleted ElasticSearchSettings.VpcID
agarciamontoro Oct 23, 2024
de13532
String() needs to be in the plain type method set
agarciamontoro Oct 23, 2024
0b92ca1
Use the correct type in reflect.MakeSlice
agarciamontoro Oct 23, 2024
eb77bbf
Default ClusterSubnetIDs' slices to non-nil slices
agarciamontoro Oct 23, 2024
2ff58ad
Test ClusterSubnetIDs
agarciamontoro Oct 23, 2024
cfb64cf
Fix ClusterSubnetIDs.IsAnySet
agarciamontoro Oct 23, 2024
9c00922
Check length of subnet lists instead of empty str
agarciamontoro Oct 23, 2024
7214588
Use proper subnets in DB cluster and Redis
agarciamontoro Oct 23, 2024
d93f792
Get default VPC and use it to define subnets
agarciamontoro Oct 23, 2024
5aa7518
Make the AZ filter on subnets conditional
agarciamontoro Oct 23, 2024
8b725dd
Remove subnet_id if not specified
agarciamontoro Oct 23, 2024
d9e2dee
make assets
agarciamontoro Oct 23, 2024
45da4f3
No, linter, I *want* to test fmt.Sprintf("%s")
agarciamontoro Oct 23, 2024
c72700c
Apply suggestions from code review
agarciamontoro Oct 24, 2024
e1dba81
make assets
agarciamontoro Oct 24, 2024
c278150
Remove aws_subnets.selected data source
agarciamontoro Oct 24, 2024
76b5d00
Format elasticsearch.tf
agarciamontoro Oct 24, 2024
15953aa
make assets
agarciamontoro Oct 24, 2024
2496b65
create dist/latest.tar.gz
Oct 24, 2024
0870690
Merge remote-tracking branch 'origin/subnets.fixes' into elasticsearc…
fmartingr Oct 24, 2024
b49ab37
allow elasticsearch
fmartingr Oct 24, 2024
51d1afc
Remove aws_vpc.default and make assets
agarciamontoro Oct 24, 2024
bad542c
Merge remote-tracking branch 'origin/subnets.fixes' into elasticsearc…
fmartingr Oct 24, 2024
10e97dc
manually create otelcol contrib dir
fmartingr Oct 25, 2024
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ endif
$(eval PACKAGE_NAME=mattermost-load-test-ng-$(DIST_VER)-$(PLATFORM))
cp -r $(PLATFORM_DIST_PATH) $(DIST_PATH)/$(PACKAGE_NAME)
tar -C $(DIST_PATH) -czf $(DIST_PATH)/$(PACKAGE_NAME).tar.gz $(PACKAGE_NAME)
rm -rf $(DIST_ROOT)/latest.tar.gz
cp $(DIST_PATH)/$(PACKAGE_NAME).tar.gz $(DIST_ROOT)/latest.tar.gz
rm -rf $(DIST_PATH)/$(PACKAGE_NAME)

verify-gomod: ## Run go mod verify.
Expand Down
6 changes: 3 additions & 3 deletions cmd/ltctl/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func createClients(output *terraform.Output) (map[string]*ssh.Client, error) {
clients := make(map[string]*ssh.Client)
if output.HasProxy() {
for i, inst := range output.Proxies {
sshc, err := extAgent.NewClient(inst.PublicIP)
sshc, err := extAgent.NewClient(inst.PrivateIP)
if err != nil {
return nil, fmt.Errorf("error in getting ssh connection %w", err)
}
Expand All @@ -131,15 +131,15 @@ func createClients(output *terraform.Output) (map[string]*ssh.Client, error) {
}

for i, instance := range output.Instances {
sshc, err := extAgent.NewClient(instance.PublicIP)
sshc, err := extAgent.NewClient(instance.PrivateIP)
if err != nil {
return nil, fmt.Errorf("error in getting ssh connection %w", err)
}
clients[fmt.Sprintf("app%d", i)] = sshc
}

for i, agent := range output.Agents {
sshc, err := extAgent.NewClient(agent.PublicIP)
sshc, err := extAgent.NewClient(agent.PrivateIP)
if err != nil {
return nil, fmt.Errorf("error in getting ssh connection %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ltctl/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func RunLoadTestStatusCmdF(cmd *cobra.Command, args []string) error {
return err
}

prometheusURL := fmt.Sprintf("http://%s:9090", tfOutput.MetricsServer.PublicIP)
prometheusURL := fmt.Sprintf("http://%s:9090", tfOutput.MetricsServer.PrivateIP)
helper, err := prometheus.NewHelper(prometheusURL)
if err != nil {
return fmt.Errorf("failed to create prometheus.Helper: %w", err)
Expand Down
5 changes: 4 additions & 1 deletion cmd/ltctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func RunCreateCmdF(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to create terraform engine: %w", err)
}

initData := config.DBDumpURI == ""
initData := config.DBDumpURI == "" || config.ExternalDBSettings.DataSource != ""
err = t.Create(initData)
if err != nil {
return fmt.Errorf("failed to create terraform env: %w", err)
Expand Down Expand Up @@ -157,6 +157,9 @@ func RunSSHListCmdF(cmd *cobra.Command, args []string) error {
if output.HasMetrics() {
fmt.Printf(" - %s\n", output.MetricsServer.Tags.Name)
}
if output.HasKeycloak() {
fmt.Printf(" - %s\n", output.KeycloakServer.Tags.Name)
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/ltctl/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func RunGenerateReportCmdF(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("could not parse output: %w", err)
}
promURL = "http://" + output.MetricsServer.PublicIP + ":9090"
promURL = "http://" + output.MetricsServer.PrivateIP + ":9090"
}

helper, err := prometheus.NewHelper(promURL)
Expand Down
6 changes: 4 additions & 2 deletions cmd/ltctl/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ func RunResetCmdF(cmd *cobra.Command, args []string) error {

appClients := make([]*ssh.Client, len(output.Instances))
for i, instance := range output.Instances {
client, err := extAgent.NewClient(instance.PublicIP)
// BRANCH: Using private ip
client, err := extAgent.NewClient(instance.PrivateIP)
if err != nil {
return fmt.Errorf("error in getting ssh connection %w", err)
}
defer client.Close()
appClients[i] = client
}

agentClient, err := extAgent.NewClient(output.Agents[0].PublicIP)
// BRANCH: Private IP
agentClient, err := extAgent.NewClient(output.Agents[0].PrivateIP)
if err != nil {
return fmt.Errorf("error in getting ssh connection %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/ltkeycloak/from_mattermost.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ func RunSyncFromMattermostCommandF(cmd *cobra.Command, _ []string) error {
if err != nil {
return fmt.Errorf("failed to get terraform output: %w", err)
}
if terraformOutput.KeycloakServer.PublicDNS == "" {
if terraformOutput.KeycloakServer.PrivateDNS == "" {
return fmt.Errorf("keycloak database cluster not found in terraform output")
}
keycloakHost = terraformOutput.KeycloakServer.PublicDNS
keycloakHost = terraformOutput.KeycloakServer.PrivateDNS
}

keycloakRealm, err := cmd.Flags().GetString("keycloak-realm")
Expand Down
2 changes: 1 addition & 1 deletion comparison/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func provisionFiles(t *terraform.Terraform, dpConfig *deploymentConfig, baseBuil
}
clients := make([]*ssh.Client, len(output.Instances))
for i, instance := range output.Instances {
client, err := extAgent.NewClient(instance.PublicIP)
client, err := extAgent.NewClient(instance.PrivateIP)
if err != nil {
return fmt.Errorf("error in getting ssh connection %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions comparison/loadtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ func initLoadTest(t *terraform.Terraform, buildCfg BuildConfig, dumpFilename str
return err
}

agentClient, err := extAgent.NewClient(tfOutput.Agents[0].PublicIP)
agentClient, err := extAgent.NewClient(tfOutput.Agents[0].PrivateIP)
if err != nil {
return fmt.Errorf("error in getting ssh connection %w", err)
}
defer agentClient.Close()

appClients := make([]*ssh.Client, len(tfOutput.Instances))
for i, instance := range tfOutput.Instances {
client, err := extAgent.NewClient(instance.PublicIP)
client, err := extAgent.NewClient(instance.PrivateIP)
if err != nil {
return fmt.Errorf("error in getting ssh connection %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions comparison/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (c *Comparison) getResults(resultsCh <-chan Result) []Result {
return
}

promURL := "http://" + output.MetricsServer.PublicIP + ":9090"
promURL := "http://" + output.MetricsServer.PrivateIP + ":9090"
helper, err := prometheus.NewHelper(promURL)
if err != nil {
mlog.Error("Failed to create prometheus.Helper", mlog.String("deployment ID", res.deploymentID), mlog.Err(err))
Expand Down Expand Up @@ -158,7 +158,7 @@ func (c *Comparison) getResults(resultsCh <-chan Result) []Result {
mlog.Error("Failed to upload dashboard", mlog.String("deployment ID", res.deploymentID), mlog.Err(err))
return
}
res.DashboardURL = fmt.Sprintf("http://%s:3000%s", output.MetricsServer.PublicIP, url)
res.DashboardURL = fmt.Sprintf("http://%s:3000%s", output.MetricsServer.PrivateIP, url)
}

resCh <- res
Expand Down
4 changes: 2 additions & 2 deletions config/deployer.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"ElasticSearchSettings": {
"InstanceCount": 0,
"InstanceType": "r6g.large.search",
"VpcID": "",
"Version": "Elasticsearch_7.10",
"CreateRole": false,
"SnapshotRepository": "",
Expand Down Expand Up @@ -62,7 +61,8 @@
"Password": "mostest80098bigpass_",
"EnablePerformanceInsights": true,
"DBParameters": [],
"ClusterIdentifier": ""
"ClusterIdentifier": "",
"EngineVersion": ""
},
"ExternalDBSettings": {
"DriverName": "cockroach",
Expand Down
1 change: 0 additions & 1 deletion config/deployer.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ CreateRole = false
InstanceCount = 0
InstanceType = 'r6g.large.search'
Version = 'Elasticsearch_7.10'
VpcID = ''
ZoneAwarenessEnabled = false
ZoneAwarenessAZCount = 2

Expand Down
6 changes: 3 additions & 3 deletions defaults/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func structDefaults(value interface{}) error {
return fmt.Errorf("invalid size definition: %q", tag)
}
dv := field.Interface()
newSlice, err := createSlice(dv, size)
newSlice, err := createSlice(field.Type(), dv, size)
if err != nil {
return err
}
Expand Down Expand Up @@ -129,7 +129,7 @@ func setValue(t reflect.Type, data string) (reflect.Value, error) {
}

// this function creates a slice for the given slice type
func createSlice(defaultValue interface{}, size int) (reflect.Value, error) {
func createSlice(fieldType reflect.Type, defaultValue interface{}, size int) (reflect.Value, error) {
t := reflect.ValueOf(defaultValue).Type().Elem()
if t.Kind() == reflect.Struct {
values := reflect.Zero(reflect.SliceOf(t))
Expand All @@ -143,7 +143,7 @@ func createSlice(defaultValue interface{}, size int) (reflect.Value, error) {
}
return values, nil
}
return reflect.MakeSlice(t, size, size), nil
return reflect.MakeSlice(fieldType, size, size), nil
}

// this function creates a map for the given map type
Expand Down
21 changes: 21 additions & 0 deletions defaults/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,25 @@ func TestSet(t *testing.T) {
assert.NotNil(t, cfg.Chan)
assert.Equal(t, 3, cap(cfg.Chan))
})

t.Run("should be able to set nil slices", func(t *testing.T) {
cfg := struct {
Strings []string
}{}

err := Set(&cfg)
require.NoError(t, err)
assert.Nil(t, cfg.Strings)
})

t.Run("should be able to set empty slices", func(t *testing.T) {
cfg := struct {
Strings []string `default_size:"0"`
}{}

err := Set(&cfg)
require.NoError(t, err)
assert.NotNil(t, cfg.Strings)
assert.Len(t, cfg.Strings, 0)
})
}
49 changes: 34 additions & 15 deletions deployment/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type Config struct {
ClusterName string `default:"loadtest" validate:"alpha"`
// ClusterVpcID is the id of the VPC associated to the resources.
ClusterVpcID string
// ClusterSubnetIDs is the ids of the subnets associated to each resource type.
// ClusterSubnetIDs is the ids of the subnets associated to each resource type.
ClusterSubnetIDs ClusterSubnetIDs
// Number of application instances.
AppInstanceCount int `default:"1" validate:"range:[0,)"`
Expand Down Expand Up @@ -144,23 +144,40 @@ func (t TerraformMap) String() string {

// ClusterSubnetIDs contains the subnet ids for the different types of instances.
type ClusterSubnetIDs struct {
App []string `json:"app"`
Job []string `json:"job"`
Proxy []string `json:"proxy"`
Agent []string `json:"agent"`
ElasticSearch []string `json:"elasticsearch"`
Metrics []string `json:"metrics"`
Keycloak []string `json:"keycloak"`
Database []string `json:"database"`
Redis []string `json:"redis"`
App []string `default_size:"0" json:"app"`
Job []string `default_size:"0" json:"job"`
Proxy []string `default_size:"0" json:"proxy"`
Agent []string `default_size:"0" json:"agent"`
ElasticSearch []string `default_size:"0" json:"elasticsearch"`
Metrics []string `default_size:"0" json:"metrics"`
Keycloak []string `default_size:"0" json:"keycloak"`
Database []string `default_size:"0" json:"database"`
Redis []string `default_size:"0" json:"redis"`
}

// IsAnySet returns true if any of the subnet ids are set.
func (c *ClusterSubnetIDs) IsAnySet() bool {
return !reflect.DeepEqual(c, &ClusterSubnetIDs{})
value := reflect.ValueOf(*c)

for i := 0; i < value.NumField(); i++ {
field := value.Field(i)
// Skip fields that are not slices
if field.Kind() != reflect.Slice {
continue
}

if field.IsNil() || value.Field(i).Len() == 0 {
continue
}

return true
}

return false

}

func (c *ClusterSubnetIDs) String() string {
func (c ClusterSubnetIDs) String() string {
b, err := json.Marshal(c)
if err != nil {
mlog.Error("Failed to marshal ClusterSubnetIDs", mlog.Err(err))
Expand Down Expand Up @@ -222,6 +239,8 @@ type TerraformDBSettings struct {
// If ClusterIdentifier is not empty, DBName should be set to the name of the database in such cluster.
// If ClusterIdentifier is empty, the database created will use DBName as its name.
DBName string `default:""`
// EngineVersion specifies the version of the database engine.
EngineVersion string `default:""`
}

// ExternalDBSettings contains the necessary data
Expand Down Expand Up @@ -437,9 +456,9 @@ func (c *Config) validateElasticSearchConfig() error {

}

if !strings.HasPrefix(c.ElasticSearchSettings.Version, "OpenSearch") {
return fmt.Errorf("Incorrect engine version: %s. Must start with %q", c.ElasticSearchSettings.Version, "OpenSearch")
}
// if !strings.HasPrefix(c.ElasticSearchSettings.Version, "OpenSearch") {
// return fmt.Errorf("Incorrect engine version: %s. Must start with %q", c.ElasticSearchSettings.Version, "OpenSearch")
// }

if c.ElasticSearchSettings.SnapshotRepository == "" {
return fmt.Errorf("Empty SnapshotRepository. Must supply a value")
Expand Down
Loading
Loading