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

Conditional Tinkerbell Template Actions #24

Open
chrisdoherty4 opened this issue Feb 8, 2023 · 1 comment
Open

Conditional Tinkerbell Template Actions #24

chrisdoherty4 opened this issue Feb 8, 2023 · 1 comment
Labels
status/accepted The scope and kind of work is agreed and the item accepted to the backlog theme/feature New functionality in Tinkerbell

Comments

@chrisdoherty4
Copy link
Member

chrisdoherty4 commented Feb 8, 2023

Overview

Tinkerbell defines a Template object that contains Actions. Actions represent an activity that contributes to the provisioning of a machine (for the primary Tinkerbell use-case). Actions are flexible as they are OCI images that can be developed and maintained by third parties. This flexibility contributes to the flexibility of Templates.

Template's themselves, however, aren't particularly flexible. For use-cases such as CAPI/CAPT where the same template is used to provision the same kind of node (such as control plane nodes) where its necessary to perform different dependent on the hardware it can be difficult to model using Template's.

Proposal

Provide control flow type capabilities in Template's that enables toggling of individual actions. This could work in a similar fashion to Github Action's if statement.

# Github Action Example
jobs:
  job_name:
     if: EXPRESSION

The semantics of if are to run the job if the EXPRESSION evaluates to true.

We could create something similar for Tinkerbell Template actions (note the historical concept of a 'task' has been removed for simplicity as it will be removed in future versions of Tinkerbell).

actions:
- name: "write-file"
  if: EXPRESSION

Rationale

Adding expression capabilities with if in Tinkerbell Templates adds complexity in the form of maintenance. Its non-trivial and the Go standard library doesn't offer expression evaluation. Leveraging third party libraries for evaluating expressions would be ideal.

The particular CAPI/CAPT example used is quite specific to CAPI/CAPT. Its possible that a CAPT solution could be created that decouples templates from CAPT TinkerbellMachineTemplate objects and alleviates that specific problem as there's nothing inherently preventing a user in Tinkerbell core from creating a different template for a specific kind of machine today.

@chrisdoherty4 chrisdoherty4 converted this from a draft issue Feb 8, 2023
@chrisdoherty4 chrisdoherty4 added theme/feature New functionality in Tinkerbell status/discussion The scope and kind of work is still in discussion labels Feb 8, 2023
@chrisdoherty4 chrisdoherty4 moved this to Accepted in Tinkerbell Roadmap Jan 29, 2024
@chrisdoherty4 chrisdoherty4 added status/accepted The scope and kind of work is agreed and the item accepted to the backlog and removed status/discussion The scope and kind of work is still in discussion labels Jan 29, 2024
@chrisdoherty4
Copy link
Member Author

After developing the initial v1alpha2 controller, @jacobweinstock and I discussed this and felt it would be quite useful long term. Implementation will be some time after the agreed functionality of v1alpha2 is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/accepted The scope and kind of work is agreed and the item accepted to the backlog theme/feature New functionality in Tinkerbell
Projects
Status: Accepted
Development

No branches or pull requests

1 participant