Skip to content

Commit

Permalink
Merge pull request #582 from tmobile/node10
Browse files Browse the repository at this point in the history
Add Support for Node10
  • Loading branch information
devsatishm authored Dec 9, 2019
2 parents ca6a5a2 + 8d43b98 commit ee6565d
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 10 deletions.
2 changes: 1 addition & 1 deletion features/extensions/apigee/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def install(region, stackprefix, jazz_apiendpoint, jazz_userpass, jenkins_url,
runTerraform(region, stackprefix, True)
# TODO remove this entire module when the terraform bug is fixed
click.secho('\nLinking new role to existing gateway function', fg='blue')
linkNewRoleToExistingFunctionWithCLI(stackprefix + "-" + gatewayFunctionName)
linkNewRoleToExistingFunctionWithCLI(stackprefix + "_" + gatewayFunctionName)
jazz_userpass_list = ''.join(list(jazz_userpass)).split()
jazz_username, jazz_password = jazz_userpass_list[0], jazz_userpass_list[1]
jenkins_userpass_list = ''.join(list(jenkins_userpass)).split()
Expand Down
7 changes: 3 additions & 4 deletions features/extensions/apigee/terraformBugWorkaround.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
terraformPreviousRoleOutput = "previous-role-arn"
featureName = "Apigee"
# The lambda function created has the format of ENVPREFIX-jazz-apigee-proxy-aws-STAGE
gatewayFunctionName = "jazz-apigee-proxy-aws-prod"
terraformGatewayResource = "aws_lambda_function.jazz-apigee-proxy"
gatewayFunctionName = "jazz_apigee-proxy-aws_prod"


def runTerraform(region, envPrefix, install):
Expand All @@ -30,9 +29,9 @@ def runTerraform(region, envPrefix, install):
'-var', 'region={0}'.format(region),
'-var', 'jazz_aws_accountid={0}'.format(getAWSAccountID()),
'-var', 'env_prefix={0}'.format(envPrefix),
'-var', 'gateway_func_arn={0}'.format(getFunctionArn(envPrefix + "-" +
'-var', 'gateway_func_arn={0}'.format(getFunctionArn(envPrefix + "_" +
gatewayFunctionName)),
'-var', 'previous_role_arn={0}'.format(getFunctionRole(envPrefix + "-" +
'-var', 'previous_role_arn={0}'.format(getFunctionRole(envPrefix + "_" +
gatewayFunctionName))
],
cwd='extensions/apigee/terraform')
Expand Down
2 changes: 1 addition & 1 deletion features/extensions/apigee/uninstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def uninstall(region, stackprefix, jazz_userpass, jazz_apiendpoint, jenkins_url,
click.secho('\nRestoring old role to gateway function', fg='blue')

# Restore old role first, before we destroy the Terraform resources
restoreOldRoleToExistingFunctionWithCLI(stackprefix + "-" + gatewayFunctionName)
restoreOldRoleToExistingFunctionWithCLI(stackprefix + "_" + gatewayFunctionName)
jazz_userpass_list = ''.join(list(jazz_userpass)).split()
jazz_username, jazz_password = jazz_userpass_list[0], jazz_userpass_list[1]
jenkins_userpass_list = ''.join(list(jenkins_userpass)).split()
Expand Down
4 changes: 4 additions & 0 deletions installer/terraform/commands.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ variable "config_cmd" {
type = "string"
default = "./scripts/config.py"
}
variable "cleanEni_cmd" {
type = "string"
default = "./scripts/clean_lambda_eni.py"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
default['maven']['setup_bin'] = true

#Node cookbook property
default['nodejs']['version'] = '8'
default['nodejs']['version'] = '10'
default['nodejs']['install_method'] = 'package'
#This monkeypatch is necessary because the node cookbook brokenly defaults to a 6.x sources.list otherwise
case node['platform_family']
when 'debian'
override['nodejs']['repo'] = 'https://deb.nodesource.com/node_8.x'
override['nodejs']['repo'] = 'https://deb.nodesource.com/node_10.x'
when 'rhel', 'amazon'
default['nodejs']['repo'] = "https://rpm.nodesource.com/pub_8.x/el/$releasever/$basearch"
default['nodejs']['repo'] = "https://rpm.nodesource.com/pub_10.x/el/$releasever/$basearch"
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
apt_update 'update' #force-update apt cache on Debian-derivatives to avoid pkg fetch errors
package 'git'
include_recipe 'maven::default'

# Node won't upgrade to latest version in centos if already a version is present.
if platform_family?('rhel')
bash 'uninstall-nodejs' do
code <<-EOH
if [ -f /etc/os-release ]; then
rm -fr /var/cache/yum/*
yum remove -y nodejs
rm /etc/yum.repos.d/nodesource*
yum clean all
fi
EOH
end
end

include_recipe 'nodejs'
include_recipe 'cloudcli'

Expand Down
47 changes: 47 additions & 0 deletions installer/terraform/scripts/clean_lambda_eni.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import boto3
import sys
import time


def cleanup(client, vpc_id, sg_id):
in_use_found = False
try:
response = client.describe_network_interfaces(
Filters=[
{
'Name': 'vpc-id',
'Values': [
str(vpc_id),
]
},
{
'Name': 'group-id',
'Values': [
str(sg_id),
]
},
],
)
for item in response['NetworkInterfaces']:
if "AWS Lambda VPC ENI" in item['Description']:
if item['Status'] == 'in-use':
in_use_found = True
if item['Status'] == 'available':
# delete the ENI
print("Item to delete: " + str(item['NetworkInterfaceId']))
response = client.delete_network_interface(
NetworkInterfaceId=str(item['NetworkInterfaceId'])
)
if in_use_found:
print("Still In use ENIs found")
time.sleep(30)
cleanup(client, vpc_id, sg_id)
else:
return True
except Exception as message:
print(message)


if __name__ == u"__main__":
client = boto3.client('ec2')
cleanup(client, sys.argv[1], sys.argv[2])
2 changes: 1 addition & 1 deletion installer/terraform/scripts/modifyCodebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ do

# shellcheck disable=SC2086
#Updating to service catalog
provider_runtime="nodejs8.10"
provider_runtime="nodejs10.x"
pushToCatalog "$tablename" "$element" "$service_type" "${deployment_targets[@]}" "$provider_runtime"

done
5 changes: 5 additions & 0 deletions installer/terraform/vpc_subnet.tf
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ resource "aws_subnet" "subnet_for_ecs_private" {
availability_zone = "${element(slice(data.aws_availability_zones.available.names, 0, 2), count.index)}"
cidr_block = "${cidrsubnet(data.aws_vpc.vpc_data.cidr_block, ceil(log(4 * 2, 2)), 2 + count.index)}"
tags = "${merge(var.additional_tags, local.common_tags)}"
provisioner "local-exec" {
when = "destroy"
command = "python ${var.cleanEni_cmd} ${data.aws_vpc.vpc_data.id} ${var.dockerizedJenkins == 1 ? join(" ", aws_security_group.vpc_sg.*.id) : aws_security_group.vpc_sg_es_kibana.id }"
on_failure = "continue"
}
}

resource "aws_route_table" "privateroute" {
Expand Down

0 comments on commit ee6565d

Please sign in to comment.