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

Add the APIStatus field in the Cluster ProviderStatus field #63

Closed
wants to merge 2 commits into from
Closed

Add the APIStatus field in the Cluster ProviderStatus field #63

wants to merge 2 commits into from

Conversation

sidharthsurana
Copy link
Contributor

  • Adds a new field "APIStatus" in the ProviderStatus for Cluster type
  • Adds logic in the cluster controller to keep the APIStatus up to date

Resolves #62

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sidharthsurana
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: roberthbailey

If they are not already assigned, you can assign the PR to them by writing /assign @roberthbailey in a comment when ready.

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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 2, 2018
* Adds a new field "APIStatus" in the ProviderStatus for Cluster type
* Adds logic in the cluster controller to keep the APIStatus up to date

Resolves #62
@frapposelli
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 3, 2018
@@ -61,6 +70,91 @@ func (vc *ClusterActuator) Reconcile(cluster *clusterv1.Cluster) error {
glog.Infof("Error setting the Load Balancer members for the cluster: %s", err)
return err
}
// Check if the target kuberenetes is ready or not, and update the ProviderStatus if change is detected
Copy link

Choose a reason for hiding this comment

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

nit: kubernetes not kuberenetes :)

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 catching 👍

}

func (vc *ClusterActuator) updateK8sAPIStatus(cluster *clusterv1.Cluster) error {
currentClusterAPIStatus, err := vc.getClusterAPIStatus(cluster)
Copy link

Choose a reason for hiding this comment

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

Is this call necessary here?

The below call to updateClusterAPIStatus will also call getClusterAPIStatus, and this will incur in a double ssh to get the kubeconfig.

Also, by returning an error here, it means the status will not be updated when it's created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, while refactoring this locally, I meant to not call the getClusterAPIStatus below inside the updateClusterAPIStatus method, rather call it here and return early if needed. That is why I added the newStatus vsphereconfig.APIStatus field in the updateClusterAPIStatus method. However, I forgot to remove this invocation from there. :)
I will fix the updateClusterAPIStatus method

}
currentAPIStatus, err := vc.getClusterAPIStatus(cluster)
if err != nil {
return err
Copy link

Choose a reason for hiding this comment

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

Do you really want to return the error here? If the status is NotReady, wouldn't it be better to update the status with this condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the last comment above, this code actually should not have been here in this method. Thus I will remove it from here.

}
newProviderStatus := &vsphereconfig.VsphereClusterProviderStatus{}
// create a copy of the old status so that any other fields except the ones we want to change can be retained
if oldProviderStatus != nil {
Copy link

Choose a reason for hiding this comment

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

Technically this is not needed, because you have already checked the oldProviderStatus a few lines before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, here we do need to check for nil since the method vsphereutils.GetClusterProviderStatus(cluster) may return a value of (nil,nil) which would go past the previous check.

Copy link

Choose a reason for hiding this comment

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

Got it, my fault, I read the previous check as an OR, when it's an AND.

Also switch the APIStatus from an int to string based enum for better
readability aspect.
@sidharthsurana
Copy link
Contributor Author

Thanks for the review @frodenas I have addressed your comments in the new patch. Please take a look again.

@frodenas
Copy link

frodenas commented Oct 8, 2018

@sidharthsurana These changes have been merged as part of PR #64, right?

@sidharthsurana
Copy link
Contributor Author

@sidharthsurana These changes have been merged as part of PR #64, right?

Yes, it did. PR#64 was stacked on top of this one

@sidharthsurana sidharthsurana deleted the add-apistatus-cluster branch October 9, 2018 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants