Skip to content

Commit fe02a25

Browse files
committed
fix: support clustered Redis workflow cleanup
1 parent 1376a7d commit fe02a25

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

deployments/charts/osmo/templates/worker.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ spec:
128128
volumeMounts:
129129
- name: osmo-progress-files
130130
mountPath: /var/run/osmo
131+
- name: osmo-runtime-tmp
132+
mountPath: /tmp
131133
{{- if .Values.secrets.masterEncryptionKey.existingSecret.name }}
132134
- mountPath: {{ include "osmo.secrets.mekMountPath" . | quote }}
133135
name: mek-volume
@@ -160,6 +162,8 @@ spec:
160162
volumes:
161163
- name: osmo-progress-files
162164
emptyDir: {}
165+
- name: osmo-runtime-tmp
166+
emptyDir: {}
163167
{{- include "osmo.pod.extraVolumes" .Values.services.worker | nindent 8 }}
164168
{{- include "osmo.secrets.mekVolume" . | nindent 8 }}
165169
{{- include "osmo.configuration.volumes" . | nindent 8 }}

deployments/charts/osmo/tests/test_osmo_charts.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ require_occurrences() {
6969
fail "expected '$expected' $count times in $file, found $actual"
7070
}
7171

72+
require_empty_dir_volume() {
73+
local file=$1
74+
local volume_name=$2
75+
awk -v volume_name="$volume_name" '
76+
$0 == " - name: " volume_name {
77+
getline
78+
if ($0 == " emptyDir: {}") found = 1
79+
}
80+
END { exit !found }
81+
' "$file" || fail "expected emptyDir volume '$volume_name' in $file"
82+
}
83+
7284
require_line_count() {
7385
local file=$1
7486
local expected=$2
@@ -1398,11 +1410,13 @@ EOF
13981410
require_contains "$TEST_DIRECTORY/osmo-$hardened_component.yaml" \
13991411
"readOnlyRootFilesystem: true"
14001412
done
1401-
for hardened_component in api router logger agent; do
1413+
for hardened_component in api worker router logger agent; do
14021414
require_contains "$TEST_DIRECTORY/osmo-$hardened_component.yaml" \
14031415
"mountPath: /tmp"
14041416
require_contains "$TEST_DIRECTORY/osmo-$hardened_component.yaml" \
14051417
"name: osmo-runtime-tmp"
1418+
require_empty_dir_volume "$TEST_DIRECTORY/osmo-$hardened_component.yaml" \
1419+
"osmo-runtime-tmp"
14061420
done
14071421
for hardened_component in worker logger agent delayed-job-monitor; do
14081422
require_contains "$TEST_DIRECTORY/osmo-$hardened_component.yaml" \

src/utils/job/jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ def _notify_barrier(self, database, redis_client, total_timeout: int):
12681268
retry_ids = task.Task.batch_fetch_latest_retry_ids(
12691269
database, self.workflow_id, task_names)
12701270

1271-
pipe = redis_client.pipeline()
1271+
pipe = redis_client.pipeline(transaction=False)
12721272
pipe.set(action_key, json.dumps(attributes))
12731273
pipe.expire(action_key, total_timeout, nx=True)
12741274

@@ -1441,7 +1441,7 @@ def execute(self, context: JobExecutionContext,
14411441

14421442
redis_client = redis.from_url(workflow_obj.logs)
14431443

1444-
redis_batch_pipeline = redis_client.pipeline()
1444+
redis_batch_pipeline = redis_client.pipeline(transaction=False)
14451445

14461446
if workflow_obj.status.failed():
14471447
start_delimiter = '\n' + '-' * 100 + '\n'

src/utils/job/tests/test_jobs_pure.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def test_when_enough_members_in_barrier_emits_notifications(self):
372372
mock.patch.object(task.Task, 'batch_fetch_latest_retry_ids',
373373
return_value={'t1': 0, 't2': 0}):
374374
ug._notify_barrier(database, client, total_timeout=60)
375+
client.pipeline.assert_called_once_with(transaction=False)
375376
pipe.execute.assert_called_once()
376377
# Two members should each lpush once.
377378
self.assertEqual(pipe.lpush.call_count, 2)
@@ -1923,6 +1924,7 @@ def test_full_execute_with_credential_calls_storage_upload(self):
19231924
new=mock.AsyncMock(return_value=mock.Mock())):
19241925
result = cw.execute(ctx, progress_writer)
19251926
self.assertIsInstance(result, jobs_base.JobResult)
1927+
redis_client.pipeline.assert_called_once_with(transaction=False)
19261928
# Update logs called for both logs and events
19271929
wf.update_log_to_db.assert_called_once()
19281930
wf.update_events_to_db.assert_called_once()

0 commit comments

Comments
 (0)