Skip to content

Commit be501f3

Browse files
author
Dale Frey
committed
USAGOV-1996: Merge branch 'dev' into USAGOV-1996
2 parents 276b246 + 6f86925 commit be501f3

File tree

59 files changed

+1329
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1329
-612
lines changed

.circleci/config.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ jobs:
625625
- deploy-cloudgov-cron:
626626
envname: prod
627627

628-
deploy-to-cloudgov-dr-cron-tools:
628+
deploy-to-cloudgov-prod-cron-tools:
629629
machine:
630630
image: ubuntu-2204:current
631631
environment:
@@ -634,15 +634,6 @@ jobs:
634634
- deploy-cloudgov-cron:
635635
envname: tools
636636

637-
deploy-to-cloudgov-dr-cron-shared-egress:
638-
machine:
639-
image: ubuntu-2204:current
640-
environment:
641-
BASH_ENV: /home/circleci/project/env.local
642-
steps:
643-
- deploy-cloudgov-cron:
644-
envname: shared-egress
645-
646637
workflows:
647638
version: 2
648639

@@ -928,30 +919,16 @@ workflows:
928919
branches:
929920
only: prod
930921

931-
- really-approve-dr-deployment-cron-tools:
932-
type: approval
933-
requires:
934-
- approve-dr-deployment-cron
935-
filters:
936-
branches:
937-
only: dr
938-
- deploy-to-cloudgov-dr-cron-tools:
939-
requires:
940-
- really-approve-dr-deployment-cron-tools
941-
filters:
942-
branches:
943-
only: dr
944-
945-
- really-approve-dr-deployment-cron-shared-egress:
922+
- really-approve-prod-deployment-cron-tools:
946923
type: approval
947924
requires:
948-
- approve-dr-deployment-cron
925+
- approve-prod-deployment-cron
949926
filters:
950927
branches:
951-
only: dr
952-
- deploy-to-cloudgov-dr-cron-shared-egress:
928+
only: prod
929+
- deploy-to-cloudgov-prod-cron-tools:
953930
requires:
954-
- really-approve-dr-deployment-cron-shared-egress
931+
- really-approve-prod-deployment-cron-tools
955932
filters:
956933
branches:
957-
only: dr
934+
only: prod

.docker/Dockerfile-egress

Lines changed: 0 additions & 26 deletions
This file was deleted.

