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

Bmcjob controller implementation #6

Merged
merged 15 commits into from
Jun 1, 2022

Conversation

pokearu
Copy link
Contributor

@pokearu pokearu commented May 23, 2022

Description

The BMCJob controller is responsible for running the Tasks (BMC actions like power and bootdev) listed on a BMCJob CR.
The controller,

  1. Fetches the BMCJob object
  2. Resolves the BaseboardManagementRef and establishes a connection (BMCCLient) to the baseboard management.
  3. Pauses the BaseboardManagement object reconcile. (Defers unpause)
  4. Reconciles the individual tasks in the BMCJob spec.
  5. For each Task the controller creates a BMCTask object, with an OwnerReference.
  6. Runs the action mentioned in the Task.
  7. Updated the Task conditions and status.
  8. Updates the Job condition and status.

Why is this needed

BMCJob is useful for performing one time actions that we want on the servers.

How Has This Been Tested?

Created a KinD cluster and tested creating and deleting BMCJob objects.

Checklist:

I have:

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

@pokearu
Copy link
Contributor Author

pokearu commented May 23, 2022

This PR is a WIP 🏗️

Also need to rebase based on changes discussed in #5

@codecov-commenter
Copy link

codecov-commenter commented May 23, 2022

Codecov Report

Merging #6 (e85f60d) into main (985d2ca) will decrease coverage by 37.03%.
The diff coverage is 3.10%.

@@             Coverage Diff             @@
##             main       #6       +/-   ##
===========================================
- Coverage   58.49%   21.45%   -37.04%     
===========================================
  Files           4        4               
  Lines         106      289      +183     
===========================================
  Hits           62       62               
- Misses         37      219      +182     
- Partials        7        8        +1     
Impacted Files Coverage Δ
controllers/bmcjob_controller.go 0.00% <0.00%> (ø)
controllers/bmctask_controller.go 0.00% <0.00%> (ø)
controllers/baseboardmanagement_controller.go 70.45% <66.66%> (-2.49%) ⬇️

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 985d2ca...e85f60d. Read the comment docs.

@pokearu pokearu force-pushed the bmcjob-controller branch from d2ab8e0 to 287106a Compare May 24, 2022 18:09
@pokearu pokearu changed the title [WIP] Bmcjob controller implementation Bmcjob controller implementation May 24, 2022
@chrisdoherty4
Copy link
Member

Please could you add to the description commentary on condition semantics.

api/v1alpha1/bmcjob_types.go Outdated Show resolved Hide resolved
api/v1alpha1/bmcjob_types.go Show resolved Hide resolved
api/v1alpha1/baseboardmanagement_types.go Outdated Show resolved Hide resolved
api/v1alpha1/baseboardmanagement_types.go Outdated Show resolved Hide resolved
api/v1alpha1/baseboardmanagement_types.go Outdated Show resolved Hide resolved
controllers/bmcjob_controller.go Outdated Show resolved Hide resolved
api/v1alpha1/bmctask_types.go Outdated Show resolved Hide resolved
controllers/bmcjob_controller.go Outdated Show resolved Hide resolved
controllers/bmcjob_controller.go Show resolved Hide resolved
controllers/bmcjob_controller.go Outdated Show resolved Hide resolved
@pokearu pokearu force-pushed the bmcjob-controller branch from 6cfdedc to ec9d0b4 Compare May 26, 2022 22:14
@pokearu pokearu force-pushed the bmcjob-controller branch from 6ecd16c to 16fdead Compare May 26, 2022 22:28
@pokearu
Copy link
Contributor Author

pokearu commented May 28, 2022

Based on discussions I have refactored how BMCJob and BMCTask resources are controlled.

bmcjob_controller

  1. Runs a BMCJob and also watches BMCTask based on owner reference.
  2. Initially sets the Job to Running and creates the first BMCTask
  3. The reconcile loop gets called again once the BMCTask updated and based on Task Conditions, the next BMCTask object is created.
  4. Once all the BMCJob tasks have condition completed, BMCJob is marked Completed.

bmctask_controller

  1. Runs the actions on a BMCTask
  2. Establishes a connection to the BMC and executes the specifies action.
  3. Updates the status

controllers/bmcjob_controller.go Outdated Show resolved Hide resolved
Comment on lines +82 to +83
if bmcJob.HasCondition(bmcv1alpha1.JobCompleted, bmcv1alpha1.ConditionTrue) ||
bmcJob.HasCondition(bmcv1alpha1.JobFailed, bmcv1alpha1.ConditionTrue) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we think Failed is a condition? Wouldn't that just be state on the Status (Success or Failed being the valid values)? In the event its Failed a description field of some sort. This way, consumers can watch for the condition "Completed" to become true before inspecting the actual result.

I don't recall what we said about Failed and Success etc. I'd be OK with allowing this to pass and changing it in a separate PR (or stripping it out of this one if possible). There's a bunch of good stuff here already that we don't want to hold up.

We need to be careful that we're not encoding job state into conditions.

controllers/bmcjob_controller.go Outdated Show resolved Hide resolved
controllers/bmcjob_controller.go Outdated Show resolved Hide resolved
Copy link
Member

@chrisdoherty4 chrisdoherty4 left a comment

Choose a reason for hiding this comment

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

I minor comment to fix in a subsequent PR.

)

// PausedAnnotation is an annotation that can be applied to BaseboardManagement
// object to prevent a controller from processing a resource.
const PausedAnnotation = "bmc.tinkerbell.org/paused"
Copy link
Member

Choose a reason for hiding this comment

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

Rufuio.tinkerbell.org

@chrisdoherty4 chrisdoherty4 merged commit 4dc2085 into tinkerbell:main Jun 1, 2022
@pokearu pokearu mentioned this pull request Jun 27, 2022
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.

3 participants