Skip to content

Commit

Permalink
Merge pull request #714 from ystia/upstream/fix_consul_path_googoe_su…
Browse files Browse the repository at this point in the history
…bnet

Fix consul path when creating a google subnet
  • Loading branch information
loicalbertin committed Feb 1, 2021
2 parents 5e1c9fb + ddba352 commit 8c37330
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: go
go:
- stable

dist: trusty
dist: xenial
sudo: required

services:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

### BUG FIXES

* Error when storing runtime attributes of google subnet ([GH-713](https://github.com/ystia/yorc/issues/713))
* Bootstrap fails on hosts where a version of ansible < 2.10.0 is installed ([GH-695](https://github.com/ystia/yorc/issues/695))
* Panic due to nil pointer dereference may happen when retrieving a workflow ([GH-691](https://github.com/ystia/yorc/issues/691))
* Empty directories not removed after ansible executions can lead to inodes exhaustion ([GH-683](https://github.com/ystia/yorc/issues/683))
Expand Down
10 changes: 4 additions & 6 deletions pkg/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ystia/alpine-consul:1.0.4_consul-1.2.3
FROM ystia/alpine-consul:1.1.0_consul-1.2.3
ARG TERRAFORM_VERSION
ARG ANSIBLE_VERSION
ARG TF_CONSUL_PLUGIN_VERSION
Expand All @@ -17,13 +17,11 @@ ENV YORC_TERRAFORM_PLUGINS_DIR /var/terraform/plugins
ADD rootfs /

# Python is required here as it should not be removed automatically when uninstalling python-dev
# We do not install the whole docker package we download the package and extract only the client
RUN apk add --update make openssh-client python3 python3-dev gcc musl-dev libffi-dev openssl-dev && \
# We do not install the whole docker package but just docker-cli
RUN apk add --update make openssh-client python3 python3-dev gcc musl-dev libffi-dev openssl-dev docker-cli && \
python3 -m ensurepip && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [ ! -e /usr/bin/python ]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
mkdir /tmp/docker && apk fetch -o /tmp/docker docker && \
tar xzf /tmp/docker/*.apk -C / usr/bin/docker && \
pip install ansible==${ANSIBLE_VERSION} docker-py netaddr jmespath && \
cd /tmp && \
curl -O https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \
Expand All @@ -50,7 +48,7 @@ RUN apk add --update make openssh-client python3 python3-dev gcc musl-dev libffi
unzip terraform-provider-openstack_${TF_OPENSTACK_PLUGIN_VERSION}_linux_amd64.zip && \
chmod 775 ${YORC_TERRAFORM_PLUGINS_DIR}/* && \
echo "Cleaning up" && \
apk del make py-pip python-dev gcc musl-dev libffi-dev openssl-dev && \
apk del make py-pip python3-dev gcc musl-dev libffi-dev openssl-dev && \
rm -rf /var/cache/apk/* && \
rm -fr /tmp/*

Expand Down
14 changes: 7 additions & 7 deletions prov/terraform/google/private_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (g *googleGenerator) generatePrivateNetwork(ctx context.Context, cfg config
if nodeType != "yorc.nodes.google.PrivateNetwork" {
return errors.Errorf("Unsupported node type for %q: %s", nodeName, nodeType)
}
nodeKey := path.Join(consulutil.DeploymentKVPrefix, deploymentID, "topology", "nodes", nodeName)
nodeInstanceKey := path.Join(consulutil.DeploymentKVPrefix, deploymentID, "topology", "instances", nodeName, "0")
privateNetwork := &PrivateNetwork{}

stringParams := []struct {
Expand All @@ -65,7 +65,7 @@ func (g *googleGenerator) generatePrivateNetwork(ctx context.Context, cfg config
// Provide output for network_name
networkKey := nodeName + "-network"
commons.AddOutput(infrastructure, networkKey, &commons.Output{Value: privateNetwork.Name})
outputs[path.Join(nodeKey, "/attributes/network_name")] = networkKey
outputs[path.Join(nodeInstanceKey, "/attributes/network_name")] = networkKey
return nil
}

Expand Down Expand Up @@ -102,14 +102,14 @@ func (g *googleGenerator) generatePrivateNetwork(ctx context.Context, cfg config
// Provide output for network_name
networkKey := nodeName + "-network"
commons.AddOutput(infrastructure, networkKey, &commons.Output{Value: fmt.Sprintf("${google_compute_network.%s.name}", privateNetwork.Name)})
outputs[path.Join(nodeKey, "/attributes/network_name")] = networkKey
outputs[path.Join(nodeInstanceKey, "/attributes/network_name")] = networkKey
return nil
}

func (g *googleGenerator) generateSubNetwork(ctx context.Context, cfg config.Configuration, deploymentID, nodeName string, infrastructure *commons.Infrastructure, outputs map[string]string) error {

subnet := &SubNetwork{}
nodeKey := path.Join(consulutil.DeploymentKVPrefix, deploymentID, "topology", "nodes", nodeName)
nodeInstanceKey := path.Join(consulutil.DeploymentKVPrefix, deploymentID, "topology", "instances", nodeName, "0")

var err error
strParams := []struct {
Expand Down Expand Up @@ -195,15 +195,15 @@ func (g *googleGenerator) generateSubNetwork(ctx context.Context, cfg config.Con
// Provide outputs
gatewayKey := nodeName + "-gateway"
commons.AddOutput(infrastructure, gatewayKey, &commons.Output{Value: fmt.Sprintf("${google_compute_subnetwork.%s.gateway_address}", subnet.Name)})
outputs[path.Join(nodeKey, "/attributes/gateway_ip")] = gatewayKey
outputs[path.Join(nodeInstanceKey, "/attributes/gateway_ip")] = gatewayKey

networkKey := nodeName + "-network"
commons.AddOutput(infrastructure, networkKey, &commons.Output{Value: subnet.Network})
outputs[path.Join(nodeKey, "/attributes/network_name")] = networkKey
outputs[path.Join(nodeInstanceKey, "/attributes/network_name")] = networkKey

subnetKey := nodeName + "-subnet"
commons.AddOutput(infrastructure, subnetKey, &commons.Output{Value: subnet.Name})
outputs[path.Join(nodeKey, "/attributes/subnetwork_name")] = subnetKey
outputs[path.Join(nodeInstanceKey, "/attributes/subnetwork_name")] = subnetKey

// Add internal firewall rules for subnet
sourceRanges := append(secondarySourceRange, subnet.IPCIDRRange)
Expand Down

0 comments on commit 8c37330

Please sign in to comment.