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

Store namespaces in DELETED state in registry #2665

Merged
merged 2 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion common/namespace/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,10 @@ func (r *registry) refreshNamespaces(ctx context.Context) error {
}
namespaceNotificationVersion := metadata.NotificationVersion

request := &persistence.ListNamespacesRequest{PageSize: CacheRefreshPageSize}
request := &persistence.ListNamespacesRequest{
PageSize: CacheRefreshPageSize,
IncludeDeleted: true,
}
var namespacesDb Namespaces
namespaceIDsDb := make(map[ID]struct{})

Expand Down
62 changes: 37 additions & 25 deletions common/namespace/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
enumspb "go.temporal.io/api/enums/v1"
namespacepb "go.temporal.io/api/namespace/v1"
"go.temporal.io/api/serviceerror"

Expand Down Expand Up @@ -85,9 +86,10 @@ func (s *registrySuite) TestListNamespace() {
namespaceRecord1 := &persistence.GetNamespaceResponse{
Namespace: &persistencespb.NamespaceDetail{
Info: &persistencespb.NamespaceInfo{
Id: namespace.NewID().String(),
Name: "some random namespace name",
Data: make(map[string]string)},
Id: namespace.NewID().String(),
Name: "some random namespace name",
State: enumspb.NAMESPACE_STATE_REGISTERED,
Data: make(map[string]string)},
Config: &persistencespb.NamespaceConfig{
Retention: timestamp.DurationFromDays(1),
BadBinaries: &namespacepb.BadBinaries{
Expand All @@ -110,9 +112,10 @@ func (s *registrySuite) TestListNamespace() {
namespaceRecord2 := &persistence.GetNamespaceResponse{
Namespace: &persistencespb.NamespaceDetail{
Info: &persistencespb.NamespaceInfo{
Id: namespace.NewID().String(),
Name: "another random namespace name",
Data: make(map[string]string)},
Id: namespace.NewID().String(),
Name: "another random namespace name",
State: enumspb.NAMESPACE_STATE_DELETED, // Still must be included.
Data: make(map[string]string)},
Config: &persistencespb.NamespaceConfig{
Retention: timestamp.DurationFromDays(2),
BadBinaries: &namespacepb.BadBinaries{
Expand All @@ -135,9 +138,10 @@ func (s *registrySuite) TestListNamespace() {
namespaceRecord3 := &persistence.GetNamespaceResponse{
Namespace: &persistencespb.NamespaceDetail{
Info: &persistencespb.NamespaceInfo{
Id: namespace.NewID().String(),
Name: "yet another random namespace name",
Data: make(map[string]string)},
Id: namespace.NewID().String(),
Name: "yet another random namespace name",
State: enumspb.NAMESPACE_STATE_DEPRECATED, // Still must be included.
Data: make(map[string]string)},
Config: &persistencespb.NamespaceConfig{
Retention: timestamp.DurationFromDays(3),
BadBinaries: &namespacepb.BadBinaries{
Expand Down Expand Up @@ -165,16 +169,18 @@ func (s *registrySuite) TestListNamespace() {
NotificationVersion: namespaceNotificationVersion,
}, nil)
s.regPersistence.EXPECT().ListNamespaces(gomock.Any(), &persistence.ListNamespacesRequest{
PageSize: namespace.CacheRefreshPageSize,
NextPageToken: nil,
PageSize: namespace.CacheRefreshPageSize,
IncludeDeleted: true,
NextPageToken: nil,
}).Return(&persistence.ListNamespacesResponse{
Namespaces: []*persistence.GetNamespaceResponse{namespaceRecord1},
NextPageToken: pageToken,
}, nil)

s.regPersistence.EXPECT().ListNamespaces(gomock.Any(), &persistence.ListNamespacesRequest{
PageSize: namespace.CacheRefreshPageSize,
NextPageToken: pageToken,
PageSize: namespace.CacheRefreshPageSize,
IncludeDeleted: true,
NextPageToken: pageToken,
}).Return(&persistence.ListNamespacesResponse{
Namespaces: []*persistence.GetNamespaceResponse{
namespaceRecord2,
Expand Down Expand Up @@ -262,8 +268,9 @@ func (s *registrySuite) TestRegisterCallback_CatchUp() {
NotificationVersion: namespaceNotificationVersion,
}, nil)
s.regPersistence.EXPECT().ListNamespaces(gomock.Any(), &persistence.ListNamespacesRequest{
PageSize: namespace.CacheRefreshPageSize,
NextPageToken: nil,
PageSize: namespace.CacheRefreshPageSize,
IncludeDeleted: true,
NextPageToken: nil,
}).Return(&persistence.ListNamespacesResponse{
Namespaces: []*persistence.GetNamespaceResponse{
namespaceRecord1,
Expand Down Expand Up @@ -360,8 +367,9 @@ func (s *registrySuite) TestUpdateCache_TriggerCallBack() {
NotificationVersion: namespaceNotificationVersion,
}, nil)
s.regPersistence.EXPECT().ListNamespaces(gomock.Any(), &persistence.ListNamespacesRequest{
PageSize: namespace.CacheRefreshPageSize,
NextPageToken: nil,
PageSize: namespace.CacheRefreshPageSize,
IncludeDeleted: true,
NextPageToken: nil,
}).Return(&persistence.ListNamespacesResponse{
Namespaces: []*persistence.GetNamespaceResponse{namespaceRecord1Old, namespaceRecord2Old},
NextPageToken: nil,
Expand Down Expand Up @@ -439,8 +447,9 @@ func (s *registrySuite) TestUpdateCache_TriggerCallBack() {
NotificationVersion: namespaceNotificationVersion,
}, nil)
s.regPersistence.EXPECT().ListNamespaces(gomock.Any(), &persistence.ListNamespacesRequest{
PageSize: namespace.CacheRefreshPageSize,
NextPageToken: nil,
PageSize: namespace.CacheRefreshPageSize,
IncludeDeleted: true,
NextPageToken: nil,
}).Return(&persistence.ListNamespacesResponse{
Namespaces: []*persistence.GetNamespaceResponse{
namespaceRecord1New,
Expand Down Expand Up @@ -488,8 +497,9 @@ func (s *registrySuite) TestGetTriggerListAndUpdateCache_ConcurrentAccess() {
entryOld := namespace.FromPersistentState(namespaceRecordOld)

s.regPersistence.EXPECT().ListNamespaces(gomock.Any(), &persistence.ListNamespacesRequest{
PageSize: namespace.CacheRefreshPageSize,
NextPageToken: nil,
PageSize: namespace.CacheRefreshPageSize,
IncludeDeleted: true,
NextPageToken: nil,
}).Return(&persistence.ListNamespacesResponse{
Namespaces: []*persistence.GetNamespaceResponse{namespaceRecordOld},
NextPageToken: nil,
Expand Down Expand Up @@ -588,8 +598,9 @@ func (s *registrySuite) TestRemoveDeletedNamespace() {
NotificationVersion: namespaceNotificationVersion,
}, nil)
s.regPersistence.EXPECT().ListNamespaces(gomock.Any(), &persistence.ListNamespacesRequest{
PageSize: namespace.CacheRefreshPageSize,
NextPageToken: nil,
PageSize: namespace.CacheRefreshPageSize,
IncludeDeleted: true,
NextPageToken: nil,
}).Return(&persistence.ListNamespacesResponse{
Namespaces: []*persistence.GetNamespaceResponse{
namespaceRecord1,
Expand All @@ -606,8 +617,9 @@ func (s *registrySuite) TestRemoveDeletedNamespace() {
NotificationVersion: namespaceNotificationVersion,
}, nil)
s.regPersistence.EXPECT().ListNamespaces(gomock.Any(), &persistence.ListNamespacesRequest{
PageSize: namespace.CacheRefreshPageSize,
NextPageToken: nil,
PageSize: namespace.CacheRefreshPageSize,
IncludeDeleted: true,
NextPageToken: nil,
}).Return(&persistence.ListNamespacesResponse{
Namespaces: []*persistence.GetNamespaceResponse{
// namespaceRecord1 is removed
Expand Down