-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: unexpected behaviour with sync and multiple ws #576
Conversation
When passing to sync multiple files (or a folder) with different _workspace definition, sync merge the files and applies them only to a single workspace. This change makes sync returning an error when attempting a deployment with multiple workspaces.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #576 +/- ##
==========================================
+ Coverage 51.07% 51.15% +0.07%
==========================================
Files 73 73
Lines 7996 8009 +13
==========================================
+ Hits 4084 4097 +13
Misses 3542 3542
Partials 370 370 ☔ View full report in Codecov by Sentry. |
@rainest Do we allow for "workspace" provided via CLI flag and that provided in the state file to differ? |
Current behavior is to print a warning and then proceed, preferring the
This is after I'd synced to the workspace in the manifest, so it failed to create a new one due to path collision. With the new patch, it's rejected regardless:
I think that's what we want, but that said, it looks like the output of the error is a bit off: I'd expect this to print |
What's the content of those files? I can't reproduce it:
|
Nevermind, weird malformed YAML from botched paste behavior strikes again. One had:
It properly detected the duplicate workspaces but then couldn't actually read it due to the leading space on the format. Edge case we don't care about for this, it should be solved with a general failure on any malformed YAML for #578 |
Let me know if any of you have more comments or if this is good to go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge with approval from Travis.
file/validate.go
Outdated
func validateWorkspaces(workspaces []string) error { | ||
utils.RemoveDuplicates(&workspaces) | ||
if len(workspaces) > 1 { | ||
return fmt.Errorf("cannot sync multiple workspaces at the same time: %v", workspaces) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return fmt.Errorf("cannot sync multiple workspaces at the same time: %v", workspaces) | |
return fmt.Errorf("It seems like you are trying to sync multiple workspaces at the same time (%v). decK doesn't support syncing multiple workspaces at the same time, please sync one workspace at a time.", workspaces) |
Use appropriate \ns and maybe add an HTTP link to docs if we have one.
cc @lena-larionova
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc is light on this and needs some improvement, but we do have something: https://docs.konghq.com/deck/1.10.x/guides/kong-enterprise/#workspaces
Preferring what? Whatever it be, we must ensure that behavior is not broken - a user ignoring the warning shouldn't receive an error after this patch. |
Confirming this patch doesn't change that behaviour:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferring the workspace in the flag, whoops.
When passing to sync multiple files (or a folder) with different _workspace definition, sync merge the files and applies them only to a single workspace. This change makes sync returning an error when attempting a deployment with multiple workspaces.
When passing to
sync
multiple files (or a folder) with different_workspace definition, sync merges the files and applies them
only to a single workspace.
This change makes
sync
returning an error when attemptinga deployment with multiple workspaces.