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

Minor change to include domainTag and pass domainName. #5468

Merged
merged 6 commits into from
Dec 9, 2023
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
12 changes: 7 additions & 5 deletions common/taskvalidator/validateworkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

// Checker is an interface for initiating the validation process.
type Checker interface {
WorkflowCheckforValidation(workflowID string, domainID string, runID string) error
WorkflowCheckforValidation(workflowID string, domainID string, domainName string, runID string) error
}

// checkerImpl is the implementation of the Checker interface.
Expand All @@ -48,14 +48,16 @@ func NewWfChecker(logger log.Logger, metrics metrics.Client) Checker {
}

// WorkflowCheckforValidation is a dummy implementation of workflow validation.
func (w *checkerImpl) WorkflowCheckforValidation(workflowID string, domainID string, runID string) error {
func (w *checkerImpl) WorkflowCheckforValidation(workflowID string, domainID string, domainName string, runID string) error {
// Emitting just the log to ensure that the workflow is called for now.
// TODO: add some validations to check the wf for corruptions.
w.logger.Info("WorkflowCheckforValidation",
tag.WorkflowID(workflowID),
tag.WorkflowRunID(runID),
tag.WorkflowDomainID(domainID))
// Emit the number of workflows that have come in for the validation.
w.metricsClient.Scope(metrics.TaskValidatorScope).IncCounter(metrics.ValidatedWorkflowCount)
tag.WorkflowDomainID(domainID),
tag.WorkflowDomainName(domainName))
// Emit the number of workflows that have come in for the validation. Including the domain tag.
// The domain name will be useful when I introduce a flipr switch to turn on validation.
w.metricsClient.Scope(metrics.TaskValidatorScope, metrics.DomainTag(domainName)).IncCounter(metrics.ValidatedWorkflowCount)
return nil
}
6 changes: 3 additions & 3 deletions common/taskvalidator/validateworkflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/metrics"
)
Expand All @@ -47,12 +48,11 @@ func TestWorkflowCheckforValidation(t *testing.T) {
workflowID := "testWorkflowID"
domainID := "testDomainID"
runID := "testRunID"
domainName := "testDomainName"

// Call the method being tested
err := checker.WorkflowCheckforValidation(workflowID, domainID, runID)
err := checker.WorkflowCheckforValidation(workflowID, domainID, domainName, runID)

// Assert that the method returned no error
assert.NoError(t, err)

// Add additional assertions as needed based on the expected behavior of the method
}
9 changes: 6 additions & 3 deletions service/history/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import (
"sync/atomic"
"time"

"github.com/uber/cadence/service/history/workflow"

"golang.org/x/sync/errgroup"

"github.com/uber/cadence/common/membership"
Expand All @@ -59,6 +57,7 @@ import (
"github.com/uber/cadence/service/history/resource"
"github.com/uber/cadence/service/history/shard"
"github.com/uber/cadence/service/history/task"
"github.com/uber/cadence/service/history/workflow"
)

const shardOwnershipTransferDelay = 5 * time.Second
Expand Down Expand Up @@ -2236,7 +2235,11 @@ func (h *handlerImpl) error(
// We will delete the workflow or mark the workflow as corrupted.
// Placing a dummy call to the function to check the coherency of the design.
// The function returns nil error so removing error handling for now.
h.GetTaskValidator().WorkflowCheckforValidation(workflowID, domainID, "")
domainName, err := h.GetDomainCache().GetDomainName(domainID)
if err != nil {
return err
}
h.GetTaskValidator().WorkflowCheckforValidation(workflowID, domainID, domainName, "")
}
return err
}
Expand Down