Skip to content

Conversation

@iamemilio
Copy link

@iamemilio iamemilio commented Jan 20, 2020

What this PR does / why we need it:
Corrects Self Signed Certs support to pull from centralized location in the cluster, the openshift-config:cloud-provider-config configmap.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Jan 20, 2020
@openshift-ci-robot
Copy link

@iamemilio: This pull request references Bugzilla bug 1769879, which is valid. The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Bug 1769879: SSC refractor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 20, 2020
@iamemilio
Copy link
Author

/assign @mandre @Fedosin

@pierreprinetti
Copy link
Member

/retest


func NewInstanceServiceFromCloud(cloud clientconfig.Cloud, cert []byte) (*InstanceService, error) {
clientOpts := new(clientconfig.ClientOpts)
var opts *gophercloud.AuthOptions
Copy link
Member

@pierreprinetti pierreprinetti Jan 21, 2020

Choose a reason for hiding this comment

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

This seems redundant, as there is opts, err := clientconfig.AuthOptions(clientOpts) below

return "", fmt.Errorf("No namespace provided, cannot get cacert from configmap")
}
if configmapName == "" {
return "", fmt.Errorf("No name provided, cannot get cacert from configmap")
Copy link
Member

@pierreprinetti pierreprinetti Jan 21, 2020

Choose a reason for hiding this comment

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

Just a nit about the error messages.

This is the error check that happens right after the call to this function:

if err != nil {
	return nil, fmt.Errorf("Failed to get openstack CA cert: %v", err)
}

Hence the complete error will be:

Failed to get openstack CA cert: No name provided, cannot get cacert from configmap

You are stating the intent twice.

Usually, you would state the intent in the calling function, because it has inherently more context about what is going on, and why. The name of this function is GetCACertFromConfigmap, but by looking at what it does, it could as well have been GetStringFromConfigmap. The piece of code that knows that the value will be a "CACert" is in the caller only.


This is what you could have for example.

On the caller side:

if err != nil {
	return nil, fmt.Errorf("failed to get OpenStack CA certificate from configmap: %v", err)
}

and here:

return "", fmt.Errorf("the provided configmap name is an empty string")

And for bonus points:

Error strings should not start with a capital letter because they'll often be prefixed before printing


cacert, err := GetCACertFromConfigmap(kubeClient, "openshift-config", "cloud-provider-config", "ca-bundle.pem")
if err != nil {
return nil, fmt.Errorf("Failed to get openstack CA cert: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to fail if the configmap doesn't contain the cert, it's a valid use case (i.e. non SSL OpenStack)

@iamemilio
Copy link
Author

/retest

1 similar comment
@iamemilio
Copy link
Author

/retest

@openshift-ci-robot
Copy link

@iamemilio: This pull request references Bugzilla bug 1769879, which is valid.

In response to this:

Bug 1769879: SSC refractor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

It's a valid use case, for instance when deploying on an OpenStack
cloud that doesn't use SSL.
@iamemilio
Copy link
Author

/retest

1 similar comment
@mandre
Copy link
Member

mandre commented Jan 24, 2020

/retest

@mandre
Copy link
Member

mandre commented Jan 24, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 24, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iamemilio, mandre

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

@openshift-merge-robot openshift-merge-robot merged commit 86e93b0 into openshift:master Jan 24, 2020
pierreprinetti pushed a commit to shiftstack/cluster-api-provider-openstack that referenced this pull request Apr 22, 2024
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. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants