Deck bug: deck quits with an error during sync when the workspace does not exists
- Dominant language
- Go
- Stars
- 503
- Forks
- 137
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 20
Description
Hi,
When we are trying to sync a new workspace the first time (for example promoting it from staging to production), the deck sync exists with an error, saying:
```
creating workspace testworkspace
Error: building state: creating defaulter: get defaults for routes: retrieve schema for routes from Kong:
HTTP status 404
message: "Workspace 'testworkspace' not found"
Error: Process completed with exit code 1.
```
What makes it even more strange is that deck actually creates the new workspace, but instead of continuing syncing the config it exists with this error.
If you run deck one more time it works as it should and syncs the configuration, since the 1st run created the new empty workspace.
Obviously this two step should be happening in a single deck run, to avoid breaking the deployment automation.
My personal suspicion is that the sync sends the create workspace request to the API first, but does not wait until the actual creation of the new workspace finishes, instead of that it immediately continues with the sync, and the config sync fails because the API returns the workspace not existing error, since it's still under creation.
I got the above suspicion based on the fact that the issue is not always reproducible, it is based on the network response time between the Kong admin API and deck. If deck is "too quick" then the error occurs, if deck is "slow" (like running deck in the EU against a Kong API deployed in Australia) then the issue is not happening, because Kong has enough time to create the new workspace.
Thanks for looking into it.
Our env:
Kong Gateway Enteprise 3.1.1.3 - Hybrid
Deck v1.15.1 (I know it's a bit old, but I did not see anything related in the changelog for the newer versions)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing a sync that creates a new workspace against the Kong Admin API, then observe the workspace-creation request and the subsequent configuration sync. The fix is complete when a single decK run creates the workspace and continues syncing successfully, including under slower or faster network conditions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100