.docker/src-cms/etc/nginx/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ http {
4242

4343
# Timeout for keep-alive connections. Server will close connections after
4444
# this time.
45-
keepalive_timeout 65;
45+
keepalive_timeout 80s;
4646

4747
# Sendfile copies data between one FD and other from within the kernel,
4848
# which is more efficient than read() + write().

.docker/src-cms/etc/periodic/1min/generate-static-site

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ if [ "${CF_INSTANCE_INDEX:-''}" == "0" ]; then
99
# Use unique uri per environment - default to prod
1010
if [ "${APP_SPACE}" = "dev" ]; then
1111
URI="https://beta-dev.usa.gov"
12+
elif [ "${APP_SPACE}" = "dr" ]; then
13+
URI="https://beta-dr.usa.gov"
1214
elif [ "${APP_SPACE}" = "stage" ]; then
1315
URI="https://beta-stage.usa.gov"
1416
elif [ "${APP_SPACE}" = "local" ]; then

.docker/src-waf/etc/nginx/nginx.conf.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ http {
2121

2222
client_max_body_size 512m;
2323

24-
keepalive_timeout 60s;
24+
# As per USAGOV-1927 need to make sure the following vlaue is greather than the timeout-value in
25+
# .docker/src-www/etc/nginx/nginx.conf
26+
# and
27+
# .docker/src-cms/etc/nginx/nginx.conf
28+
keepalive_timeout 100s;
2529

2630
resolver ${DNS_SERVER} valid=5s ipv6=off;
2731

.docker/src-www/etc/nginx/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ http {
4242

4343
# Timeout for keep-alive connections. Server will close connections after
4444
# this time.
45-
keepalive_timeout 65;
45+
keepalive_timeout 80s;
4646

4747
# Sendfile copies data between one FD and other from within the kernel,
4848
# which is more efficient than read() + write().

bin/cloudgov/audit/cf-components

Lines changed: 270 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This script will compile a report of our cf env's components
4+
#
5+
6+
# Styling variables
7+
underline=`tput smul`
8+
nounderline=`tput rmul`
9+
bold=`tput bold`
10+
normal=`tput sgr0`
11+
level2=" "
12+
level3=" "
13+
level4=" "
14+
level5=" "
15+
level6=" "
16+
17+
die() { echo "$*" >&2; exit 2; } # complain to STDERR and exit with error
18+
needs_arg() { if [ -z "$OPTARG" ]; then die "No arg for --$OPT option"; fi; }
19+
20+
# Defaults (to be thorough, you could also assign alpha="" and charlie="")
21+
all=false # Overridden by the value set by -b or --bravo
22+
spaces="all" # Overridden by the value set by -s or --spaces
23+
24+
while getopts as: OPT; do # allow -a, -b with arg, and -- "with arg"
25+
# support long options: https://stackoverflow.com/a/28466267/519360
26+
if [ "$OPT" = "-" ]; then # long option: reformulate OPT and OPTARG
27+
OPT="${OPTARG%%=*}" # extract long option name
28+
OPTARG="${OPTARG#"$OPT"}" # extract long option argument (may be empty)
29+
OPTARG="${OPTARG#=}" # if long option argument, remove assigning `=`
30+
fi
31+
case "$OPT" in
32+
a | all ) all=true ;;
33+
s | spaces ) needs_arg; spaces="$OPTARG" ;;
34+
\? ) exit 2 ;; # bad short option (error reported via getopts)
35+
* ) die "Illegal option --$OPT" ;; # bad long option
36+
esac
37+
done
38+
shift $((OPTIND-1)) # remove parsed options and args from $@ list
39+
40+
getPaginationCount() { # $1 = resource, $2 = relationship, $3 = relationship id
41+
PAGES=$(cf curl "/v3/$1" | jq -r '.pagination | .total_pages');
42+
SELECT=""
43+
if [ -n "$2" ]; then
44+
SELECT=' select( .relationships.'"$2"'.data.guid == "'"$3"'" ) |'
45+
fi
46+
for i in $(seq 1 "$PAGES"); do
47+
IDS=${IDS}$(cf curl "/v3/$1?page=$i&per_page=50" | jq -r '[.resources[] |'"$SELECT"' .guid]')
48+
done
49+
echo "$IDS"
50+
}
51+
52+
echo "${bold}${underline}CF Components${nounderline}${normal}"
53+
54+
# Orgs->Domains/Spaces->Apps/Services->Tasks/Sidecars
55+
if [ $all == true ]; then
56+
ORGIDS=$(getPaginationCount "organizations")
57+
else
58+
echo "Showing info for gsa-tts-usagov, add --all argument to see all orgs."
59+
ORGIDS=$(cf curl "/v3/organizations" | jq -r '[.resources[] | select(.name == "gsa-tts-usagov") | .guid]')
60+
fi
61+
62+
IFS=',' read -r -a spaces_array <<< "$spaces"
63+
64+
echo "$ORGIDS" | jq -r '.[]' | while read -r ORGID; do
65+
ORG=$(cf curl "/v3/organizations/$ORGID")
66+
ORGNAME=$(echo "$ORG" | jq -r '.name')
67+
ORGCREATE=$(echo "$ORG" | jq -r '.created_at')
68+
ORGUPDATE=$(echo "$ORG" | jq -r '.updated_at')
69+
70+
echo "Org: ${underline}$ORGNAME${nounderline} (Last updated: $ORGUPDATE | Created: $ORGCREATE)"
71+
72+
DOMIANIDS=$(getPaginationCount "domains" "organization" "$ORGID")
73+
if [ "$DOMIANIDS" != "[]" ]; then
74+
echo "$level2 Domains:"
75+
echo "$DOMIANIDS" | jq -r '.[]' | while read -r DOMIANID; do
76+
DOMAIN=$(cf curl "/v3/domains/$DOMIANID")
77+
DOMAINNAME=$(echo "$DOMAIN" | jq -r '.name')
78+
DOMAINCREATED=$(echo "$DOMAIN" | jq -r '.created_at')
79+
DOMAINUPDATED=$(echo "$DOMAIN" | jq -r '.updated_at')
80+
DOMAININTERNAL=$(echo "$DOMAIN" | jq -r '.internal')
81+
DOMAINPROTOCOLS=$(echo "$DOMAIN" | jq -c '.supported_protocols')
82+
echo "$level3 $DOMAINNAME (Last updated: $DOMAINUPDATED | Created: $DOMAINCREATED | Internal: $DOMAININTERNAL | Supported Protocols: $DOMAINPROTOCOLS)"
83+
done
84+
fi
85+
86+
if [ $spaces == "all" ]; then
87+
SPACEPAGES=$(cf curl "/v3/spaces" | jq -r '.pagination | .total_pages');
88+
if [[ $SPACEPAGES -gt 1 ]]; then
89+
for i in $SPACEPAGES; do
90+
SPACEIDS=$(cf curl "/v3/spaces?page=$i&per_page=50" | jq -r '.resources[] | select( .relationships.organization.data.guid == "'$ORGID'" ) | .guid')
91+
done
92+
else
93+
SPACEIDS=$(cf curl "/v3/spaces" | jq -r '.resources[] | select( .relationships.organization.data.guid == "'$ORGID'" ) | .guid')
94+
fi
95+
else
96+
SPACEPAGES=$(cf curl "/v3/spaces" | jq -r '.pagination | .total_pages');
97+
if [[ $SPACEPAGES -gt 1 ]]; then
98+
for i in $SPACEPAGES; do
99+
SPACEIDS=$(cf curl "/v3/spaces?page=$i&per_page=50" | jq -r '.resources[] | select( .relationships.organization.data.guid == "'$ORGID'" ) | .guid' | while read -r SPACEID; do
100+
SPACENAME=$(cf curl "/v3/spaces/$SPACEID" | jq -r '.name')
101+
for space in "${spaces_array[@]}"; do
102+
if [[ "$space" == "$SPACENAME" ]]; then
103+
echo "$SPACEID"
104+
fi
105+
done
106+
done)
107+
done
108+
else
109+
SPACEIDS=$(cf curl "/v3/spaces" | jq -r '.resources[] | select( .relationships.organization.data.guid == "'$ORGID'" ) | .guid' | while read -r SPACEID; do
110+
SPACENAME=$(cf curl "/v3/spaces/$SPACEID" | jq -r '.name')
111+
for space in "${spaces_array[@]}"; do
112+
if [[ "$space" == "$SPACENAME" ]]; then
113+
echo "$SPACEID"
114+
fi
115+
done
116+
done)
117+
fi
118+
fi
119+
120+
echo "$SPACEIDS" | while read -r SPACEID; do
121+
SPACE=$(cf curl "/v3/spaces/$SPACEID")
122+
SPACENAME=$(echo "$SPACE" | jq -r '.name')
123+
SPACECREATED=$(echo "$SPACE" | jq -r '.created_at')
124+
SPACEUPDATE=$(echo "$SPACE" | jq -r '.updated_at')
125+
echo "$level2 Space: ${underline}$SPACENAME${nounderline} (Last updated: $SPACEUPDATE | Created: $SPACECREATED)"
126+
127+
SERVICEIDS=$(getPaginationCount "service_instances" "space" "$SPACEID")
128+
if [ "$SERVICEIDS" != "[]" ]; then
129+
echo "$level3 Services:"
130+
echo "$SERVICEIDS" | jq -r '.[]' | while read -r SERVICEID; do
131+
SERVICELASTOPERATION=""
132+
SERVICE=$(cf curl "/v3/service_instances/$SERVICEID")
133+
SERVICENAME=$(echo "$SERVICE" | jq -r '.name')
134+
SERVICECREATED=$(echo "$SERVICE" | jq -r '.created_at')
135+
SERVICEUPDATED=$(echo "$SERVICE" | jq -r '.updated_at')
136+
if [ "$(echo "$SERVICE" | jq -r '.last_operation')" != "{}" ]; then
137+
SERVICETYPE=$(echo "$SERVICE" | jq -r '.last_operation.type')
138+
SERVICESTATE=$(echo "$SERVICE" | jq -r '.last_operation.state')
139+
SERVICEDESCRIPTION=$(echo "$SERVICE" | jq -r '.last_operation.description')
140+
SERVICEUPDATED=$(echo "$SERVICE" | jq -r '.last_operation.updated_at')
141+
142+
SERVICELASTOPERATION="(Last operation at $SERVICEUPDATED; Type: $SERVICETYPE | State: $SERVICESTATE | Description: $SERVICEDESCRIPTION)"
143+
fi
144+
echo "$level4 $SERVICENAME Last updated: $SERVICEUPDATED | Created: $SERVICECREATED $SERVICELASTOPERATION"
145+
done
146+
fi
147+
148+
ROUTEIDS=$(getPaginationCount "routes" "space" "$SPACEID")
149+
if [ "$ROUTEIDS" != "[]" ]; then
150+
echo "$level3 Routes:"
151+
echo "$ROUTEIDS" | jq -r '.[]' | while read -r ROUTEID; do
152+
ROUTE=$(cf curl "/v3/routes/$ROUTEID")
153+
ROUTECREATED=$(echo "$ROUTE" | jq -r '.created_at')
154+
ROUTEUPDATED=$(echo "$ROUTE" | jq -r '.updated_at')
155+
ROUTEHOST=$(echo "$ROUTE" | jq -r '.host')
156+
ROUTEPATH=$(echo "$ROUTE" | jq -r '.path')
157+
ROUTEURL=$(echo "$ROUTE" | jq -r '.url')
158+
echo "$level4 $ROUTEURL (Last updated: $ROUTEUPDATED | Created: $ROUTECREATED | Host: $ROUTEHOST | Path: $ROUTEPATH)"
159+
done
160+
fi
161+
162+
SGROUPIDS=$(getPaginationCount "spaces/$SPACEID/running_security_groups")
163+
if [ "$SGROUPIDS" != "[]" ]; then
164+
echo "$level3 Attached Security Groups:"
165+
echo "$SGROUPIDS" | jq -r '.[]' | while read -r SGROUPID; do
166+
SGROUP=$(cf curl "/v3/security_groups/$SGROUPID")
167+
SGROUPCREATED=$(echo "$SGROUP" | jq -r '.created_at')
168+
SGROUPUPDATED=$(echo "$SGROUP" | jq -r '.updated_at')
169+
SGROUPNAME=$(echo "$SGROUP" | jq -r '.name')
170+
echo "$level4 $SGROUPNAME (Last updated: $SGROUPUPDATED | Created: $SGROUPCREATED)"
171+
done
172+
fi
173+
174+
APPIDS=$(getPaginationCount "apps" "space" "$SPACEID")
175+
if [ "$APPIDS" != "[]" ]; then
176+
echo "$level3 Apps:"
177+
echo "$APPIDS" | jq -r '.[]' | while read -r APPID; do
178+
APP=$(cf curl "/v3/apps/$APPID")
179+
APPNAME=$(echo "$APP" | jq -r '.name')
180+
APPCREATED=$(echo "$APP" | jq -r '.created_at')
181+
APPUPDATED=$(echo "$APP" | jq -r '.updated_at')
182+
APPSTATE=$(echo "$APP" | jq -r '.state')
183+
APPTYPE=$(echo "$APP" | jq -r '.lifecycle.type')
184+
185+
if [ "$APPTYPE" != "docker" ]; then
186+
APPBUILDPACKS=$(echo "$APP" | jq -c '.lifecycle.data.buildpacks')
187+
APPSTACK=$(echo "$APP" | jq -c '.lifecycle.data.stack')
188+
APPSTACKINFO=" | Buildpacks: $APPBUILDPACKS | Stack: $APPSTACK"
189+
fi
190+
echo "$level4 $APPNAME (Last updated: $APPUPDATED | Created: $APPCREATED | State: $APPSTATE | Type: $APPTYPE$APPSTACKINFO)"
191+
192+
DROPLETID=$(cf curl "/v3/apps/$APPID/droplets/current" | jq -r '.guid')
193+
if [ -n "$DROPLETID" ]; then
194+
DROPLET=$(cf curl "/v3/droplets/$DROPLETID")
195+
DROPLETSTATE=$(echo "$DROPLET" | jq -r '.state')
196+
DROPLETCREATED=$(echo "$DROPLET" | jq -r '.created_at')
197+
DROPLETUPDATED=$(echo "$DROPLET" | jq -r '.updated_at')
198+
DROPLETSTACK=$(echo "$DROPLET" | jq -r '.stack')
199+
DROPLETSTACKOUT=""
200+
if [ "$DROPLETSTACK" != "null" ]; then
201+
DROPLETSTACKOUT=" | Stack: $DROPLETSTACK"
202+
fi
203+
DROPLETIMAGEOUT=""
204+
DROPLETIMAGE=$(echo "$DROPLET" | jq -r '.image')
205+
if [ "$DROPLETIMAGE" != "null" ]; then
206+
DROPLETIMAGEOUT=" | Image: $DROPLETIMAGE"
207+
fi
208+
echo "$level5 Current Droplet: $DROPLETSTATE (Last updated: $DROPLETUPDATED | Created: $DROPLETCREATED$DROPLETSTACKOUT$DROPLETIMAGEOUT)"
209+
fi
210+
211+
TASKCOUNT=$(cf curl "/v3/apps/$APPID/tasks" | jq -r '.pagination | .total_results')
212+
if [ "$TASKCOUNT" != "[]" ]; then
213+
echo "$level5 Number of Tasks attached to $APPNAME: $TASKCOUNT"
214+
fi
215+
216+
SIDECARIDS=$(getPaginationCount "apps/$APPID/sidecars" "app" "$APPID")
217+
if [ "$SIDECARIDS" != "[]" ]; then
218+
echo "$level5 Sidecars:"
219+
echo "$SIDECARIDS" | jq -r '.[]' | while read -r SIDECARID; do
220+
SIDECAR=$(cf curl "/v3/sidecars/$SIDECARID")
221+
SIDECARNAME=$(echo "$SIDECAR" | jq -r '.name')
222+
SIDECARCREATED=$(echo "$SIDECAR" | jq -r '.created_at')
223+
SIDECARUPDATED=$(echo "$SIDECAR" | jq -r '.updated_at')
224+
SIDECARCOMMAND=$(echo "$SIDECAR" | jq -r '.command')
225+
SIDECARPROCESS=$(echo "$SIDECAR" | jq -c '.process_types')
226+
SIDECARMEMORY=$(echo "$SIDECAR" | jq -r '.memory_in_mb')
227+
SIDECARORIGIN=$(echo "$SIDECAR" | jq -r '.origin')
228+
echo "$level6 $SIDECARNAME (Last updated: $SIDECARUPDATED | Created: $SIDECARCREATED | Command: $SIDECARCOMMAND | Process Types: $SIDECARPROCESS | Memory: $SIDECARMEMORY mb | Origin: $SIDECARORIGIN)"
229+
done
230+
fi
231+
done
232+
fi
233+
done
234+
done
235+
236+
# Misc info
237+
# Users temporarily removed as there is no way to filter users by organization.
238+
#
239+
# if [ $all == true ]; then
240+
# echo "Showing all orgs. For security reasons, the display of users is suppressed. Remove -a argument to see users for gsa-tts-usagov org."
241+
# else
242+
# USERIDS=$(getPaginationCount "users")
243+
# if [ "$USERIDS" != "[]" ]; then
244+
# echo "${underline}Users:${nounderline}"
245+
# echo "$USERIDS" | jq -r '.[]' | while read -r USERID; do
246+
# USER=$(cf curl "/v3/users/$USERID")
247+
# USERNAME=$(echo "$USER" | jq -r '.username')
248+
# USERPCREATED=$(echo "$USER" | jq -r '.created_at')
249+
# USERPUPDATE=$(echo "$USER" | jq -r '.updated_at')
250+
# USERPRESENTATION=$(echo "$USER" | jq -r '.presentation_name')
251+
# USERORIGIN=$(echo "$USER" | jq -r '.origin')
252+
# echo "$level2 $USERNAME (Last updated: $USERPUPDATE | Created: $USERPCREATED | Presentation Name: $USERPRESENTATION | Origin: $USERORIGIN)"
253+
# done
254+
# fi
255+
# fi
256+
257+
GROUPIDS=$(getPaginationCount "security_groups")
258+
if [ "$GROUPIDS" != "[]" ]; then
259+
echo "${underline}Security Groups:${nounderline}"
260+
echo "$GROUPIDS" | jq -r '.[]' | while read -r GROUPID; do
261+
GROUP=$(cf curl "/v3/security_groups/$GROUPID")
262+
GROUPNAME=$(echo "$GROUP" | jq -r '.name')
263+
GROUPUPDATED=$(echo "$GROUP" | jq -r '.created_at')
264+
GROUPUPDATED=$(echo "$GROUP" | jq -r '.updated_at')
265+
GROUPRULES=$(echo "$GROUP" | jq -r '.rules')
266+
echo "$level2 $GROUPNAME (Last updated: $GROUPUPDATED | Created: $GROUPUPDATED)"
267+
echo "$level3 Rules:"
268+
echo "$level4 $GROUPRULES"
269+
done
270+
fi

0 commit comments

Comments
 (0)