Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
eea2092
pkg/cvo/sync_worker: Generalize CancelError to ContextError
wking May 28, 2020
adf8fd6
pkg/cvo/sync_worker: Do not treat "All errors were context errors..."…
wking May 28, 2020
99f6ba5
Merge pull request #378 from openshift-cherrypick-robot/cherry-pick-3…
openshift-merge-robot Jun 3, 2020
202578a
Expand supported set of probe field mutations
ironcladlou Jun 15, 2020
40ec7e4
Merge pull request #389 from openshift-cherrypick-robot/cherry-pick-3…
openshift-merge-robot Jun 19, 2020
2326bcc
Bug 1855577: Updating the golang.org/x/text version to v0.3.3
LalatenduMohanty Jul 14, 2020
dc662b7
pkg/cvo: Set NoDesiredImage reason when desired.Image is empty
wking May 27, 2020
f00e20f
pkg/cvo/status: Raise Operator leveling grace-period to 20 minutes
wking Jul 31, 2020
b0f92e5
Merge pull request #427 from wking/raise-operator-leveling-timeout-4.5
openshift-merge-robot Aug 19, 2020
9713dc5
Merge pull request #409 from openshift-cherrypick-robot/cherry-pick-4…
openshift-merge-robot Aug 20, 2020
55ff603
pkg/start: Drop the internal EnableMetrics
wking Apr 15, 2020
d257c32
pkg/cvo/metrics: Graceful server shutdown
wking Apr 15, 2020
f8774c0
pkg/start: Register metrics directly
wking Apr 15, 2020
d8ca134
pkg/cvo/egress: Pull HTTPS/Proxy egress into separate file
wking Apr 21, 2020
905b305
pkg/start: Release leader lease on graceful shutdown
wking Aug 3, 2020
c8af639
pkg/start/start_integration_test: Do not assume "deleted" for ConfigM…
wking Aug 5, 2020
c8f99b2
pkg/start: Fill in deferred HandleCrash
wking Aug 6, 2020
a42bfb7
cmd/start: Include the version in the outgoing log line
wking Aug 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pkg/cvo/egress: Pull HTTPS/Proxy egress into separate file
These are not just for available updates, they're also for downloading
signatures.  Placing them in a separate file makes it easier to focus
on the code that is specific to available updates.
  • Loading branch information
wking committed Aug 27, 2020
commit d8ca1343ff05215736ddaf299a4dc3b3d10f3b61
53 changes: 0 additions & 53 deletions pkg/cvo/availableupdates.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cvo

import (
"crypto/tls"
"crypto/x509"
"fmt"
"net/url"
"runtime"
Expand All @@ -11,7 +10,6 @@ import (
"github.com/blang/semver"
"github.com/google/uuid"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog"

Expand Down Expand Up @@ -197,54 +195,3 @@ func calculateAvailableUpdatesStatus(clusterID string, proxyURL *url.URL, tlsCon
LastTransitionTime: metav1.Now(),
}
}

// getHTTPSProxyURL returns a url.URL object for the configured
// https proxy only. It can be nil if does not exist or there is an error.
func (optr *Operator) getHTTPSProxyURL() (*url.URL, string, error) {
proxy, err := optr.proxyLister.Get("cluster")

if errors.IsNotFound(err) {
return nil, "", nil
}
if err != nil {
return nil, "", err
}

if &proxy.Spec != nil {
if proxy.Spec.HTTPSProxy != "" {
proxyURL, err := url.Parse(proxy.Spec.HTTPSProxy)
if err != nil {
return nil, "", err
}
return proxyURL, proxy.Spec.TrustedCA.Name, nil
}
}
return nil, "", nil
}

func (optr *Operator) getTLSConfig(cmNameRef string) (*tls.Config, error) {
cm, err := optr.cmConfigLister.Get(cmNameRef)

if err != nil {
return nil, err
}

certPool, _ := x509.SystemCertPool()
if certPool == nil {
certPool = x509.NewCertPool()
}

if cm.Data["ca-bundle.crt"] != "" {
if ok := certPool.AppendCertsFromPEM([]byte(cm.Data["ca-bundle.crt"])); !ok {
return nil, fmt.Errorf("unable to add ca-bundle.crt certificates")
}
} else {
return nil, nil
}

config := &tls.Config{
RootCAs: certPool,
}

return config, nil
}
61 changes: 61 additions & 0 deletions pkg/cvo/egress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cvo

import (
"crypto/tls"
"crypto/x509"
"fmt"
"net/url"

"k8s.io/apimachinery/pkg/api/errors"
)

// getHTTPSProxyURL returns a url.URL object for the configured
// https proxy only. It can be nil if does not exist or there is an error.
func (optr *Operator) getHTTPSProxyURL() (*url.URL, string, error) {
proxy, err := optr.proxyLister.Get("cluster")

if errors.IsNotFound(err) {
return nil, "", nil
}
if err != nil {
return nil, "", err
}

if &proxy.Spec != nil {
if proxy.Spec.HTTPSProxy != "" {
proxyURL, err := url.Parse(proxy.Spec.HTTPSProxy)
if err != nil {
return nil, "", err
}
return proxyURL, proxy.Spec.TrustedCA.Name, nil
}
}
return nil, "", nil
}

func (optr *Operator) getTLSConfig(cmNameRef string) (*tls.Config, error) {
cm, err := optr.cmConfigLister.Get(cmNameRef)

if err != nil {
return nil, err
}

certPool, _ := x509.SystemCertPool()
if certPool == nil {
certPool = x509.NewCertPool()
}

if cm.Data["ca-bundle.crt"] != "" {
if ok := certPool.AppendCertsFromPEM([]byte(cm.Data["ca-bundle.crt"])); !ok {
return nil, fmt.Errorf("unable to add ca-bundle.crt certificates")
}
} else {
return nil, nil
}

config := &tls.Config{
RootCAs: certPool,
}

return config, nil
}