Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

🏃Added Test :Return early if the owning machine does not have an associated cluster #240

Merged
merged 1 commit into from
Sep 23, 2019

Conversation

hpandeycodeit
Copy link
Contributor

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

@k8s-ci-robot
Copy link
Contributor

Welcome @hpandeycodeit!

It looks like this is your first PR to kubernetes-sigs/cluster-api-bootstrap-provider-kubeadm 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-bootstrap-provider-kubeadm has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 20, 2019
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 20, 2019
@@ -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) {
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

@chuckha indeed

Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

That is the direction that @ncdc, @vincepri, and myself have been advocating for, but I believe that the Cluster has been specified to still be optional at this point in time.

Copy link
Contributor

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

Copy link
Contributor

@SataQiu SataQiu left a 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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Return early If the owning machine does not have a associated cluster
// Return early If the owning machine does not have an associated cluster.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

@chuckha chuckha left a 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 {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@chuckha chuckha mentioned this pull request Sep 23, 2019
8 tasks
@chuckha
Copy link
Contributor

chuckha commented Sep 23, 2019

can you please squash your commits?

}
_, err := k.Reconcile(request)
if err != nil {
t.Fatal("Not Expecting error, got an error")
Copy link
Contributor

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)

Copy link
Contributor Author

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

@chuckha
Copy link
Contributor

chuckha commented Sep 23, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 23, 2019
@chuckha
Copy link
Contributor

chuckha commented Sep 23, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 23, 2019
@k8s-ci-robot k8s-ci-robot merged commit 7aea998 into kubernetes-retired:master Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants