-
Notifications
You must be signed in to change notification settings - Fork 17
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
Baseboardmanagement controller implementation #3
Baseboardmanagement controller implementation #3
Conversation
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
d6f2eb1
to
dfe231e
Compare
Codecov Report
@@ Coverage Diff @@
## main #3 +/- ##
==========================================
+ Coverage 0.00% 54.46% +54.46%
==========================================
Files 3 4 +1
Lines 21 112 +91
==========================================
+ Hits 0 61 +61
- Misses 21 42 +21
- Partials 0 9 +9
Continue to review full report at Codecov.
|
} | ||
|
||
// Initializing BMC Client connection | ||
r.BMCClient.InitClient(bm.Spec.Connection.Host, "623", username, password) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is port hardcoded? Shouldn't that be configurable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad. I was going to have a TODO to add this to the BaseboardManagement api.
Will update 👍
Signed-off-by: Aravind Ramalingam <[email protected]>
…nges Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
…mcclient factory method Signed-off-by: Aravind Ramalingam <[email protected]>
1fdfb67
to
4038d9e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK. Just need to move the types around and get rid of some redundant code + some cleanup.
err = r.BMCClient.OpenConnection(ctx) | ||
if err != nil { | ||
logger.Error(err, "BMC connection failed", "host", bm.Spec.Connection.Host) | ||
result, setConditionErr := r.setCondition(ctx, bm, bmcv1alpha1.ConnectionError, err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pokearu Wants to address the conditions discussion in a separate PR so resolving for now.
Signed-off-by: Aravind Ramalingam <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few minor questions/changes
|
||
// TODO (pokearu): Remove port hardcoding | ||
// Initializing BMC Client | ||
bmcClient, err := r.bmcClientFactory(ctx, bm.Spec.Connection.Host, "623", username, password) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you going to remove this hardcoding in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning to do a quick follow up PR. Was going to add it to the BaseboardManagement
api connection struct.
} | ||
for _, reconiler := range fieldReconcilers { | ||
if err := reconiler(ctx, bm, bmcClient); err != nil { | ||
logger.Error(err, "Failed to reconcile BaseboardManagement", "host", bm.Spec.Connection.Host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you still want to update the status on failure. You want to converge on desired state, not make it all-or-nothing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, I modified the reconciler to update status when reconciling fields 👍
|
||
// patchStatus patches the specifies patch on the BaseboardManagement. | ||
func (r *BaseboardManagementReconciler) patchStatus(ctx context.Context, bm *bmcv1alpha1.BaseboardManagement, patch client.Patch) (ctrl.Result, error) { | ||
err := r.client.Status().Patch(ctx, bm, patch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrisdoherty4 @jacobweinstock there is no idempotency/locking in the whole reconcile, do we want/need that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. When you're only considering the object under reconciliation there's no races as the manager ensures you're the only reconciler reconciling that resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is, of course, the possibility that an object is patched by something else but I don't think we have those semantics here.
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
Signed-off-by: Aravind Ramalingam <[email protected]>
0c60ca4
to
65acac8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This PR adds the reconciler implementation for the baseboardmanagement controller.
The controller ensures state for
baseboardmanagement
api type. On each reconcile loop,baseboardmanagement
object, error if not found.bmc client
and do apower status
call. If connection error, update.Status.Conditions
..Status.Power
.How Has This Been Tested?
I tested by generating a manifest and applying the controller to a cluster.
How are existing users impacted? What migration steps/scripts do we need?
No impact for existing users.
Checklist:
I have: