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

Kuryr: Handle unexpected errors fetching CA cert #462

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions pkg/platform/openstack/kuryr_bootstrap.go
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/openshift/cluster-network-operator/pkg/names"
"github.com/openshift/cluster-network-operator/pkg/platform/openstack/util/cert"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

confv1 "github.com/openshift/api/config/v1"
Expand Down Expand Up @@ -835,7 +836,7 @@ func getConfigMap(kubeClient client.Client, namespace, name string) (*v1.ConfigM
return cm, nil
}

func getUserCACert(kubeClient client.Client) (string, error) {
func getCloudProviderCACert(kubeClient client.Client) (string, error) {
cm, err := getConfigMap(kubeClient, OpenShiftConfigNamespace, UserCABundleConfigMap)
if err != nil {
return "", err
Expand Down Expand Up @@ -893,7 +894,11 @@ func BootstrapKuryr(conf *operv1.NetworkSpec, kubeClient client.Client) (*bootst

// We need to fetch user-provided OpenStack cloud CA certificate and make gophercloud use it.
// Also it'll get injected into a ConfigMap mounted into kuryr-controller later on.
userCACert, err := getUserCACert(kubeClient)
userCACert, err := getCloudProviderCACert(kubeClient)
if err != nil && !apierrors.IsNotFound(err) {
return nil, errors.Wrap(err, "failed to get cloud provider CA certificate")
}

if userCACert != "" {
certPool, err := x509.SystemCertPool()
if err == nil {
Expand Down Expand Up @@ -1167,7 +1172,10 @@ func BootstrapKuryr(conf *operv1.NetworkSpec, kubeClient client.Client) (*bootst
// b. List providers and look for OVN one.
// c. If it's present configure Kuryr to use it.
// d. In case of any issues just use whatever the default is.
octaviaProvider, err := getSavedOctaviaProvider(kubeClient) // Ignore error, just do the normal discovery then.
octaviaProvider, err := getSavedOctaviaProvider(kubeClient)
if err != nil && !apierrors.IsNotFound(err) { // Ignore 404, just do the normal discovery then.
return nil, errors.Wrap(err, "failed to get kuryr-config ConfigMap")
}
if octaviaProvider != "" {
log.Printf("Detected that Kuryr was already configured to use %s LB provider. Making sure to keep it that way.",
octaviaProvider)
Expand Down