-
Notifications
You must be signed in to change notification settings - Fork 67
🏃Added Test :Return early if the owning machine does not have an associated cluster #240
Conversation
Welcome @hpandeycodeit! |
@@ -192,6 +192,34 @@ func TestKubeadmConfigReconciler_Reconcile_ReturnEarlyIfMachineHasBootstrapData( | |||
} | |||
} | |||
|
|||
// Return early If the owning machine does not have a associated cluster | |||
func TestKubeadmConfigReconciler_Reconcile_ReturnEarlyIfMachineHasNoCluster(t *testing.T) { |
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.
@chuckha @ncdc based on the discussions from the f2f planning, is this the behavior that we actually want? Or do we want to allow a Machine without a Cluster as long as the label isn't set and have some fallback behavior to just not provide the defaults we set from the Cluster resource when that is the case?
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.
This is for the use-case that only uses the Machine API?
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.
@chuckha indeed
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 understanding was that a Cluster object was still required even if it's an empty object. It's good to figure this out now though. Is that also your understanding?
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 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.
Cluster is required as of today. This is not a change in behavior but a formalization of the current behavior. If we can open an issue to get the Machine API use-case here then we can work on iterating from this place:
CABPK requires a Cluster
Cluster API requires a Cluster
CAPA requires a Cluster
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.
found small nit
@@ -192,6 +192,34 @@ func TestKubeadmConfigReconciler_Reconcile_ReturnEarlyIfMachineHasBootstrapData( | |||
} | |||
} | |||
|
|||
// Return early If the owning machine does not have a associated cluster |
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.
// Return early If the owning machine does not have a associated cluster | |
// Return early If the owning machine does not have an associated cluster. |
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.
done.
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.
one minor change and this looks good to me!
}, | ||
} | ||
_, err := k.Reconcile(request) | ||
if err == nil { |
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 believe this recently changed, If the cluster does not exist then we expect error to be nil as it will simply be reconciled again. If you flip the ==
to be !=
and fix up the t.Fatal call then this looks good to me
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.
done
can you please squash your commits? |
} | ||
_, err := k.Reconcile(request) | ||
if err != nil { | ||
t.Fatal("Not Expecting error, got an 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.
It would be good to also print out the error, something like t.Fatalf("Not Expecting error, got an error: %+v", 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.
thanks for pointing it out! Added the error in the t.fatalf
a31db75
to
be00257
Compare
…an associated cluster
be00257
to
2b93a31
Compare
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chuckha, hpandeycodeit 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 adds a test case - Return early if the owning machine does not have an associated cluster.
Which issue(s) this PR fixes :
Ref #214