Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
A follow-up to restore backward-compatibility lost in the latest work…
Browse files Browse the repository at this point in the history
… to introduce the support for deployments to existing subnets
  • Loading branch information
mumoshu committed Jan 24, 2017
1 parent 68d88b9 commit af7fad7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 21 deletions.
6 changes: 6 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ func ClusterFromBytes(data []byte) (*Cluster, error) {
}
}

for index, s := range c.Subnets {
if s.SubnetLogicalName == "" {
s.SubnetLogicalName = fmt.Sprintf("Subnet%d", index)
}
}

return c, nil
}

Expand Down
32 changes: 19 additions & 13 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,14 @@ subnets:
`,
subnets: []*Subnet{
{
InstanceCIDR: "10.4.3.0/24",
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.4.3.0/24",
AvailabilityZone: "ap-northeast-1a",
SubnetLogicalName: "Subnet0",
},
{
InstanceCIDR: "10.4.4.0/24",
AvailabilityZone: "ap-northeast-1c",
InstanceCIDR: "10.4.4.0/24",
AvailabilityZone: "ap-northeast-1c",
SubnetLogicalName: "Subnet1",
},
},
},
Expand All @@ -349,8 +351,9 @@ instanceCIDR: 10.4.3.0/24
`,
subnets: []*Subnet{
{
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.4.3.0/24",
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.4.3.0/24",
SubnetLogicalName: "Subnet0",
},
},
},
Expand All @@ -365,8 +368,9 @@ subnets: []
`,
subnets: []*Subnet{
{
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.4.3.0/24",
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.4.3.0/24",
SubnetLogicalName: "Subnet0",
},
},
},
Expand All @@ -378,8 +382,9 @@ subnets: []
`,
subnets: []*Subnet{
{
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.0.0.0/24",
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.0.0.0/24",
SubnetLogicalName: "Subnet0",
},
},
},
Expand All @@ -390,8 +395,9 @@ availabilityZone: "ap-northeast-1a"
`,
subnets: []*Subnet{
{
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.0.0.0/24",
AvailabilityZone: "ap-northeast-1a",
InstanceCIDR: "10.0.0.0/24",
SubnetLogicalName: "Subnet0",
},
},
},
Expand Down Expand Up @@ -452,7 +458,7 @@ subnets:
}
if !reflect.DeepEqual(c.Subnets, conf.subnets) {
t.Errorf(
"parsed subnets %s does not expected subnets %s in config: %s",
"parsed subnets %s does not match expected subnets %s in config: %s",
c.Subnets,
conf.subnets,
confBody,
Expand Down
34 changes: 26 additions & 8 deletions e2e/run
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,20 @@ main_stack_name() {
echo $KUBE_AWS_CLUSTER_NAME
}

main_status() {
aws cloudformation describe-stacks --stack-name $(main_stack_name) --output json | jq -rc '.Stacks[0].StackStatus'
}

main_all() {
status=$(aws cloudformation describe-stacks --stack-name $(main_stack_name) --output json | jq -rc '.Stacks[0].StackStatus')
if [ "$status" = "" ]; then
prepare
configure
up
if [ ! -e "${WORK_DIR}/cluster.yaml" ]; then
prepare
configure
fi
if [ "$(main_status)" = "" ]; then
up
fi
if [ "$KUBE_AWS_UPDATE" != "" ]; then
update
fi
Expand Down Expand Up @@ -174,9 +182,19 @@ up() {
set -vx
}

destroy() {
aws cloudformation delete-stack --stack-name ${KUBE_AWS_CLUSTER_NAME}
aws cloudformation wait stack-delete-complete --stack-name ${KUBE_AWS_CLUSTER_NAME}
main_destroy() {
status=$(main_status)

if [ "$status" != "" ]; then
if [ "$status" != "DELETE_IN_PROGRESS" ]; then
aws cloudformation delete-stack --stack-name $(main_stack_name)
aws cloudformation wait stack-delete-complete --stack-name $(main_stack_name)
else
aws cloudformation wait stack-delete-complete --stack-name $(main_stack_name)
fi
else
echo $(main_stack_name) does not exist. skipping.
fi
}

update() {
Expand Down Expand Up @@ -355,7 +373,7 @@ nodepool_update() {
nodepool_destroy() {
cd ${WORK_DIR}

status=$(aws cloudformation describe-stacks --stack-name $(nodepool_stack_name) --output json | jq -rc '.Stacks[0].StackStatus')
status=$(nodepool_status)

if [ "$status" != "" ]; then
if [ "$status" != "DELETE_IN_PROGRESS" ]; then
Expand Down Expand Up @@ -460,7 +478,7 @@ all() {

all_destroy() {
nodepool_destroy
destroy
main_destroy
if [ "${KUBE_AWS_DEPLOY_TO_EXISTING_VPC}" != "" ]; then
testinfra_destroy
fi
Expand Down
6 changes: 6 additions & 0 deletions nodepool/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ func ClusterFromBytes(data []byte, main *cfg.Config) (*ProvidedConfig, error) {
}
}

for index, s := range c.Subnets {
if s.SubnetLogicalName == "" {
s.SubnetLogicalName = fmt.Sprintf("Subnet%d", index)
}
}

c.EtcdInstances = main.EtcdInstances

return c, nil
Expand Down

0 comments on commit af7fad7

Please sign in to comment.