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

Update domain deprecation command to fail if workflow exists #4126

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

Shaddoll
Copy link
Member

@Shaddoll Shaddoll commented Apr 9, 2021

What changed?
Update the domain deprecation command to check if there exists any workflow history in that domain before deprecating the domain by default. And also add a new flag '--force' to allow user to skip the workflow history check.

Why?
We want to be cautious when deprecating a domain, so the default behavior is not to do anything if workflow history exists. We also want to keep the original behavior to deprecate a domain when we don't care workflow history in that domain.

How did you test it?
unit test

Potential risks

Release notes

Documentation Changes

@Shaddoll Shaddoll requested review from a team and meiliang86 April 9, 2021 20:45
@coveralls
Copy link

coveralls commented Apr 9, 2021

Pull Request Test Coverage Report for Build 3a7dc900-12d6-4fa1-a24c-f4527269a5ec

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • 53 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.03%) to 67.881%

Files with Coverage Reduction New Missed Lines %
service/history/task/task.go 1 83.2%
service/history/execution/mutable_state_builder.go 2 69.79%
common/persistence/cassandra/cassandraPersistence.go 3 51.2%
service/history/task/transfer_standby_task_executor.go 4 90.32%
common/task/fifoTaskScheduler.go 5 84.54%
service/history/queue/processor_base.go 7 61.82%
common/persistence/cassandra/cassandraPersistenceUtil.go 31 90.98%
Totals Coverage Status
Change from base Build 558ac9ea-51a2-4a16-a7b1-4ba5d28d053c: 0.03%
Covered Lines: 98756
Relevant Lines: 145485

💛 - Coveralls

// check if there is any workflow in this domain, if exists, do not deprecate
wfs, _ := listClosedWorkflow(getWorkflowClient(c), 1, 0, time.Now().UnixNano(), "", "", workflowStatusNotSet, nil, c)
if len(wfs) > 0 {
ErrorAndExit("Operation DeprecateDomain failed.", errors.New("Workflow history not cleared in this domain."))
Copy link
Contributor

Choose a reason for hiding this comment

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

why closed workflows still matter? Is that a requirements or some technical workaround?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's a requirement. We want to be conservative.

Copy link
Contributor

Choose a reason for hiding this comment

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

May I ask what's purpose of this change? I thought only start or signal workflow is blocked for deprecated domains. Trying to understand why do closed workflow and running workflow matter here?

If we want to enforce this requirement that domain deprecation only happens for domains in which all workflows have passed retention, I think this check should be done inside the handler of domain deprecation call instead of just in the CLI?

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason I made the change in CLI but not in server is to let the caller do the check.
And within CLI, we can add another flag (e.g. --force) to make this check optional, but the default behavior is to be conservative and does the check.

Copy link
Member Author

Choose a reason for hiding this comment

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

@meiliang86 What's your opinion on this? I prefer to adding the check in CLI and later we can add a flag to skip the check if we'd like to.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah adding the check to the CLI is fine. Technically we can deprecate domains even there's open/close workflows, so it's ok to not check it on the server side.
This extra check is just to make sure we don't shoot ourselves in the foot (i.e. accidentally deprecating domains that are still in use), as right now we don't support resurrecting domains once deprecated.

@Shaddoll Shaddoll force-pushed the cli-dep branch 2 times, most recently from 0b1448c to 98db25d Compare April 13, 2021 22:28
@Shaddoll Shaddoll requested a review from yycptt April 13, 2021 23:03

ctx, cancel := newContext(c)
defer cancel()

if !force {
// check if there is any workflow in this domain, if exists, do not deprecate
wfs, _ := listClosedWorkflow(getWorkflowClient(c), 1, 0, time.Now().UnixNano(), "", "", workflowStatusNotSet, nil, c)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to check the error and block deprecation when failed to verify workflows?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's done within the helper functions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see. I thought the second return value is error. My bad.


ctx, cancel := newContext(c)
defer cancel()

if !force {
// check if there is any workflow in this domain, if exists, do not deprecate
wfs, _ := listClosedWorkflow(getWorkflowClient(c), 1, 0, time.Now().UnixNano(), "", "", workflowStatusNotSet, nil, c)
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see. I thought the second return value is error. My bad.

@Shaddoll Shaddoll merged commit 8d3519b into cadence-workflow:master Apr 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants