Spaces:
Running
Running
Accept absent runtime SHA only for fully paused ORCID Worker
Browse files- orcid_maintenance_regression.py +12 -0
- tools/orcid_rebind.py +3 -1
orcid_maintenance_regression.py
CHANGED
|
@@ -61,6 +61,18 @@ class MaintenanceChecks(unittest.TestCase):
|
|
| 61 |
with self.assertRaisesRegex(ValueError, 'dirty'):
|
| 62 |
confirm_local_isolation('b' * 40)
|
| 63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
if __name__ == '__main__':
|
| 66 |
unittest.main()
|
|
|
|
| 61 |
with self.assertRaisesRegex(ValueError, 'dirty'):
|
| 62 |
confirm_local_isolation('b' * 40)
|
| 63 |
|
| 64 |
+
def test_paused_worker_may_have_no_runtime_sha(self):
|
| 65 |
+
api = Mock()
|
| 66 |
+
frontend = SimpleNamespace(sha='b' * 40, runtime={'sha': 'b' * 40, 'stage': 'RUNNING', 'devMode': False})
|
| 67 |
+
worker = SimpleNamespace(sha='c' * 40, runtime={'stage': 'PAUSED', 'devMode': False})
|
| 68 |
+
with patch.dict(os.environ, {'ORCID_REBIND_MAINTENANCE': 'false'}):
|
| 69 |
+
api.space_info.side_effect = [frontend, worker]
|
| 70 |
+
self.assertEqual(maintenance_versions(api, 'frontend', 'worker', True)['worker_commit'], 'c' * 40)
|
| 71 |
+
worker.runtime['sha'] = 'd' * 40
|
| 72 |
+
api.space_info.side_effect = [frontend, worker]
|
| 73 |
+
with self.assertRaises(ValueError):
|
| 74 |
+
maintenance_versions(api, 'frontend', 'worker', True)
|
| 75 |
+
|
| 76 |
|
| 77 |
if __name__ == '__main__':
|
| 78 |
unittest.main()
|
tools/orcid_rebind.py
CHANGED
|
@@ -211,7 +211,9 @@ def maintenance_versions(api, frontend_space, worker_space, confirmed):
|
|
| 211 |
controlled_frontend = label == 'frontend' and enabled()
|
| 212 |
if controlled_frontend:
|
| 213 |
confirm_local_isolation(info.sha)
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
or not re.fullmatch(r'[0-9a-f]{40}', info.sha or '')):
|
| 216 |
raise ValueError('Space version, stage or Dev Mode is not ready: ' + label)
|
| 217 |
result[label + '_commit'] = info.sha
|
|
|
|
| 211 |
controlled_frontend = label == 'frontend' and enabled()
|
| 212 |
if controlled_frontend:
|
| 213 |
confirm_local_isolation(info.sha)
|
| 214 |
+
stopped_worker = label == 'worker' and runtime.get('stage') == 'PAUSED' and runtime.get('sha') is None
|
| 215 |
+
if (runtime.get('stage') != stage or runtime.get('devMode') and not controlled_frontend
|
| 216 |
+
or not stopped_worker and runtime.get('sha') != info.sha
|
| 217 |
or not re.fullmatch(r'[0-9a-f]{40}', info.sha or '')):
|
| 218 |
raise ValueError('Space version, stage or Dev Mode is not ready: ' + label)
|
| 219 |
result[label + '_commit'] = info.sha
|