Skip to content
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

Stub Config Entries for Consul Native API Gateway #15644

Merged
merged 44 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
98f4e64
Add empty InlineCertificate struct and protobuf
Dec 1, 2022
54e6e00
apigateway stubs
sarahalsmiller Dec 5, 2022
4ceb7e3
new files
sarahalsmiller Dec 6, 2022
aaaa46f
Stub HTTPRoute in api pkg
nathancoleman Dec 6, 2022
62bf00f
checkpoint
sarahalsmiller Dec 6, 2022
024b99d
Stub HTTPRoute in structs pkg
nathancoleman Dec 6, 2022
b17c9db
Simplify api.APIGatewayConfigEntry to be consistent w/ other entries
nathancoleman Dec 6, 2022
682766d
Update makeConfigEntry switch, add docstring for HTTPRouteConfigEntry
nathancoleman Dec 6, 2022
277102d
merge conflicts
sarahalsmiller Dec 6, 2022
7f26173
Add TCPRoute to MakeConfigEntry, return unique Kind
nathancoleman Dec 6, 2022
e5c54d1
merge
sarahalsmiller Dec 6, 2022
c476b22
merge
sarahalsmiller Dec 6, 2022
4d8e5b3
proto generated files
sarahalsmiller Dec 6, 2022
b70176f
Stub BoundAPIGatewayConfigEntry in agent
nathancoleman Dec 6, 2022
207b387
Add RaftIndex to APIGatewayConfigEntry stub
nathancoleman Dec 6, 2022
d7bb1a3
Add new config entry kinds to validation allow-list
nathancoleman Dec 6, 2022
2cd7326
Add RaftIndex to other added config entry stubs
nathancoleman Dec 6, 2022
8c3a10d
fix panic
sarahalsmiller Dec 6, 2022
b387152
merge
sarahalsmiller Dec 6, 2022
af7f28d
Update usage metrics assertions to include new cfg entries
nathancoleman Dec 6, 2022
c52f5c0
Merge branch 'main' into stub-apigw-config-entries
Dec 6, 2022
c7c21b5
Regenerate proto w/ Go 1.19
nathancoleman Dec 6, 2022
6de0525
Run buf formatter on config_entry.proto
nathancoleman Dec 6, 2022
ef5bdc8
Merge branch 'main' into stub-apigw-config-entries
nathancoleman Dec 9, 2022
73bd941
Add Meta and acl.EnterpriseMeta to all new ConfigEntry types
nathancoleman Dec 9, 2022
3b42fca
Remove optional interface method Warnings() for now
nathancoleman Dec 9, 2022
e0c7e31
Remove unnecessary Services field from added config entry types
nathancoleman Dec 9, 2022
d8980be
Implement GetMeta(), GetEnterpriseMeta() for added config entry types
nathancoleman Dec 9, 2022
a30cb2a
Add meta field to proto, name consistently w/ existing config entries
nathancoleman Dec 9, 2022
31d6e64
Format config_entry.proto
nathancoleman Dec 9, 2022
d0428d0
Add initial implementation of CanRead + CanWrite for new config entry…
nathancoleman Dec 9, 2022
8b169da
Add unit tests for decoding of new config entry types
nathancoleman Dec 12, 2022
99e58cf
Add unit tests for parsing of new config entry types
nathancoleman Dec 12, 2022
5edf6b5
Add unit tests for API Gateway config entry ACLs
nathancoleman Dec 12, 2022
39e9d70
Return typed PermissionDeniedError on BoundAPIGateway CanWrite
nathancoleman Dec 13, 2022
10a6ff8
Add unit tests for added config entry ACLs
nathancoleman Dec 13, 2022
7325716
Add BoundAPIGateway type to AllConfigEntryKinds
nathancoleman Dec 13, 2022
f57948c
Return proper kind from BoundAPIGateway
nathancoleman Dec 13, 2022
2115905
Add docstrings for new config entry types
nathancoleman Dec 13, 2022
4bfce61
Add missing config entry kinds to proto def
nathancoleman Dec 13, 2022
fb7ee99
Merge branch 'native-api-gateway' into stub-apigw-config-entries
nathancoleman Dec 13, 2022
d42f8d8
Update usagemetrics_oss_test.go
nathancoleman Dec 13, 2022
5c6b79a
Use utility func for returning PermissionDeniedError
nathancoleman Dec 13, 2022
675a834
Add BoundAPIGateway to proto def
nathancoleman Dec 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acl/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type PermissionDeniedError struct {
Accessor string
// Resource (e.g. Service)
Resource Resource
// Access leve (e.g. Read)
// Access level (e.g. Read)
AccessLevel AccessLevel
// e.g. "sidecar-proxy-1"
ResourceID ResourceDescriptor
Expand Down
5 changes: 5 additions & 0 deletions agent/consul/state/config_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@ func validateProposedConfigEntryInGraph(
case structs.ServiceIntentions:
case structs.MeshConfig:
case structs.ExportedServices:
case structs.APIGateway: // TODO Consider checkGatewayClash
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved
case structs.BoundAPIGateway:
case structs.InlineCertificate:
case structs.HTTPRoute:
case structs.TCPRoute:
default:
return fmt.Errorf("unhandled kind %q during validation of %q", kindName.Kind, kindName.Name)
}
Expand Down
160 changes: 160 additions & 0 deletions agent/consul/usagemetrics/usagemetrics_oss_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,86 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "exported-services"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=api-gateway": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "api-gateway"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=api-gateway": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "api-gateway"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=bound-api-gateway": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "bound-api-gateway"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=bound-api-gateway": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "bound-api-gateway"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=inline-certificate": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "inline-certificate"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=inline-certificate": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "inline-certificate"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=http-route": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "http-route"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=http-route": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "http-route"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=tcp-route": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "tcp-route"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=tcp-route": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "tcp-route"},
},
},
},
getMembersFunc: func() []serf.Member { return []serf.Member{} },
},
Expand Down Expand Up @@ -690,6 +770,86 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "exported-services"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=api-gateway": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "api-gateway"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=api-gateway": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "api-gateway"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=bound-api-gateway": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "bound-api-gateway"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=bound-api-gateway": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "bound-api-gateway"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=inline-certificate": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "inline-certificate"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=inline-certificate": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "inline-certificate"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=http-route": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "http-route"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=http-route": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "http-route"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=tcp-route": { // Legacy
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "tcp-route"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=tcp-route": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "tcp-route"},
},
},
},
},
}
Expand Down
20 changes: 20 additions & 0 deletions agent/structs/config_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const (
ServiceIntentions string = "service-intentions"
MeshConfig string = "mesh"
ExportedServices string = "exported-services"
APIGateway string = "api-gateway"
BoundAPIGateway string = "bound-api-gateway"
InlineCertificate string = "inline-certificate"
HTTPRoute string = "http-route"
TCPRoute string = "tcp-route"

ProxyConfigGlobal string = "global"
MeshConfigMesh string = "mesh"
Expand All @@ -54,6 +59,11 @@ var AllConfigEntryKinds = []string{
ServiceIntentions,
MeshConfig,
ExportedServices,
APIGateway,
nathancoleman marked this conversation as resolved.
Show resolved Hide resolved
BoundAPIGateway,
HTTPRoute,
TCPRoute,
InlineCertificate,
}

// ConfigEntry is the interface for centralized configuration stored in Raft.
Expand Down Expand Up @@ -659,6 +669,16 @@ func MakeConfigEntry(kind, name string) (ConfigEntry, error) {
return &MeshConfigEntry{}, nil
case ExportedServices:
return &ExportedServicesConfigEntry{Name: name}, nil
case APIGateway:
return &APIGatewayConfigEntry{Name: name}, nil
case BoundAPIGateway:
return &BoundAPIGatewayConfigEntry{Name: name}, nil
case InlineCertificate:
return &InlineCertificateConfigEntry{Name: name}, nil
case HTTPRoute:
return &HTTPRouteConfigEntry{Name: name}, nil
case TCPRoute:
return &TCPRouteConfigEntry{Name: name}, nil
default:
return nil, fmt.Errorf("invalid config entry kind: %s", kind)
}
Expand Down
Loading