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

Must parse rendered template for hardware address validation #408

Merged
merged 3 commits into from
Dec 31, 2020

Conversation

gauravgahlot
Copy link
Contributor

@gauravgahlot gauravgahlot commented Dec 31, 2020

Description

The template rendering logic does not validate if the rendered template has the correct worker address or not. The workflow create request only fails while inserting the workflow details into the database. For example, if we have the following template:

version: "0.1"
name: hello_world_workflow
global_timeout: 600
tasks:
  - name: "hello world"
    worker: "{{.device_1}}"
    actions:
    - name: "hello_world"
      image: hello-world
      timeout: 60

Now, if we create a workflow with incorrect hardware details an error is returned from database:

$ tink workflow create -t e80169ae-4b35-11eb-bef7-0242ac120004 -r '{"invalid_device": "08:00:27:00:00:01"}'
// 2020/12/31 07:01:37 rpc error: code = Unknown desc = failed to create workflow: unable to insert into action list: invalid worker address:

Why is this needed

The validation of the worker/hardware address must happen before making any database call.

$ tink workflow create -t cb826ef8-4b61-11eb-ab9f-0242ac120004 -r '{"invalid_device": "08:00:27:00:00:01"}'
2020/12/31 12:15:37 rpc error: code = Unknown desc = failed to render template, invalid hardware address: {"invalid_device": "08:00:27:00:00:01"}

$ tink workflow create -t cb826ef8-4b61-11eb-ab9f-0242ac120004 -r '{"device_1": "08:00:27:00:00:01"}'
Created Workflow:  ecabf4ce-4b61-11eb-ab9f-0242ac120004

How Has This Been Tested?

  • Unit tests
  • Manually over vagrant setup

Checklist:

I have:

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

Signed-off-by: Gaurav Gahlot <[email protected]>
@gauravgahlot gauravgahlot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Dec 31, 2020
@gauravgahlot gauravgahlot self-assigned this Dec 31, 2020
@gauravgahlot gauravgahlot force-pushed the fix-template-rendering branch from b14ca69 to 220e99d Compare December 31, 2020 12:40
@codecov
Copy link

codecov bot commented Dec 31, 2020

Codecov Report

Merging #408 (220e99d) into master (d7856c9) will increase coverage by 0.13%.
The diff coverage is 52.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #408      +/-   ##
==========================================
+ Coverage   21.24%   21.38%   +0.13%     
==========================================
  Files          24       24              
  Lines        2170     2170              
==========================================
+ Hits          461      464       +3     
+ Misses       1667     1664       -3     
  Partials       42       42              
Impacted Files Coverage Δ
grpc-server/workflow.go 28.80% <50.00%> (-0.76%) ⬇️
workflow/template_validator.go 80.59% <52.63%> (-11.07%) ⬇️

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 d7856c9...220e99d. Read the comment docs.

@gauravgahlot gauravgahlot requested a review from Cbkhare December 31, 2020 12:44
@Cbkhare Cbkhare merged commit ad5c929 into tinkerbell:master Dec 31, 2020
@gauravgahlot gauravgahlot deleted the fix-template-rendering branch December 31, 2020 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants