Skip to content

fix: resolve race condition causing false domain-already-taken on app edit#739

Open
JamesSprow wants to merge 5 commits intokubero-dev:mainfrom
JamesSprow:fix/domain-already-taken-race-condition
Open

fix: resolve race condition causing false domain-already-taken on app edit#739
JamesSprow wants to merge 5 commits intokubero-dev:mainfrom
JamesSprow:fix/domain-already-taken-race-condition

Conversation

@JamesSprow
Copy link
Copy Markdown

Summary

Fixes #738

Problem: Editing any existing Kubero app shows "domain already taken" and Save is disabled, even though the domain belongs to the app being edited.

Root cause: Race condition in mounted(). getDomains() and loadPipelineAndApp() run concurrently via Promise.all. Inside loadPipelineAndApp(), loadApp() was not awaited, so getDomains() resolved first with this.ingress.hosts still empty — the app's own domain was never excluded from takenDomains.

whiteListDomains() also had a splice-while-iterating bug that made it unreliable even when called in the right order.

Changes

  • loadApp() — made async, returns the promise
  • loadPipelineAndApp() — now awaits loadApp() so this.ingress.hosts is populated before getDomains() / whiteListDomains() runs
  • whiteListDomains() — replaced mutating splice loop with Set + filter (no more index drift bug)
  • Removed the now-redundant whiteListDomains() call inside loadApp() itself (it was already handled in getDomains())

Test plan

  • Create an app with a custom domain
  • Navigate to edit that app — Save should be enabled and domain should not be flagged as taken
  • Create two apps with different domains — editing either should not flag the other as taken on the same form
  • New-app flow: all existing domains should still be correctly flagged as taken

…pp edit

In mounted(), getDomains() and loadPipelineAndApp() ran concurrently.
loadApp() inside loadPipelineAndApp() was not awaited, so getDomains()
resolved first with this.ingress.hosts still empty — the app's own
domain was never whitelisted from takenDomains.

- Make loadApp() async and return the promise
- Await loadApp() inside loadPipelineAndApp() before getDomains() runs
- Fix whiteListDomains() splice-while-iterating bug by using Set + filter

Fixes kubero-dev#738
…in save

For docker-strategy pipelines, pipelineData.git.repository is undefined.
updateApp() and createApp() both accessed .ssh_url on it unconditionally,
throwing a TypeError that was silently swallowed by the catch block —
causing Save to appear to work but make no network request.

Also guarded postdata.image.run.securityContext before typeof checks for
apps where securityContext is absent from the spec.

Refs kubero-dev#738
…y-taken

getDomains() was in the Promise.all alongside loadPipelineAndApp(), so it
could resolve and call whiteListDomains() before loadApp() had populated
this.ingress.hosts — meaning the app's own domain was never whitelisted.

Moving getDomains() to run sequentially after the parallel block ensures
this.ingress.hosts is always populated when whiteListDomains() runs.

Refs kubero-dev#738
Apps without TLS have ingress.tls=undefined after loadApp() overwrites
the initial empty array. setSSL() checked tls?.length==0 which doesn't
catch undefined, so tls[0] crashed. Also guarded the sslIndex population
loop in loadApp() with optional chaining.

Refs kubero-dev#738
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition in form.vue causes "domain already taken" error when editing existing apps

1 participant