Skip to content

Commit

Permalink
delete all v2 resources type when deleting a namespace (CE) (#18621)
Browse files Browse the repository at this point in the history
* add namespace scope to ServiceV1Alpha1Type

* add CE portion of namespace deletion
  • Loading branch information
dhiaayachi authored Aug 31, 2023
1 parent 255aa15 commit f8d77f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion agent/consul/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"bytes"
"context"
"fmt"
"github.com/hashicorp/consul/internal/catalog"
"github.com/hashicorp/consul/internal/mesh"
"github.com/hashicorp/consul/internal/resource/demo"
"net"
"os"
"strings"
Expand Down Expand Up @@ -559,6 +562,10 @@ func newDefaultDeps(t *testing.T, c *Config) Deps {
RPCHoldTimeout: c.RPCHoldTimeout,
}
connPool.SetRPCClientTimeout(c.RPCClientTimeout)
registry := resource.NewRegistry()
demo.RegisterTypes(registry)
mesh.RegisterTypes(registry)
catalog.RegisterTypes(registry)
return Deps{
EventPublisher: stream.NewEventPublisher(10 * time.Second),
Logger: logger,
Expand All @@ -578,7 +585,7 @@ func newDefaultDeps(t *testing.T, c *Config) Deps {
GetNetRPCInterceptorFunc: middleware.GetNetRPCInterceptor,
EnterpriseDeps: newDefaultDepsEnterprise(t, logger, c),
XDSStreamLimiter: limiter.NewSessionLimiter(),
Registry: resource.NewRegistry(),
Registry: registry,
}
}

Expand Down
3 changes: 3 additions & 0 deletions agent/consul/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ type Server struct {

// handles metrics reporting to HashiCorp
reportingManager *reporting.ReportingManager

registry resource.Registry
}

func (s *Server) DecrementBlockingQueries() uint64 {
Expand Down Expand Up @@ -547,6 +549,7 @@ func NewServer(config *Config, flat Deps, externalGRPCServer *grpc.Server,
publisher: flat.EventPublisher,
incomingRPCLimiter: incomingRPCLimiter,
routineManager: routine.NewManager(logger.Named(logging.ConsulServer)),
registry: flat.Registry,
}
incomingRPCLimiter.Register(s)

Expand Down
1 change: 1 addition & 0 deletions internal/catalog/internal/types/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func RegisterService(r resource.Registry) {
Type: ServiceV1Alpha1Type,
Proto: &pbcatalog.Service{},
Validate: ValidateService,
Scope: resource.ScopeNamespace,
})
}

Expand Down

0 comments on commit f8d77f0

Please sign in to comment.