Commit 830aac6
authored
TECH_DEBT: Add QA2 support and fix full commit hash resolution in get_deployed_commit.py (#1843)
* TECH_DEBT: Add QA2 environment support to get_deployed_commit.py
The Deploy_All_Services pipeline has offered scale-qa2 as an environment since
82f073a, but get_deployed_commit.py only recognized dev-scale, scale-test and
scale-qa. Selecting QA2 failed the Summarize job with "Unknown environment
'scale-qa2'", which skipped the dependent Deploy job.
- Map scale-qa2 to a QA2_BASE_URL environment variable, alongside the existing three
- List scale-qa2 in the unknown-environment and empty-BASE_URL error messages
- Document scale-qa2 in the script docstring and the Scripts/README.md row
- Mention QA2 in the pipeline's environment parameter displayName
Verified by running the script against scale-qa2 with QA2_BASE_URL set to
https://qa2-admin.nhsnlink.org, which resolved the deployed commit 78b98b4 from
/api/info. Unknown environments and the direct https:// URL argument are unchanged.
Requires a QA2_BASE_URL variable to be added in Azure DevOps wherever QA_BASE_URL is
already defined; without it the script reports the empty-BASE_URL error rather than
querying the wrong host.
* TECH_DEBT: Resolve short commit hashes via the GitHub commits API
get_deployed_commit.py read the full SHA from payload.commit.sha2 in the JSON served
by the GitHub commit page. That path no longer exists — the SHA moved to
payload.commitRoute.commit.oid — so the chained .get() calls fell back to the short
hash and returned it without raising. The "Attempting to translate..." line was
therefore followed by neither a warning nor a translation.
FromCommit then reached list-deploy-changes.py as a 7-character hash. It fetches both
refs with 'git fetch --depth=1 origin <ref>', which GitHub rejects for anything but a
full SHA ("couldn't find remote ref"), and that fetch discards stderr and ignores its
exit code, so the deployment summary could silently come out empty.
- Query api.github.com/repos/.../commits/<sha> with the 'application/vnd.github.sha'
media type, which returns the 40-character hash as plain text, instead of reading
the commit page's undocumented JSON payload
- Accept the result only when it is exactly 40 characters, warning with the response
body otherwise
- Warn explicitly when FromCommit is still a short hash, naming the fetch that will
fail, so a future breakage is not silent
Verified against qa and qa2: 78b98b4 now resolves to
78b98b4. An unknown hash returns HTTP 422, which
raises into the existing handler and then trips the short-hash warning.
* TECH_DEBT: Bound the HTTP calls in get_deployed_commit.py with a timeout
Neither urlopen call passed a timeout, and the script never sets a global socket
default, so both used urlopen's default of blocking indefinitely. An unresponsive
/api/info endpoint or GitHub API would hang the Summarize job until the Azure DevOps
job timeout killed it, rather than failing the step with a usable error.
- Add an HTTP_TIMEOUT_SECONDS constant of 30 seconds
- Pass it to the /api/info request and the GitHub commits request, so both share the
same budget
A timeout on the /api/info call raises into the existing handler and exits through
fail(); a timeout while resolving the full hash prints the existing warnings and
leaves FromCommit as the short hash. Verified against qa2 that the normal path is
unaffected: 78b98b4 still resolves to 78b98b4.
* TECH_DEBT: Fail get_deployed_commit.py when the full hash cannot be resolved
The script warned about an unresolved short hash and then published it anyway. The
downstream consumer cannot use it: list-deploy-changes.py fetches both refs with
'git fetch --depth=1 origin <ref>', GitHub rejects unadvertised objects by short SHA,
and that fetch discards stderr and ignores its exit code — so the deployment summary
came out empty with nothing in the log to explain it.
- Replace the short-hash warning with a fail(), reporting the same context on stderr
and exiting nonzero
- Place it ahead of the FromCommit print and the ##vso[task.setvariable] line, so no
unusable value is published
This makes the Summarize job fail whenever the GitHub lookup fails for any reason,
including a rate limit or transport error, and Deploy is gated on Summarize
succeeding.
Verified against qa2 that the normal path is unchanged and exits 0. Forced the
failure path with an unreachable API host: the warning and the ERROR line are both
printed, the exit status is 1, and neither FromCommit nor the ##vso line is emitted.1 parent f13092b commit 830aac6
3 files changed
Lines changed: 35 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
| 64 | + | |
| 65 | + | |
59 | 66 | | |
60 | | - | |
| 67 | + | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
64 | | - | |
| 71 | + | |
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
| |||
75 | 82 | | |
76 | 83 | | |
77 | 84 | | |
78 | | - | |
| 85 | + | |
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
| |||
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
99 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
100 | 109 | | |
101 | 110 | | |
102 | 111 | | |
103 | 112 | | |
104 | | - | |
105 | | - | |
| 113 | + | |
| 114 | + | |
106 | 115 | | |
107 | | - | |
108 | | - | |
109 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
110 | 123 | | |
111 | 124 | | |
112 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
113 | 134 | | |
114 | 135 | | |
115 | 136 | | |
| |||
0 commit comments