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

Workflow boot features, print columns, and Workflow Conditions #1000

Merged

Conversation

jacobweinstock
Copy link
Member

@jacobweinstock jacobweinstock commented Sep 19, 2024

Description

  1. Adds fields in the Workflow spec that trigger handling of setting hardware allowPxe field and getting machines into a netbooting state.

    toggleAllowNetboot: indicates whether the controller should toggle the field in the associated hardware for allowing PXE booting. This will be enabled before a Workflow is executed and disabled after the Workflow has completed successfully. A HardwareRef must be provided.

    oneTimeNetboot: indicates whether the controller should create a job.bmc.tinkerbell.org object for getting the associated hardware into a netbooting state. A HardwareRef that contains a spec.bmcRef must be provided.

    Current Workflow spec example:

     apiVersion: tinkerbell.org/v1alpha1
     kind: Workflow
     metadata:
       name: example1
       namespace: tink-system
     spec:
       hardwareMap:
         device_1: 01:02:03:04:05:06
       templateRef: myTemplate
       hardwareRef: example1

    New Workflow spec example:

     apiVersion: tinkerbell.org/v1alpha1
     kind: Workflow
     metadata:
       name: example1
       namespace: tink-system
     spec:
       hardwareMap:
         device_1: 01:02:03:04:05:06
       templateRef: myTemplate
       hardwareRef: example1
       bootOptions:
         toggleAllowNetboot: true
         oneTimeNetboot: true
  2. Adds the following columns to kubectl get workflow: CURRENT-ACTION and TEMPLATE-RENDERING.

    ❯ kubectl get wf -n tink-system 
    NAME         TEMPLATE   STATE           CURRENT-ACTION   TEMPLATE-RENDERING
    testing      testing    STATE_SUCCESS   action 7         successful
  3. Introduces Conditions to the Workflow spec. The following are the initial conditions.

    NetbootJobFailed
    NetbootJobComplete
    NetbootJobRunning
    NetbootJobSetupFailed
    NetbootJobSetupComplete
    ToggleAllowNetbootTrue
    ToggleAllowNetbootFalse
    TemplateRenderedSuccess
    

Why is this needed

Fixes: #

How Has This Been Tested?

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

Upgrade:

  1. Update the workflow CRD
    kubectl replace -f https://raw.githubusercontent.com/tinkerbell/tink/refs/heads/main/config/crd/bases/tinkerbell.org_workflows.yaml
  2. Update the tink controller Role
    kubectl replace -f https://raw.githubusercontent.com/tinkerbell/tink/refs/heads/main/config/manager-rbac/role.yaml -n tink-system
  3. Update tink controller and tink server images
    kubectl set image -n tink-system deployment/tink-controller tink-controller=quay.io/tinkerbell/tink-controller:latest
    kubectl set image -n tink-system deployment/tink-server server=quay.io/tinkerbell/tink-server:latest

Checklist:

I have:

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

Add spec field and functionality for
setting the allowPXE field in hardware.

Add spec field and functionality for
creating a job.bmc.tinkerbell.org object to
get the Hardware into a netboot state.

Signed-off-by: Jacob Weinstock <[email protected]>
Use status' to make sure creation and
deletion work properly.

Signed-off-by: Jacob Weinstock <[email protected]>
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 54.48505% with 137 lines in your changes missing coverage. Please review.

Project coverage is 30.06%. Comparing base (9631f39) to head (ff45778).
Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
internal/deprecated/workflow/reconciler.go 38.46% 74 Missing and 6 partials ⚠️
internal/deprecated/workflow/bootops.go 76.51% 21 Missing and 10 partials ⚠️
api/v1alpha1/workflow_types.go 70.58% 5 Missing ⚠️
cmd/tink-controller/main.go 0.00% 4 Missing ⚠️
cmd/tink-controller-v1alpha2/main.go 0.00% 3 Missing ⚠️
cmd/tink-server/main.go 0.00% 3 Missing ⚠️
internal/server/kubernetes_api_workflow.go 0.00% 3 Missing ⚠️
cmd/tink-worker/cmd/root.go 0.00% 2 Missing ⚠️
cmd/virtual-worker/cmd/root.go 0.00% 2 Missing ⚠️
internal/cli/agent.go 0.00% 2 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1000      +/-   ##
==========================================
+ Coverage   28.04%   30.06%   +2.01%     
==========================================
  Files          70       71       +1     
  Lines        3484     3739     +255     
==========================================
+ Hits          977     1124     +147     
- Misses       2445     2539      +94     
- Partials       62       76      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock
Copy link
Member Author

related to tinkerbell/roadmap#33

Add tests for handleOneTimeNetboot and handleHardwareAllowPXE.

Signed-off-by: Jacob Weinstock <[email protected]>
Hopefully improved the understandability
of the field some.

Signed-off-by: Jacob Weinstock <[email protected]>
Update rbac.

Signed-off-by: Jacob Weinstock <[email protected]>
Upgrades and removed unused dep.

Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Pin apk packages in all Dockerfiles.

Signed-off-by: Jacob Weinstock <[email protected]>
Push the boolean info to the caller
so that handleHardwareAllowPXE can be
simpler.

Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock jacobweinstock marked this pull request as ready for review September 20, 2024 22:03
@jacobweinstock jacobweinstock changed the title WIP: Builtin workflow features new Workflow booting features Sep 20, 2024
This allows for adding/modifying conditions without
changing the Workflow spec.

Signed-off-by: Jacob Weinstock <[email protected]>
Moving to using Conditions required the tests
be updated.

Signed-off-by: Jacob Weinstock <[email protected]>
- Allows update existing conditions.
- Remove using conditions to check state, add top level
  status fields for state.
- Add TemplateRendering status field, printcolumn, and implementation
- Add currentAction status field, printcolumn, and implementation
- Move boot options code to their own file

Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock jacobweinstock changed the title new Workflow booting features new Workflow booting features, print columns, and Workflow Conditions Sep 26, 2024
@jacobweinstock jacobweinstock changed the title new Workflow booting features, print columns, and Workflow Conditions Workflow booting features, print columns, and Workflow Conditions Sep 26, 2024
Make the spec and status fields for boot options
the same so they are logically correlated.

Change global state from WorkflowStatePreparing to
WorkflowStateWaiting. This follows Kubernetes Pod
container states.
https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-states

Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock jacobweinstock added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 27, 2024
Return in each switch case. Make function for patching status.
Reorganize where some conditions were being set.
Replace !errors.IsNotFound with ctrlclient.IgnoreNotFound
in order to improve readability.

Signed-off-by: Jacob Weinstock <[email protected]>
@jacobweinstock jacobweinstock changed the title Workflow booting features, print columns, and Workflow Conditions Workflow boot features, print columns, and Workflow Conditions Sep 30, 2024
@jacobweinstock jacobweinstock merged commit 6841e81 into tinkerbell:main Oct 3, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant