-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
agent: ensure that we normalize bootstrapped config entries #8547
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
agent: ensure that we normalize bootstrapped config entries | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,8 @@ type configTest struct { | |
func TestBuilder_BuildAndValide_ConfigFlagsAndEdgecases(t *testing.T) { | ||
dataDir := testutil.TempDir(t, "consul") | ||
|
||
defaultEntMeta := structs.DefaultEnterpriseMeta() | ||
|
||
tests := []configTest{ | ||
// ------------------------------------------------------------ | ||
// cmd line flags | ||
|
@@ -3286,32 +3288,28 @@ func TestBuilder_BuildAndValide_ConfigFlagsAndEdgecases(t *testing.T) { | |
err: "config_entries.bootstrap[0]: invalid config entry kind: foo", | ||
}, | ||
{ | ||
desc: "ConfigEntry bootstrap invalid", | ||
desc: "ConfigEntry bootstrap invalid service-defaults", | ||
args: []string{`-data-dir=` + dataDir}, | ||
json: []string{`{ | ||
"config_entries": { | ||
"bootstrap": [ | ||
{ | ||
"kind": "proxy-defaults", | ||
"name": "invalid-name", | ||
"config": { | ||
"foo": "bar" | ||
} | ||
"kind": "service-defaults", | ||
"name": "web", | ||
"made_up_key": "blah" | ||
} | ||
] | ||
} | ||
}`}, | ||
hcl: []string{` | ||
config_entries { | ||
bootstrap { | ||
kind = "proxy-defaults" | ||
name = "invalid-name" | ||
config { | ||
foo = "bar" | ||
} | ||
kind = "service-defaults" | ||
name = "web" | ||
made_up_key = "blah" | ||
} | ||
}`}, | ||
err: "config_entries.bootstrap[0]: invalid name (\"invalid-name\"), only \"global\" is supported", | ||
err: "config_entries.bootstrap[0]: 1 error occurred:\n\t* invalid config key \"made_up_key\"\n\n", | ||
}, | ||
{ | ||
desc: "ConfigEntry bootstrap proxy-defaults (snake-case)", | ||
|
@@ -3355,8 +3353,9 @@ func TestBuilder_BuildAndValide_ConfigFlagsAndEdgecases(t *testing.T) { | |
rt.DataDir = dataDir | ||
rt.ConfigEntryBootstrap = []structs.ConfigEntry{ | ||
&structs.ProxyConfigEntry{ | ||
Kind: structs.ProxyDefaults, | ||
Name: structs.ProxyConfigGlobal, | ||
Kind: structs.ProxyDefaults, | ||
Name: structs.ProxyConfigGlobal, | ||
EnterpriseMeta: *defaultEntMeta, | ||
Config: map[string]interface{}{ | ||
"bar": "abc", | ||
"moreconfig": map[string]interface{}{ | ||
|
@@ -3412,8 +3411,9 @@ func TestBuilder_BuildAndValide_ConfigFlagsAndEdgecases(t *testing.T) { | |
rt.DataDir = dataDir | ||
rt.ConfigEntryBootstrap = []structs.ConfigEntry{ | ||
&structs.ProxyConfigEntry{ | ||
Kind: structs.ProxyDefaults, | ||
Name: structs.ProxyConfigGlobal, | ||
Kind: structs.ProxyDefaults, | ||
Name: structs.ProxyConfigGlobal, | ||
EnterpriseMeta: *defaultEntMeta, | ||
Config: map[string]interface{}{ | ||
"bar": "abc", | ||
"moreconfig": map[string]interface{}{ | ||
|
@@ -3461,10 +3461,11 @@ func TestBuilder_BuildAndValide_ConfigFlagsAndEdgecases(t *testing.T) { | |
rt.DataDir = dataDir | ||
rt.ConfigEntryBootstrap = []structs.ConfigEntry{ | ||
&structs.ServiceConfigEntry{ | ||
Kind: structs.ServiceDefaults, | ||
Name: "web", | ||
Protocol: "http", | ||
ExternalSNI: "abc-123", | ||
Kind: structs.ServiceDefaults, | ||
Name: "web", | ||
EnterpriseMeta: *defaultEntMeta, | ||
Protocol: "http", | ||
ExternalSNI: "abc-123", | ||
MeshGateway: structs.MeshGatewayConfig{ | ||
Mode: structs.MeshGatewayModeRemote, | ||
}, | ||
|
@@ -3506,10 +3507,11 @@ func TestBuilder_BuildAndValide_ConfigFlagsAndEdgecases(t *testing.T) { | |
rt.DataDir = dataDir | ||
rt.ConfigEntryBootstrap = []structs.ConfigEntry{ | ||
&structs.ServiceConfigEntry{ | ||
Kind: structs.ServiceDefaults, | ||
Name: "web", | ||
Protocol: "http", | ||
ExternalSNI: "abc-123", | ||
Kind: structs.ServiceDefaults, | ||
Name: "web", | ||
EnterpriseMeta: *defaultEntMeta, | ||
Protocol: "http", | ||
ExternalSNI: "abc-123", | ||
MeshGateway: structs.MeshGatewayConfig{ | ||
Mode: structs.MeshGatewayModeRemote, | ||
}, | ||
|
@@ -3691,8 +3693,9 @@ func TestBuilder_BuildAndValide_ConfigFlagsAndEdgecases(t *testing.T) { | |
rt.DataDir = dataDir | ||
rt.ConfigEntryBootstrap = []structs.ConfigEntry{ | ||
&structs.ServiceRouterConfigEntry{ | ||
Kind: structs.ServiceRouter, | ||
Name: "main", | ||
Kind: structs.ServiceRouter, | ||
Name: "main", | ||
EnterpriseMeta: *defaultEntMeta, | ||
Routes: []structs.ServiceRoute{ | ||
{ | ||
Match: &structs.ServiceRouteMatch{ | ||
|
@@ -3772,6 +3775,8 @@ func TestBuilder_BuildAndValide_ConfigFlagsAndEdgecases(t *testing.T) { | |
} | ||
}, | ||
}, | ||
// TODO(rb): add in missing tests for ingress-gateway (snake + camel) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed these, but adding them in is outside of the targeted scope of this particular fix. |
||
// TODO(rb): add in missing tests for terminating-gateway (snake + camel) | ||
|
||
/////////////////////////////////// | ||
// Defaults sanity checks | ||
|
@@ -4380,6 +4385,8 @@ func TestFullConfig(t *testing.T) { | |
return n | ||
} | ||
|
||
defaultEntMeta := structs.DefaultEnterpriseMeta() | ||
|
||
flagSrc := []string{`-dev`} | ||
src := map[string]string{ | ||
"json": `{ | ||
|
@@ -5953,8 +5960,9 @@ func TestFullConfig(t *testing.T) { | |
ClientAddrs: []*net.IPAddr{ipAddr("93.83.18.19")}, | ||
ConfigEntryBootstrap: []structs.ConfigEntry{ | ||
&structs.ProxyConfigEntry{ | ||
Kind: structs.ProxyDefaults, | ||
Name: structs.ProxyConfigGlobal, | ||
Kind: structs.ProxyDefaults, | ||
Name: structs.ProxyConfigGlobal, | ||
EnterpriseMeta: *defaultEntMeta, | ||
Config: map[string]interface{}{ | ||
"foo": "bar", | ||
// has to be a float due to being a map[string]interface | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This test had to change because the
Normalize
method forproxy-defaults
always forces theName
field to beglobal