gowalk-cicd 1.0.228 → 1.0.229

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.
@@ -12,6 +12,7 @@ from health_rollout_engine import Engine, MARKER, healthy, probe, unshared
12
12
  from health_rollout_spec import ROLES, receipt, scope, specification, unchanged, verified
13
13
  from runtime_host import host_enabled, start_lock
14
14
  from runtime_launch import START_LOCK
15
+ from runtime_lifecycle import require_active
15
16
  from runtime_readback import profile
16
17
 
17
18
 
@@ -20,6 +21,7 @@ def allowed(app, service, identifier, image):
20
21
  or not re.fullmatch('[a-f0-9]{64}', identifier) or not re.fullmatch('sha256:[a-f0-9]{64}', image)):
21
22
  raise ValueError('rollout_scope_invalid')
22
23
  host_enabled()
24
+ require_active(app)
23
25
  document = profile(app)
24
26
  if document is not None:
25
27
  value = json.loads(document)
@@ -11,6 +11,7 @@ import re
11
11
  import stat
12
12
  import sys
13
13
  import tempfile
14
+ import time
14
15
  from pathlib import Path
15
16
 
16
17
  from identity_diagnostics import ReaderFailure, bounded
@@ -22,6 +23,7 @@ ROOT_UID = 0
22
23
  SCHEMA = 'gowalk-cicd/backend-lifecycle.v1'
23
24
  RESULT = 'gowalk-cicd/backend-lifecycle-result.v1'
24
25
  MAX_GENERATION = 9007199254740991
26
+ WORK_SECONDS = 180
25
27
  CODES = frozenset({'invalid_scope', 'state_invalid', 'owner_refused', 'host_disabled',
26
28
  'stale_generation', 'generation_conflict', 'native_runtime_unsupported',
27
29
  'container_scope_mismatch', 'container_inventory_invalid', 'runtime_changed',
@@ -116,17 +118,24 @@ def valid_restart(row):
116
118
  and (row['restart'] == 'on-failure' or row['retry'] == 0))
117
119
 
118
120
 
119
- def inventory(project, app_root):
120
- identifiers = bounded(['docker', 'ps', '--all', '--no-trunc', '--filter',
121
+ def run(arguments, seconds, deadline):
122
+ remaining = deadline - time.monotonic()
123
+ if remaining <= 0:
124
+ raise ReaderFailure('command_timeout')
125
+ return bounded(arguments, seconds=min(seconds, remaining))
126
+
127
+
128
+ def inventory(project, app_root, deadline):
129
+ identifiers = run(['docker', 'ps', '--all', '--no-trunc', '--filter',
121
130
  'label=com.docker.compose.project=' + project,
122
- '--format', '{{.ID}}'], seconds=15).decode().splitlines()
131
+ '--format', '{{.ID}}'], 15, deadline).decode().splitlines()
123
132
  if (len(identifiers) > 32 or len(set(identifiers)) != len(identifiers)
124
133
  or any(not re.fullmatch('[0-9a-f]{64}', value) for value in identifiers)):
125
134
  raise ValueError('container_inventory_invalid')
126
135
  if not identifiers:
127
136
  return []
128
- rows = [json.loads(line) for line in bounded(
129
- ['docker', 'inspect', '--format', INSPECT, *identifiers], seconds=15).splitlines()]
137
+ rows = [json.loads(line) for line in run(
138
+ ['docker', 'inspect', '--format', INSPECT, *identifiers], 15, deadline).splitlines()]
130
139
  if sorted(row['id'] for row in rows) != sorted(identifiers):
131
140
  raise ValueError('runtime_changed')
132
141
  for row in rows:
@@ -139,11 +148,11 @@ def inventory(project, app_root):
139
148
  return sorted(rows, key=lambda row: row['id'])
140
149
 
141
150
 
142
- def restore(project, app_root, previous):
151
+ def restore(project, app_root, previous, deadline):
143
152
  """Restore our exact containers' policies; never replace an operator's changed policy."""
144
153
  saved = {row['id']: row for row in previous['restarts']}
145
154
  expected = {}
146
- for row in inventory(project, app_root):
155
+ for row in inventory(project, app_root, deadline):
147
156
  original = saved.get(row['id'])
148
157
  if original is None:
149
158
  continue
@@ -154,9 +163,9 @@ def restore(project, app_root, previous):
154
163
  policy = original['restart'] or 'no'
155
164
  if policy == 'on-failure' and original['retry']:
156
165
  policy += ':' + str(original['retry'])
157
- bounded(['docker', 'update', '--restart=' + policy, row['id']], seconds=30)
166
+ run(['docker', 'update', '--restart=' + policy, row['id']], 30, deadline)
158
167
  expected[row['id']] = (original['restart'] or 'no', original['retry'])
159
- observed = {row['id']: row for row in inventory(project, app_root)}
168
+ observed = {row['id']: row for row in inventory(project, app_root, deadline)}
160
169
  for identifier, policy in expected.items():
161
170
  row = observed.get(identifier)
162
171
  if row is None or (row['restart'], row['retry']) != policy:
@@ -168,6 +177,7 @@ def apply(project, generation, state, owner):
168
177
 
169
178
  scope(project, generation, state)
170
179
  with start_lock(START_LOCK):
180
+ deadline = time.monotonic() + WORK_SECONDS
171
181
  policy = ssh_gate.load_policy(owner)
172
182
  if policy['disabled']:
173
183
  raise ValueError('host_disabled')
@@ -191,7 +201,7 @@ def apply(project, generation, state, owner):
191
201
  'generation': generation, 'state': state, 'restarts': []}
192
202
  stopped = 0
193
203
  if state == 'suspended':
194
- rows = inventory(project, ssh_gate.APPS)
204
+ rows = inventory(project, ssh_gate.APPS, deadline)
195
205
  saved = {row['id']: row for row in (previous or {}).get('restarts', [])}
196
206
  for row in rows:
197
207
  original = saved.get(row['id'])
@@ -203,22 +213,22 @@ def apply(project, generation, state, owner):
203
213
  identifiers = [row['id'] for row in rows]
204
214
  if identifiers:
205
215
  # Manual stop alone does not survive a daemon restart with policy=always.
206
- bounded(['docker', 'update', '--restart=no', *identifiers], seconds=30)
207
- current = inventory(project, ssh_gate.APPS)
216
+ run(['docker', 'update', '--restart=no', *identifiers], 30, deadline)
217
+ current = inventory(project, ssh_gate.APPS, deadline)
208
218
  if ([row['id'] for row in current] != identifiers
209
219
  or any(row['restart'] != 'no' for row in current)):
210
220
  raise ValueError('runtime_changed')
211
221
  running = [row['id'] for row in current if row['running']]
212
222
  if running:
213
- bounded(['docker', 'stop', '--time', '30', *running], seconds=90)
223
+ run(['docker', 'stop', '--time', '30', *running], 90, deadline)
214
224
  stopped = len(running)
215
- current = inventory(project, ssh_gate.APPS)
225
+ current = inventory(project, ssh_gate.APPS, deadline)
216
226
  if ([row['id'] for row in current] != identifiers
217
227
  or any(row['running'] or row['restart'] != 'no' for row in current)):
218
228
  raise ValueError('runtime_not_stopped')
219
229
  else:
220
230
  if previous and previous['state'] == 'suspended':
221
- restore(project, ssh_gate.APPS, previous)
231
+ restore(project, ssh_gate.APPS, previous, deadline)
222
232
  if value != previous:
223
233
  write(value)
224
234
  return {'schema': RESULT, 'ok': True, 'project': project, 'generation': generation,
@@ -61,7 +61,7 @@ Failures emit only `backend_ssh_refused`, never the original command or private
61
61
 
62
62
  ## Archive lifecycle
63
63
 
64
- From host runtime 1.0.228, the existing owner key may suspend its registered Docker project with
64
+ From host runtime 1.0.229, the existing owner key may suspend its registered Docker project with
65
65
  `gowalk-backend lifecycle <project> <generation> suspended`. The generation is the panel's durable,
66
66
  strictly increasing integer (1 through 9007199254740991) for each desired-state change. The panel,
67
67
  not this host transport, verifies archive policy and Apple production-approval history before sending it.
@@ -78,6 +78,10 @@ using our `restart=no`, verifies the restoration, then clears this archive fence
78
78
  container or replaces a later operator-changed policy or an operator-disabled runtime profile. Native profiles explicitly refuse
79
79
  with `native_runtime_unsupported`; their units are never inferred from Docker naming.
80
80
 
81
+ Lifecycle commands share a 180-second work deadline after the existing 120-second start-lock
82
+ admission. Partial work remains journaled and replayable; a 330-second client transport bound leaves
83
+ room for cleanup and the fixed result. This does not add a wait to successful commands.
84
+
81
85
  The fixed JSON success receipt is `schema=gowalk-cicd/backend-lifecycle-result.v1`, `ok=true`,
82
86
  `project`, `generation`, `state`, and integer `containers_stopped`. Zero means there was nothing
83
87
  running to stop on that successful read, including an exact replay. A failure contains only the same
@@ -85,7 +89,7 @@ schema, `ok=false` and a fixed `code`; a gate-level refusal retains `backend_ssh
85
89
  No environment, application output or other project's inventory leaves the host.
86
90
 
87
91
  While suspended, the gate refuses source/configuration writes and deployments but retains lifecycle
88
- and diagnostic reads. Both Compose and native launchers check the fence again under the start lock,
92
+ and diagnostic reads. Compose, native and operator health-cache rollout launchers check the fence again under the start lock,
89
93
  so a build that began before suspension cannot start afterward. Installing the new runtime cannot
90
94
  change already running older helper processes: drain those before the first lifecycle request (the
91
95
  existing global deployment freeze may be used during that adoption). Installation alone neither
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gowalk-cicd",
3
- "version": "1.0.228",
3
+ "version": "1.0.229",
4
4
  "description": "Zero-config GitHub Actions delivery for iOS TestFlight and Android Google Play.",
5
5
  "type": "module",
6
6
  "bin": {