Ensure GCE disk name does not start with a number

As this could not have worked before, we don't have to worry about
compatability with existing users.
This commit is contained in:
Justin Santa Barbara 2018-01-22 00:23:42 -05:00
parent 752c7bd96d
commit ec4a916f62
3 changed files with 22 additions and 18 deletions

View File

@ -194,7 +194,11 @@ func (b *MasterVolumeBuilder) addGCEVolume(c *fi.ModelBuilderContext, name strin
tags[gce.GceLabelNameRolePrefix+"master"] = "master" // Can't start with a number
tags[gce.GceLabelNameEtcdClusterPrefix+etcd.Name] = gce.EncodeGCELabel(clusterSpec)
// GCE disk names must match the following regular expression: '[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?'
name = strings.Replace(name, ".", "-", -1)
if strings.IndexByte("0123456789-", name[0]) != -1 {
name = "d" + name
}
t := &gcetasks.Disk{
Name: s(name),

View File

@ -14,19 +14,19 @@ spec:
etcdClusters:
- etcdMembers:
- instanceGroup: master-us-test1-a
name: a
name: "1"
- instanceGroup: master-us-test1-b
name: b
name: "2"
- instanceGroup: master-us-test1-c
name: c
name: "3"
name: main
- etcdMembers:
- instanceGroup: master-us-test1-a
name: a
name: "1"
- instanceGroup: master-us-test1-b
name: b
name: "2"
- instanceGroup: master-us-test1-c
name: c
name: "3"
name: events
iam:
legacy: false

View File

@ -15,43 +15,43 @@ provider "google" {
region = "us-test1"
}
resource "google_compute_disk" "a-etcd-events-ha-gce-example-com" {
name = "a-etcd-events-ha-gce-example-com"
resource "google_compute_disk" "d1-etcd-events-ha-gce-example-com" {
name = "d1-etcd-events-ha-gce-example-com"
type = "pd-ssd"
size = 20
zone = "us-test1-a"
}
resource "google_compute_disk" "a-etcd-main-ha-gce-example-com" {
name = "a-etcd-main-ha-gce-example-com"
resource "google_compute_disk" "d1-etcd-main-ha-gce-example-com" {
name = "d1-etcd-main-ha-gce-example-com"
type = "pd-ssd"
size = 20
zone = "us-test1-a"
}
resource "google_compute_disk" "b-etcd-events-ha-gce-example-com" {
name = "b-etcd-events-ha-gce-example-com"
resource "google_compute_disk" "d2-etcd-events-ha-gce-example-com" {
name = "d2-etcd-events-ha-gce-example-com"
type = "pd-ssd"
size = 20
zone = "us-test1-b"
}
resource "google_compute_disk" "b-etcd-main-ha-gce-example-com" {
name = "b-etcd-main-ha-gce-example-com"
resource "google_compute_disk" "d2-etcd-main-ha-gce-example-com" {
name = "d2-etcd-main-ha-gce-example-com"
type = "pd-ssd"
size = 20
zone = "us-test1-b"
}
resource "google_compute_disk" "c-etcd-events-ha-gce-example-com" {
name = "c-etcd-events-ha-gce-example-com"
resource "google_compute_disk" "d3-etcd-events-ha-gce-example-com" {
name = "d3-etcd-events-ha-gce-example-com"
type = "pd-ssd"
size = 20
zone = "us-test1-c"
}
resource "google_compute_disk" "c-etcd-main-ha-gce-example-com" {
name = "c-etcd-main-ha-gce-example-com"
resource "google_compute_disk" "d3-etcd-main-ha-gce-example-com" {
name = "d3-etcd-main-ha-gce-example-com"
type = "pd-ssd"
size = 20
zone = "us-test1-c"