pcf_blue_green 0.43.38 → 0.43.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/pcf_blue_green/version.rb +1 -1
- data/lib/pcf_blue_green.rb +8 -2
- data/lib/shared-deploy-functions.sh +35 -10
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 34e3f7a1aec41a57d429d0ff406e1140b72558e2ee03fb06815492aab8b684d6
|
|
4
|
+
data.tar.gz: 5cd23931c440025a520d5b60eb269946e62cb562971c1af10465360c9ac1a11e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ddfae920b9857d551fc93e867cd36ecb696981864c026ca00c38ef739d29036cd29948dd545e98de8b1999ecb891465dc59e7b2909c8ffeeef67c567f8c39669
|
|
7
|
+
data.tar.gz: e7cf065b654bfc53005f755ff22d2bd667200d43a95a377cc72c40a5bb6fdb2627b9cdaee1a509bec0fd534a15eab62dadd5921cee419b525c23b6f867dc6c5d
|
data/lib/pcf_blue_green.rb
CHANGED
|
@@ -17,6 +17,7 @@ module PcfBlueGreen
|
|
|
17
17
|
@org = org
|
|
18
18
|
@space = space
|
|
19
19
|
@login_options = @options[:login]
|
|
20
|
+
ENV['maitenance_enabled'] = maitenance_enabled?.to_s
|
|
20
21
|
login if call_login
|
|
21
22
|
cmd = "echo $(gem which pcf_blue_green)"
|
|
22
23
|
shell = Mixlib::ShellOut.new(cmd)
|
|
@@ -90,6 +91,11 @@ module PcfBlueGreen
|
|
|
90
91
|
mapped_routes.uniq.join(",\n")
|
|
91
92
|
end
|
|
92
93
|
|
|
94
|
+
def maitenance_enabled?
|
|
95
|
+
entity = entity_for(ENV['cf_app'])
|
|
96
|
+
entity ? entity['environment_json']['MAINTENANCE_ENABLED'] : false
|
|
97
|
+
end
|
|
98
|
+
|
|
93
99
|
private
|
|
94
100
|
|
|
95
101
|
def entity_for(app_name)
|
|
@@ -130,7 +136,7 @@ module PcfBlueGreen
|
|
|
130
136
|
|
|
131
137
|
def routes_stdout(entity)
|
|
132
138
|
routes_url = entity['routes_url']
|
|
133
|
-
app_routes_cmd = "cf curl #{routes_url}"
|
|
139
|
+
app_routes_cmd = "cf curl #{routes_url}?results-per-page=100"
|
|
134
140
|
app_routes_shell = Mixlib::ShellOut.new(app_routes_cmd)
|
|
135
141
|
app_routes_shell.run_command
|
|
136
142
|
JSON.parse(app_routes_shell.stdout)
|
|
@@ -146,7 +152,7 @@ module PcfBlueGreen
|
|
|
146
152
|
|
|
147
153
|
def login
|
|
148
154
|
puts "Logging in to #{@url}"
|
|
149
|
-
cf_login = "cf login -a #{@url} -u #{@user} -p '#{@pass}' -o #{@org} -s #{@space} #{@login_options} > /dev/null"
|
|
155
|
+
cf_login = "cf login -a #{@url} -u #{@user} -p '#{@pass}' -o #{@org} -s '#{@space}' #{@login_options} > /dev/null"
|
|
150
156
|
cmd = "#{cf_login}"
|
|
151
157
|
shell = Mixlib::ShellOut.new(cmd)
|
|
152
158
|
shell.run_command
|
|
@@ -33,7 +33,7 @@ function announce-success {
|
|
|
33
33
|
|
|
34
34
|
function run-cmd {
|
|
35
35
|
echo -e "\n\n${Cya}${@}${RCol}\n"
|
|
36
|
-
$@
|
|
36
|
+
"$@"
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function set-ruby {
|
|
@@ -56,22 +56,33 @@ function cf-setup {
|
|
|
56
56
|
run-cmd cf api ${cf_api} --skip-ssl-validation
|
|
57
57
|
set +x
|
|
58
58
|
cf auth ${cf_user} ${cf_password}
|
|
59
|
-
run-cmd cf target -o ${cf_org} -s ${cf_space}
|
|
59
|
+
run-cmd cf target -o ${cf_org} -s "${cf_space}"
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
function cf-push {
|
|
63
63
|
local app_name=$1
|
|
64
64
|
local manifest=$2
|
|
65
|
+
|
|
66
|
+
if [ -z ${health_check_timeout+x} ]; then
|
|
67
|
+
announce-task "Pushing ${app_name}"
|
|
68
|
+
run-cmd cf push ${app_name} -f ${cf_manifest} --hostname ${app_name} -s cflinuxfs3
|
|
69
|
+
else
|
|
70
|
+
announce-task "Pushing ${app_name}. ${health_check_timeout} seconds health-check timeout set"
|
|
71
|
+
run-cmd cf push ${app_name} -f ${cf_manifest} --hostname ${app_name} -t ${health_check_timeout} -s cflinuxfs3
|
|
72
|
+
fi
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function cf-push-healthcheck {
|
|
76
|
+
local app_name=$1
|
|
77
|
+
local manifest=$2
|
|
78
|
+
local health_check_type=$3
|
|
65
79
|
announce-task "Pushing ${app_name}"
|
|
66
|
-
run-cmd cf push ${app_name} -f ${cf_manifest} --hostname ${app_name}
|
|
80
|
+
run-cmd cf push ${app_name} -f ${cf_manifest} --hostname ${app_name} --health-check-type ${health_check_type} -s cflinuxfs3
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
function check-health {
|
|
70
84
|
local app_url=$1
|
|
71
85
|
announce-task "Checking health"
|
|
72
|
-
sleep 300
|
|
73
|
-
maitenance_enabled=$(echo $(cf curl '/v2/apps' -X GET -H 'Content-Type: application/x-www-form-urlencoded' -d "q=name:$cf_app" | jq '.resources[0].entity.environment_json.MAINTENANCE_ENABLED'))
|
|
74
|
-
maitenance_enabled=$(echo ${maitenance_enabled//\"} | awk '{ print tolower($1) }')
|
|
75
86
|
if [ $maitenance_enabled == "true" ] ; then
|
|
76
87
|
status=$(curl -sSIL --header "x-digital-auth: ${JWT}" -X GET -o /dev/null -w "%{http_code}" ${app_url} --insecure)
|
|
77
88
|
if [ $status == 503 ] ; then
|
|
@@ -118,13 +129,20 @@ function remove-blue {
|
|
|
118
129
|
}
|
|
119
130
|
|
|
120
131
|
function get-domain {
|
|
121
|
-
|
|
132
|
+
arr=($cf_space)
|
|
133
|
+
num=$(($(echo ${#arr[@]}) + 2))
|
|
134
|
+
export domain=$(cf routes | grep ${cf_app} | awk -v env_var="$num" '{print $'$num'}' | grep "^apps\\." | tail -1)
|
|
122
135
|
announce-task "Domain is ${domain}"
|
|
123
136
|
}
|
|
137
|
+
function join { local IFS="$1"; shift; echo "$*"; }
|
|
124
138
|
|
|
125
139
|
function prep-green {
|
|
126
140
|
blue=${cf_app}
|
|
127
|
-
|
|
141
|
+
arr=($cf_space)
|
|
142
|
+
space="$(join - ${arr[@]})"
|
|
143
|
+
space="$(echo "${space//_/$'-'}")"
|
|
144
|
+
export green="${cf_app}-${space}-g"
|
|
145
|
+
echo "exported green: ${green}"
|
|
128
146
|
if [ -z ${cf_manifest+x }]; then
|
|
129
147
|
generate-manifest
|
|
130
148
|
else
|
|
@@ -153,9 +171,16 @@ function blue-green {
|
|
|
153
171
|
cd $app_directory
|
|
154
172
|
cf-setup
|
|
155
173
|
|
|
156
|
-
|
|
174
|
+
if [ $maitenance_enabled == "true" ] ; then
|
|
175
|
+
cf set-health-check ${cf_app} port
|
|
176
|
+
fi
|
|
157
177
|
|
|
158
|
-
|
|
178
|
+
prep-green
|
|
179
|
+
if [ $maitenance_enabled == "false" ] ; then
|
|
180
|
+
cf-push-healthcheck ${green} ${cf_manifest} 'http'
|
|
181
|
+
else
|
|
182
|
+
cf-push ${green} ${cf_manifest}
|
|
183
|
+
fi
|
|
159
184
|
health_check_domain="${health_check_domain:-$domain}"
|
|
160
185
|
if [ -z ${app_path+x} ]; then
|
|
161
186
|
check-health "https://${green}.${health_check_domain}"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pcf_blue_green
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.43.
|
|
4
|
+
version: 0.43.43
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pawel Bardzinski
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-07-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: mixlib-shellout
|
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
132
132
|
version: '0'
|
|
133
133
|
requirements: []
|
|
134
134
|
rubyforge_project:
|
|
135
|
-
rubygems_version: 2.
|
|
135
|
+
rubygems_version: 2.7.7
|
|
136
136
|
signing_key:
|
|
137
137
|
specification_version: 4
|
|
138
138
|
summary: gem encapsualting blue-green bash script
|