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

Fix merge confict #2642

Merged
merged 1 commit into from
Mar 24, 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
20 changes: 10 additions & 10 deletions service/worker/deletenamespace/activities.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ func NewActivities(
}
}

func (a *activities) GetNamespaceIDActivity(_ context.Context, nsName namespace.Name) (namespace.ID, error) {
func (a *activities) GetNamespaceIDActivity(ctx context.Context, nsName namespace.Name) (namespace.ID, error) {
getNamespaceRequest := &persistence.GetNamespaceRequest{
Name: nsName.String(),
}

getNamespaceResponse, err := a.metadataManager.GetNamespace(getNamespaceRequest)
getNamespaceResponse, err := a.metadataManager.GetNamespace(ctx, getNamespaceRequest)
if err != nil {
return namespace.EmptyID, err
}
Expand All @@ -77,19 +77,19 @@ func (a *activities) GetNamespaceIDActivity(_ context.Context, nsName namespace.
return namespace.ID(getNamespaceResponse.Namespace.Info.Id), nil
}

func (a *activities) MarkNamespaceDeletedActivity(_ context.Context, nsName namespace.Name) error {
func (a *activities) MarkNamespaceDeletedActivity(ctx context.Context, nsName namespace.Name) error {
getNamespaceRequest := &persistence.GetNamespaceRequest{
Name: nsName.String(),
}

metadata, err := a.metadataManager.GetMetadata()
metadata, err := a.metadataManager.GetMetadata(ctx)
if err != nil {
a.metricsClient.IncCounter(metrics.DeleteNamespaceWorkflowScope, metrics.ReadNamespaceFailuresCount)
a.logger.Error("Unable to get cluster metadata.", tag.WorkflowNamespace(nsName.String()), tag.Error(err))
return err
}

ns, err := a.metadataManager.GetNamespace(getNamespaceRequest)
ns, err := a.metadataManager.GetNamespace(ctx, getNamespaceRequest)
if err != nil {
a.metricsClient.IncCounter(metrics.DeleteNamespaceWorkflowScope, metrics.ReadNamespaceFailuresCount)
a.logger.Error("Unable to get namespace details.", tag.WorkflowNamespace(nsName.String()), tag.Error(err))
Expand All @@ -104,7 +104,7 @@ func (a *activities) MarkNamespaceDeletedActivity(_ context.Context, nsName name
NotificationVersion: metadata.NotificationVersion,
}

err = a.metadataManager.UpdateNamespace(updateRequest)
err = a.metadataManager.UpdateNamespace(ctx, updateRequest)
if err != nil {
a.metricsClient.IncCounter(metrics.DeleteNamespaceWorkflowScope, metrics.UpdateNamespaceFailuresCount)
a.logger.Error("Unable to update namespace state to Deleted.", tag.WorkflowNamespace(nsName.String()), tag.Error(err))
Expand All @@ -113,7 +113,7 @@ func (a *activities) MarkNamespaceDeletedActivity(_ context.Context, nsName name
return nil
}

func (a *activities) GenerateDeletedNamespaceNameActivity(_ context.Context, nsName namespace.Name) (namespace.Name, error) {
func (a *activities) GenerateDeletedNamespaceNameActivity(ctx context.Context, nsName namespace.Name) (namespace.Name, error) {
var letters = []rune("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
const suffixLength = 5
rand.Seed(time.Now().UnixNano())
Expand All @@ -126,7 +126,7 @@ func (a *activities) GenerateDeletedNamespaceNameActivity(_ context.Context, nsN

newName := fmt.Sprintf("%s-deleted-%s", nsName, string(b))

_, err := a.metadataManager.GetNamespace(&persistence.GetNamespaceRequest{
_, err := a.metadataManager.GetNamespace(ctx, &persistence.GetNamespaceRequest{
Name: newName,
})
switch err.(type) {
Expand All @@ -143,13 +143,13 @@ func (a *activities) GenerateDeletedNamespaceNameActivity(_ context.Context, nsN
}
}

func (a *activities) RenameNamespaceActivity(_ context.Context, previousName namespace.Name, newName namespace.Name) error {
func (a *activities) RenameNamespaceActivity(ctx context.Context, previousName namespace.Name, newName namespace.Name) error {
renameNamespaceRequest := &persistence.RenameNamespaceRequest{
PreviousName: previousName.String(),
NewName: newName.String(),
}

err := a.metadataManager.RenameNamespace(renameNamespaceRequest)
err := a.metadataManager.RenameNamespace(ctx, renameNamespaceRequest)
if err != nil {
a.metricsClient.IncCounter(metrics.DeleteNamespaceWorkflowScope, metrics.RenameNamespaceFailuresCount)
a.logger.Error("Unable to rename namespace.", tag.WorkflowNamespace(previousName.String()), tag.Error(err))
Expand Down
6 changes: 3 additions & 3 deletions service/worker/deletenamespace/reclaimresources/activities.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NewActivities(
}
}

func (a *Activities) EnsureNoExecutionsActivity(ctx context.Context, nsID namespace.ID, nsName namespace.Name) error {
func (a *Activities) EnsureNoExecutionsActivity(_ context.Context, nsID namespace.ID, nsName namespace.Name) error {
// TODO: remove this check after CountWorkflowExecutions is implemented in standard visibility.
if a.visibilityManager.GetName() == "elasticsearch" {
req := &manager.CountWorkflowExecutionsRequest{
Expand Down Expand Up @@ -97,12 +97,12 @@ func (a *Activities) EnsureNoExecutionsActivity(ctx context.Context, nsID namesp
return nil
}

func (a *Activities) DeleteNamespaceActivity(_ context.Context, nsID namespace.ID, nsName namespace.Name) error {
func (a *Activities) DeleteNamespaceActivity(ctx context.Context, nsID namespace.ID, nsName namespace.Name) error {
deleteNamespaceRequest := &persistence.DeleteNamespaceByNameRequest{
Name: nsName.String(),
}

err := a.metadataManager.DeleteNamespaceByName(deleteNamespaceRequest)
err := a.metadataManager.DeleteNamespaceByName(ctx, deleteNamespaceRequest)
if err != nil {
a.metricsClient.IncCounter(metrics.ReclaimResourcesWorkflowScope, metrics.DeleteNamespaceFailuresCount)
a.logger.Error("Unable delete namespace from persistence.", tag.WorkflowNamespace(nsName.String()), tag.Error(err))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func Test_ReclaimResourcesWorkflow_NoActivityMocks_Success(t *testing.T) {
}, nil)

metadataManager := persistence.NewMockMetadataManager(ctrl)
metadataManager.EXPECT().DeleteNamespaceByName(&persistence.DeleteNamespaceByNameRequest{
metadataManager.EXPECT().DeleteNamespaceByName(gomock.Any(), &persistence.DeleteNamespaceByNameRequest{
Name: "namespace",
}).Return(nil)

Expand Down