Files
trainer/pkg
Stefan WangandGitHub c3153f3f63 fix(cache): use status code (not identity) to detect Service AlreadyExists (#3507)
The `cache` dataset initializer compared the exception instance to the
`ConflictError` class using `is`, which is always False:

    except ApiException as e:
        if e is ConflictError:  # always False

`core_v1.create_namespaced_service()` raises a plain `ApiException` with
`status=409`, not a `ConflictError`, so this branch was unreachable. When
the Service already existed (e.g., re-reconcile after a crash between
Service creation and LWS readiness), the code re-raised, fell into the
outer cleanup, and deleted the ServiceAccount — leaving the cache
cluster in a broken state.

Match the pattern used a few lines above for the ServiceAccount and
check `e.status == 409` instead.

Add a unit test that mocks `create_namespaced_service` to raise 409 and
asserts `download_dataset` completes without calling
`delete_namespaced_service_account`.

Signed-off-by: 1fanwang <[email protected]>
2026-06-15 14:58:28 +00:00
..