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

Database interface refactor #544

Merged
merged 4 commits into from
Oct 1, 2021

Conversation

micahhausler
Copy link
Contributor

@micahhausler micahhausler commented Sep 30, 2021

Signed-off-by: Micah Hausler [email protected]

Description

This includes 4 changes that are preparatory for future work to migrate to the Kubernetes data model.

  • Propagate stream context in streaming API. Previously context.Background() was used, but the stream provides a context object
  • Refactored shadowed "context" package name. By naming a method variable "context", no context package calls could be made in the method
  • Added context.Context to GetWorkflowsForWorker() database API. This plumbs down the context from the API call into the d.instance.QueryContext() call.
  • Refactor the database interface. I added a new interface WorkerWorkflow with the methods that get used by APIs the Tink Worker invokes. This is essentially a no-op for now.

Why is this needed

See tinkerbell/proposals#46

How Has This Been Tested?

Locally ran tests.

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

No impact to existing users

Checklist:

I have:

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

mmlb
mmlb previously approved these changes Sep 30, 2021
@micahhausler micahhausler force-pushed the interface-refactor branch 4 times, most recently from a3ebeed to 7334b1d Compare September 30, 2021 16:15
@codecov
Copy link

codecov bot commented Sep 30, 2021

Codecov Report

Merging #544 (d932a47) into main (3743d31) will not change coverage.
The diff coverage is 82.75%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #544   +/-   ##
=======================================
  Coverage   34.36%   34.36%           
=======================================
  Files          44       44           
  Lines        3384     3384           
=======================================
  Hits         1163     1163           
  Misses       2122     2122           
  Partials       99       99           
Impacted Files Coverage Δ
db/db.go 57.69% <ø> (ø)
db/workflow.go 31.73% <0.00%> (ø)
grpc-server/tinkerbell.go 91.48% <88.88%> (ø)

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 3743d31...d932a47. Read the comment docs.

@mmlb
Copy link
Contributor

mmlb commented Sep 30, 2021

Hey @micahhausler can you split this into a few commits please? I'm thinking:

  • rename context -> ctx
  • change context.Background -> stream.Context
  • add context to GetWorkflowsForWorker
  • everything else

looks to be the best break down to me.

@micahhausler
Copy link
Contributor Author

Hey @micahhausler can you split this into a few commits please? I'm thinking:

  • rename context -> ctx
  • change context.Background -> stream.Context
  • add context to GetWorkflowsForWorker
  • everything else

looks to be the best break down to me.

For an already small change is breaking it down further more of a preference or is there a documented style guide? I'm happy to do it if you think its necessary

@mmlb
Copy link
Contributor

mmlb commented Sep 30, 2021

For an already small change is breaking it down further more of a preference or is there a documented style guide?

There is not a style guide covering this, which is unfortunate and I will remedy that soon. Looking at the history of PRs to this and other tinkerbell repos I think we've all pretty much landed on one-commit-per-change, more or less.

I'm happy to do it if you think its necessary

Yes, please.

@mmlb
Copy link
Contributor

mmlb commented Sep 30, 2021

Also, I'll channel my @tstromberg senses and ask you to please update the PR description with info for all the changes being submitted. This way we can be sure the changes are intentional.

This change adds a separate interface for calls that are only invoked by APIs made by the Tink worker

Signed-off-by: Micah Hausler <[email protected]>
@micahhausler
Copy link
Contributor Author

Also, I'll channel my @tstromberg senses and ask you to please update the PR description with info for all the changes being submitted. This way we can be sure the changes are intentional.

Done! I think CI is now waiting for some sort of maintainer approval

@mmlb mmlb added the ready-to-merge Signal to Mergify to merge the PR. label Oct 1, 2021
@mergify mergify bot merged commit 7ef02f8 into tinkerbell:main Oct 1, 2021
@displague displague added this to the 0.7.0 milestone Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Signal to Mergify to merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants