#6986 fix: correct TaskAction CR/pod names and namespaces, improve run ID generation
Pull request opened by
AdilFayyaz
Tracking issue
Closes
#6969
Why are the changes needed?
Two bugs were causing TaskActions and pods to be created incorrectly:
1. Wrong names: CR and pod names included an {org}-{project}-{domain} prefix and the root action duplicated the run name, producing names like org-project-domain-runname-runname-0 instead of runname-a0-0.
2. Wrong namespace: TaskActions were created in the flyte namespace instead of the project-scoped {project}-{domain} namespace (e.g. flytetest-development).
Additionally, run IDs were generated with a time-based format (run-<unix_timestamp>) which is not suitable for production use.
What changes were proposed in this pull request?
1. Fixed buildTaskActionName (actions/k8s/client.go): Root actions now produce {runName}-a0-0; child actions produce {runName}-{actionName}-0.
2. Fixed namespace derivation (actions/k8s/client.go): Added buildNamespace which computes {project}-{domain} from the run identifier. All CRUD operations and the watcher now use this namespace. The watcher watches all namespaces.
3. Auto-creates namespaces on demand (actions/k8s/client.go): Enqueue calls an injected ensureNamespace function before creating a TaskAction, so project-scoped namespaces are created automatically.
4. Improved run ID format (runs/service/run_service.go): Run names are now generated as r<19 random chars> using
k8s.io/apimachinery/pkg/util/rand.
5. Single source of run name generation (runs/service/run_service.go, runs/repository/impl/action.go): The service generates the run name once and converts ProjectId → RunId before calling the repository, removing redundant name generation in the repo layer.
6. Moved EnsureNamespaceExists to flytestdlib/k8s (flytestdlib/k8s/namespace.go): Shared utility for idempotent namespace creation, used by both app/k8s.go and actions/setup.go.
How was this patch tested?
Tested end-to-end using the local development setup (make run in manager/). A workflow was submitted via the SDK and verified that:
• TaskAction CRs were created in the correct flytesnacks-development namespace
• CR and pod names matched the expected format ({runName}-a0-0 for root, {runName}-{actionName}-0 for children)
• Run IDs followed the r<19chars> format
Also tested against unit tests:
• actions/k8s/client_test.go — 4 tests
• runs/service/run_service_test.go — 4 tests
•
main
•
#6583
•
#6986 👈
flyteorg/flyte