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

Added minor adjustments in the shadow status options #1359

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions internal/query_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ var (
WorkflowStatusFailed = WorkflowStatus(shared.WorkflowExecutionCloseStatusFailed.String())
// WorkflowStatusCanceled is the WorkflowStatus for canceled workflows
WorkflowStatusCanceled = WorkflowStatus(shared.WorkflowExecutionCloseStatusCanceled.String())
// WorkflowStatusTerminated is the WorkflowStatus for terminated workflows
WorkflowStatusTerminated = WorkflowStatus(shared.WorkflowExecutionCloseStatusTerminated.String())
// WorkflowStatusContinuedAsNew is the WorkflowStatus for continuedAsNew workflows
WorkflowStatusContinuedAsNew = WorkflowStatus(shared.WorkflowExecutionCloseStatusContinuedAsNew.String())
// WorkflowStatusTimedOut is the WorkflowStatus for timedout workflows
Expand Down Expand Up @@ -183,7 +181,7 @@ func ToWorkflowStatus(statusString string) (WorkflowStatus, error) {
status := WorkflowStatus(strings.ToUpper(statusString))
switch status {
case WorkflowStatusOpen, WorkflowStatusClosed, WorkflowStatusCompleted,
WorkflowStatusFailed, WorkflowStatusCanceled, WorkflowStatusTerminated,
WorkflowStatusFailed, WorkflowStatusCanceled,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can still leave it here in the mapping function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will readd it later. removed it to be sure that the status can not be used in any situation at all.

WorkflowStatusContinuedAsNew, WorkflowStatusTimedOut, WorkflowStatusALL:
return status, nil
default:
Expand Down
8 changes: 1 addition & 7 deletions internal/query_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (s *queryBuilderSuite) TestWorkflowStatusQuery() {
},
{
msg: "all workflows",
workflowStatuses: []WorkflowStatus{WorkflowStatusTerminated, WorkflowStatusALL},
workflowStatuses: []WorkflowStatus{WorkflowStatusALL},
expectedQuery: "",
},
}
Expand Down Expand Up @@ -225,12 +225,6 @@ func (s *queryBuilderSuite) TestToWorkflowStatus() {
expectErr: false,
expectedStatus: WorkflowStatusTimedOut,
},
{
msg: "upper case status string",
statusString: "TERMINATED",
expectErr: false,
expectedStatus: WorkflowStatusTerminated,
},
{
msg: "all",
statusString: "ALL",
Expand Down
5 changes: 2 additions & 3 deletions internal/workflow_shadower.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,9 @@ func (o *ShadowOptions) validateAndPopulateFields() error {
}
statuses = append(statuses, status)
}
//All the open statuses are taken by default. This list seems to not work as expected.
//TODO: verify that the status list works as expected. currently all wfs of all types get picked up.
//This filter doesn't seem to be working as expected.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please elaborate in the comment what you mean

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filter should have only taken open and closed wfs but it returns continue as new wfs as well. not sure if this is because of some other check somewhere or the query gets formed incorrectly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please elaborate on this in the comment so it will be easier to identify the problem.
Consider adding a TODO: handle ContinueAsNew as a special case.

if len(statuses) == 0 {
statuses = []WorkflowStatus{WorkflowStatusOpen}
statuses = []WorkflowStatus{WorkflowStatusOpen, WorkflowStatusClosed}
}
queryBuilder.WorkflowStatus(statuses)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess modern DBs with good query analyzers will just drop this expression, but evaluation of this does not make any sense.
I suggest making this optional:

if len(statuses) != 0 {
  queryBuilder.WorkflowStatus(statuses)
}

Copy link
Contributor Author

@agautam478 agautam478 Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will incorporate this and update PR. Okay! so there's some other bug somewhere in there which created strange behavour in the filter so leaving the above as it is. I will be scrapping this piece anyway. I need this diff as an interim fix so that I ca continue working on the qb update without interrupting the customers.


Expand Down
4 changes: 2 additions & 2 deletions internal/workflow_shadower_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (s *workflowShadowerSuite) TestShadowOptionsValidation() {
options: ShadowOptions{},
expectErr: false,
validationFn: func(options *ShadowOptions) {
s.Equal("(CloseTime = missing)", options.WorkflowQuery)
s.Equal("(CloseTime = missing or CloseTime != missing)", options.WorkflowQuery)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not this equivalent to empty query?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is but the query builder forms it this way because of open and closed statuses getting added together in the test. This portion of default status check needs a rewrite that I will be doing as a part of the shadower fix initiative.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do have an ALL status filter somewhere but it barely gets used. Now the problem with that one is that it picks up everything present in that defaut list of statuses.

s.Equal(1.0, options.SamplingRate)
s.Equal(1, options.Concurrency)
},
Expand Down Expand Up @@ -255,7 +255,7 @@ func (s *workflowShadowerSuite) TestShadowOptionsWithExcludeTypes() {
Mode: ShadowModeNormal,
}
expectedQuery := fmt.Sprintf(
`(WorkflowType = "includedType1" or WorkflowType = "includedType2") and (WorkflowType != "excludedType1" and WorkflowType != "excludedType2") and (CloseTime = missing)`,
`(WorkflowType = "includedType1" or WorkflowType = "includedType2") and (WorkflowType != "excludedType1" and WorkflowType != "excludedType2") and (CloseTime = missing or CloseTime != missing)`,
)
shadower, err := NewWorkflowShadower(s.mockService, "testDomain", options, ReplayOptions{}, nil)
s.NoError(err)
Expand Down
Loading