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

Fixed #477 : Corrected state for get and get by id command. #482

Merged
merged 3 commits into from
Apr 20, 2021

Conversation

parauliya
Copy link
Contributor

@parauliya parauliya commented Apr 14, 2021

Signed-off-by: parauliya [email protected]

Description

After this Fix user will get the correct state in tink workflow get and tink workflow get <id>

Why is this needed

Fixes: #477

How Has This Been Tested?

Tested Manually with Vagrant Setup.

How are existing users impacted? What migration steps/scripts do we need?

No Impact.

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

@parauliya parauliya requested review from mmlb and gianarb April 14, 2021 12:18
@parauliya parauliya self-assigned this Apr 14, 2021
Copy link
Member

@jacobweinstock jacobweinstock left a comment

Choose a reason for hiding this comment

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

any chance you could add some tests?

grpc-server/workflow.go Show resolved Hide resolved
grpc-server/workflow.go Outdated Show resolved Hide resolved
@gauravgahlot gauravgahlot added the needs-tests Needs supporting unit tests label Apr 15, 2021
@codecov
Copy link

codecov bot commented Apr 15, 2021

Codecov Report

Merging #482 (9b817ce) into master (d13a368) will increase coverage by 0.06%.
The diff coverage is 60.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #482      +/-   ##
==========================================
+ Coverage   32.09%   32.16%   +0.06%     
==========================================
  Files          44       44              
  Lines        3103     3112       +9     
==========================================
+ Hits          996     1001       +5     
- Misses       2017     2019       +2     
- Partials       90       92       +2     
Impacted Files Coverage Δ
grpc-server/workflow.go 40.51% <60.00%> (+0.72%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d13a368...9b817ce. Read the comment docs.

@parauliya parauliya force-pushed the Fix_477 branch 2 times, most recently from 246f699 to b08bcb1 Compare April 16, 2021 07:23
thebsdbox
thebsdbox previously approved these changes Apr 16, 2021
@gauravgahlot gauravgahlot removed the needs-tests Needs supporting unit tests label Apr 19, 2021
@parauliya parauliya requested review from thebsdbox and jacobweinstock and removed request for gianarb April 19, 2021 07:13
Copy link
Member

@jacobweinstock jacobweinstock left a comment

Choose a reason for hiding this comment

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

thanks for adding tests! so important to making the tink codebase less fragile!
made a few comments for your review.

if wfCtx.CurrentActionState != workflow.State_STATE_SUCCESS {
return wfCtx.CurrentActionState
} else {
//wfacts, _ := db.GetWorkflowActions(ctx, id)
Copy link
Member

Choose a reason for hiding this comment

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

should probably removed commented code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -279,3 +273,22 @@ func (s *server) ShowWorkflowEvents(req *workflow.GetRequest, stream workflow.Wo
metrics.CacheHits.With(labels).Inc()
return nil
}

// This function will provide the workflow state on the basis of the state of the actions
// For e.g. : If an action has Tailed or Timeout then the workflow state will also be
Copy link
Member

Choose a reason for hiding this comment

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

NIT: misspelled word "Tailed" -> "Failed"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected

@@ -181,6 +174,7 @@ func (s *server) ListWorkflows(_ *workflow.Empty, stream workflow.WorkflowServic
Hardware: w.Hardware,
CreatedAt: w.CreatedAt,
UpdatedAt: w.UpdatedAt,
State: getWorkflowState(s.db, stream.Context(), w.ID),
Copy link
Member

Choose a reason for hiding this comment

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

you're making 2 calls to getWorkflowState, this means 2 DB calls. You could call getWorkflowState just once (1 DB call) and store it to a variable for use in both locations.

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 don't think it is possible to call getWorkflowState once and store it because the workflow state will change during the execution of a workflow which makes it dynamic. Therefore we have to fetch the latest value of a workflow state.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, apologies. You are right. For some reason I thought I saw two calls in a single function.

@parauliya parauliya merged commit 5d58c4b into tinkerbell:master Apr 20, 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.

"tink workflow get/get by id" command returns the incorrect state for workflows
4 participants