-
Notifications
You must be signed in to change notification settings - Fork 89
Adopt CAPI v1beta2 status changes and respective controller changes for IBMPowerVSMachine #2272
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
Adopt CAPI v1beta2 status changes and respective controller changes for IBMPowerVSMachine #2272
Conversation
✅ Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
/test pull-cluster-api-provider-ibmcloud-apidiff |
Output from testing
|
|
8db3c4e
to
e6c4127
Compare
@Prajyot-Parab @Amulyam24 @dharaneeshvrd please take a look when you get chance. |
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
/cc @dharaneeshvrd |
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 see few logs have been completely removed, hope that is intentional
Overall LGTM.
I don't see any changes that would affect the hypershift flow. Please think once from that perspective too. Thanks!
@@ -635,7 +617,7 @@ func (m *PowerVSMachineScope) GetRawBootstrapData() ([]byte, error) { | |||
secret := &corev1.Secret{} | |||
key := types.NamespacedName{Namespace: m.Machine.Namespace, Name: *m.Machine.Spec.Bootstrap.DataSecretName} | |||
if err := m.Client.Get(context.TODO(), key, secret); err != nil { | |||
return nil, fmt.Errorf("failed to retrieve bootstrap data secret for IBMPowerVSMachine %s/%s: %w", m.Machine.Namespace, m.Machine.Name, err) |
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.
Any reason to remove this info?
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.
We are embedding the machine names, namespaces, cluster name so on into logger and thats added to context, Like
log = log.WithValues("Machine", klog.KObj(machine))
ctx = ctrl.LoggerInto(ctx, log)
These can be found in function
func (r *IBMPowerVSMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, reterr error) {
So the log line will by default contains these information and we need not explicitly add it again.
Thank you, Yes, I just refactored logs to avoid unnecessary or duplicate lines. |
/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.
Minor comments, overall LGTM @Karthik-K-N !
|
||
instanceReply, err := m.ensureInstanceUnique(m.IBMPowerVSMachine.Name) | ||
if err != nil { | ||
return nil, err | ||
} else if instanceReply != nil { | ||
// TODO need a reasonable wrapped error. | ||
log.Info("PowerVS instance already exists") |
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.
It would be good to log the name of the machine.
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.
The logger will automatically print the machine and other owner details as mentioned here #2272 (comment)
@@ -271,38 +255,42 @@ func (m *PowerVSMachineScope) CreateMachine() (*models.PVMInstanceReference, err | |||
if con.Type == infrav1beta2.InstanceReadyCondition && con.Status == corev1.ConditionUnknown { |
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.
would we have to remove this going further as it is similar to the below check?
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.
when CAPI completely migrates into v1beta2 we will remove the earlier one.
m.IBMPowerVSMachine.Status.FailureReason = &reason | ||
} | ||
|
||
// SetFailureMessage will set status FailureMessage for the machine. | ||
func (m *PowerVSMachineScope) SetFailureMessage(message string) { | ||
//nolint:staticcheck |
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.
can you share why staticcheck is being ignored?
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.
Because we are setting the FailureMessage which has been deprecated as per CAPI v1beta2 guidelines.
@@ -235,6 +236,7 @@ func TestIBMPowerVSMachineReconciler_Reconcile(t *testing.T) { | |||
Name: tc.powervsMachine.Name, | |||
}, | |||
}) | |||
fmt.Println(err) |
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.
missed removing it?
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.
Updated it in the latest commit
40ede8b
to
5abb1a8
Compare
func (r *IBMPowerVSMachine) GetV1Beta2Conditions() []metav1.Condition { | ||
if r.Status.V1Beta2 == nil { | ||
return nil | ||
} | ||
return r.Status.V1Beta2.Conditions | ||
} | ||
|
||
// SetV1Beta2Conditions sets conditions for an API object. | ||
func (r *IBMPowerVSMachine) SetV1Beta2Conditions(conditions []metav1.Condition) { | ||
if r.Status.V1Beta2 == nil { | ||
r.Status.V1Beta2 = &IBMPowerVSMachineV1Beta2Status{} | ||
} | ||
r.Status.V1Beta2.Conditions = conditions | ||
} | ||
|
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.
@Karthik-K-N , where are we using this functions? I'm unable to find it in this PR, it is required for future changes?
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.
These are part of Setter interface. We need to implement these interfaces to use utility functions to set the conditions, As they accept setter interface as parameter: https://github.com/kubernetes-sigs/cluster-api/blob/09e6c8a14c2dd955924e7534727974d1e89643e5/util/conditions/v1beta2/setter.go#L73
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.
Got it, Thanks @Karthik-K-N 👍🏼
5abb1a8
to
62f9e9f
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Karthik-K-N, Prajyot-Parab The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
This PR consists of following changes
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #2264
Special notes for your reviewer:
Tried to keep different commits for each use case
/area provider/ibmcloud
Release note: