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

Avoid hardcoding port in clusterclient.go #734

Merged
merged 1 commit into from
Feb 7, 2019
Merged

Avoid hardcoding port in clusterclient.go #734

merged 1 commit into from
Feb 7, 2019

Conversation

frapposelli
Copy link
Member

What this PR does / why we need it:

In clusterclient.go client.UpdateClusterObjectEndpoint checks if the value fetched from the provider is in the host:port format, if no port is present appends the default API server port (443).

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 #559

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 7, 2019
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 7, 2019
@frapposelli
Copy link
Member Author

/assign @vincepri @detiber
/cc @flaper87 @chaosaffe

@frapposelli
Copy link
Member Author

I would also recommend to rename Deployer.GetIP to a more describing Deployer.GetControlPlaneEndpoint.

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

Left some comments, this would solve the immediate issue with the hardcoded port although I agree that the deployer's GetIP should be renamed to something more meaningful.

cluster, err := c.GetClusterObject(clusterName, namespace)
if err != nil {
return err
}
// clusterEndpoint can be passed as hostname or hostname:port, if port is not present
// the default port 443 will be applied.
Copy link
Member

Choose a reason for hiding this comment

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

Should we have this and a better description in an exported comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

took a stab at it

@@ -406,15 +408,32 @@ func newDeleteOptions() *metav1.DeleteOptions {
}

// TODO: Test this function
func (c *client) UpdateClusterObjectEndpoint(controlPlaneIP, clusterName, namespace string) error {
func (c *client) UpdateClusterObjectEndpoint(clusterEndpoint, clusterName, namespace string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Do we know what's using this method currently?

Copy link
Member Author

Choose a reason for hiding this comment

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

clusterdeployer.go in updateClusterEndpoint

Copy link
Contributor

@sidharthsurana sidharthsurana left a comment

Choose a reason for hiding this comment

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

change looks good, just a minor nit

In clusterclient.go client.UpdateClusterObjectEndpoint checks if the value
fetched from the provider is in the host:port format, if no port is present
appends the default API server port (443).

Fixes: #559
@sidharthsurana
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 7, 2019
// TODO: Test this function
func (c *client) UpdateClusterObjectEndpoint(controlPlaneIP, clusterName, namespace string) error {
func (c *client) UpdateClusterObjectEndpoint(clusterEndpoint, clusterName, namespace string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a simple test and remove the TODO as part of this change?

@detiber
Copy link
Member

detiber commented Feb 7, 2019

I would also recommend to rename Deployer.GetIP to a more describing Deployer.GetControlPlaneEndpoint.

Generally I would agree with this, however the Deployer interface in general is a workaround and only required for building custom clusterctl binaries for each provider. Rather than iterate on this interface we should instead focus on replacing the Deployer interface and properly extending clusterctl to support external providers natively.

@detiber
Copy link
Member

detiber commented Feb 7, 2019

/lgtm

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

@frapposelli We can follow up with some unit tests in a new PR.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: frapposelli, vincepri

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 Feb 7, 2019
@k8s-ci-robot k8s-ci-robot merged commit 9153bcf into kubernetes-sigs:master Feb 7, 2019
@frapposelli
Copy link
Member Author

@vincepri sounds good 👍

@frapposelli frapposelli deleted the GH-559 branch February 7, 2019 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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 "Looks good to me", 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.

The apiserver port is hard-coded
5 participants