-
Notifications
You must be signed in to change notification settings - Fork 323
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
Give better error if config entry already created #420
Conversation
e3a313f
to
3201ba5
Compare
e77e247
to
aa22088
Compare
Previously if the config entry already existed in Consul we'd give an error like: config entry managed in different datacenter: "other-dc" This worked well if the config entry had been created by a controller running in another Kube cluster, but if the user had created the config entry directly in Consul then it wouldn't have the datacenter annotation and so the error would actually read: config entry managed in different datacenter: "" Which was confusing. This change changes the error in that case to read: config entry already exists in Consul
aa22088
to
fc7fbf7
Compare
@@ -1843,292 +1843,36 @@ func TestConfigEntryControllers_doesNotCreateUnownedConfigEntry(t *testing.T) { | |||
kubeNS := "default" | |||
|
|||
cases := []struct { | |||
kubeKind string |
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.
I removed the cases for each config entry and instead added cases based on the value of the source-datacenter
metadata since now we expect a different error message if it's empty vs set to something else.
I think it's okay to remove the per-config-entry cases because
- they were testing the same underlying code
- I would need to add config entry x cases permutations to test this new functionality which I think is going to make the tests too complicated
- each config entry has unit tests to ensure it implements the ConfigEntry interface properly (which is all we require to be working here)
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.
Can we add an Asana task to clean up the other tests as well when appropriate? Unless youve done that already :)
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.
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.
🎉
if sourceDatacenter == "" { | ||
return fmt.Errorf("config entry already exists in Consul") | ||
} | ||
return fmt.Errorf("config entry managed in different datacenter: %q", sourceDatacenter) |
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.
NICE!
@@ -1843,292 +1843,36 @@ func TestConfigEntryControllers_doesNotCreateUnownedConfigEntry(t *testing.T) { | |||
kubeNS := "default" | |||
|
|||
cases := []struct { | |||
kubeKind string |
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.
Can we add an Asana task to clean up the other tests as well when appropriate? Unless youve done that already :)
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.
🔥
* server-acl-init-job sets server addresses if 'externalServers.enabled' is true * server-acl-init and server-acl-init-cleanup jobs and their related resources now run either when servers are enabled or when externalServers are enabled * Add new acls.bootstrapToken value for providing your own bootstrap token. * Allow custom auth method configuration * Fail if both server and externalServers are enabled
Previously if the config entry already existed in Consul we'd give an
error like:
This worked well if the config entry had been created by a controller
running in another Kube cluster, but if the user had created the config
entry directly in Consul then it wouldn't have the datacenter annotation
and so the error would actually read:
Which was confusing.
This change changes the error in that case to read:
How I've tested this PR:
How I expect reviewers to test this PR:
Checklist: