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

roachprod: enable dns_hostnames in VPC and re-enable terraform config #36488

Merged
Merged
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
4 changes: 3 additions & 1 deletion pkg/cmd/roachprod/vm/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,19 @@ const (

var defaultConfig = func() (cfg *awsConfig) {
cfg = new(awsConfig)
if err := json.Unmarshal(MustAsset("old.json"), cfg); err != nil {
if err := json.Unmarshal(MustAsset("config.json"), cfg); err != nil {
panic(errors.Wrap(err, "failed to embedded configuration"))
}
return cfg
}()

var defaultZones = []string{
"us-east-2a",
"us-east-2b",
"us-east-2c",
"us-west-2a",
"us-west-2b",
"us-west-2c",
"eu-west-2a",
"eu-west-2b",
"eu-west-2c",
Expand Down
9 changes: 8 additions & 1 deletion pkg/cmd/roachprod/vm/aws/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"

"github.com/pkg/errors"
)
Expand Down Expand Up @@ -71,7 +72,13 @@ func (p *Provider) sshKeyImport(keyName string, region string) error {
"--key-name", keyName,
"--public-key-material", string(keyBytes),
}
return p.runJSONCommand(args, &data)
err = p.runJSONCommand(args, &data)
// If two roachprod instances run at the same time with the same key, they may
// race to upload the key pair.
if strings.Contains(err.Error(), "InvalidKeyPair.Duplicate") {
return nil
}
return err
}

// sshKeyName computes the name of the ec2 ssh key that we'll store the local user's public key in
Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/roachprod/vm/aws/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package aws

import (
"bytes"
"encoding/json"
"io/ioutil"
"log"
Expand Down Expand Up @@ -144,15 +145,16 @@ func (p *Provider) runCommand(args []string) ([]byte, error) {
if p.opts.Profile != "" {
args = append(args[:len(args):len(args)], "--profile", p.opts.Profile)
}

var stderrBuf bytes.Buffer
cmd := exec.Command("aws", args...)

cmd.Stderr = &stderrBuf
output, err := cmd.Output()
if err != nil {
if exitErr, ok := err.(*exec.ExitError); ok {
log.Println(string(exitErr.Stderr))
}
return nil, errors.Wrapf(err, "failed to run: aws %s", strings.Join(args, " "))
return nil, errors.Wrapf(err, "failed to run: aws %s: stderr: %v",
strings.Join(args, " "), stderrBuf.String())
}
return output, nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/roachprod/vm/aws/terraform/aws-region/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ output "vpc_info" {
}
}

output "extended_vpc_info" {
output "region_info" {
value = {
"region" = "${var.region}"
"security_group" = "${aws_security_group.region_security_group.id}"
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/roachprod/vm/aws/terraform/aws-region/network.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ data "aws_availability_zone" "zone_detail" {

# One VPC per region, with CIDR 10.<region ID>.0.0/8.
resource "aws_vpc" "region_vpc" {
cidr_block = "${cidrsubnet("10.0.0.0/8", 8, local.region_number[var.region])}"

cidr_block = "${cidrsubnet("10.0.0.0/8", 8, local.region_number[var.region])}"
enable_dns_hostnames = true
tags {
Name = "${var.label}-vpc-${var.region}"
Name = "${var.label}-vpc-${var.region}"
}
}

Expand Down