Skip to content

Conversation

@jcpowermac
Copy link
Contributor

  • Modified Cincinnati client to accept the http transport struct
    so that a https proxy can be set
  • Created new function getHTTPTransportProxy that
    retrieves the proxy config, creates the transport and returns the
    transport ptr.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 5, 2019
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 5, 2019
@jcpowermac
Copy link
Contributor Author

https://github.com/openshift/cluster-version-operator/blob/master/vendor/github.com/openshift/api/config/v1/types_proxy.go
Does not have ProxyStatus. Either update or switch to using proxy.Spec instead of proxy.Status.

# github.com/openshift/cluster-version-operator/pkg/cvo pkg/cvo/availableupdates.go:204:10: proxy.Status undefined...enshift/api/config/v1".Proxy has no field or method Status)

@jcpowermac
Copy link
Contributor Author

@abhinavdahiya when you have a moment to take a look for a initial review, thanks!


func getHTTPTransportProxy() (*http.Transport, error) {
transport := http.Transport{}
config, err := rest.InClusterConfig()
Copy link
Contributor

Choose a reason for hiding this comment

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

You cannot create a new config here, please reuse the one in the operator struct already.

Or add proxy type client /listers to the operator struct and use here...

That would help in integration tests

// NewClient creates a new Cincinnati client with the given client identifier.
func NewClient(id uuid.UUID) Client {
return Client{id: id}
func NewClient(id uuid.UUID, transport *http.Transport) Client {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is pretty broad additon..
I think a restricted proxy information and creating a transport with that is more ideal.

"github.com/google/uuid"
_ "k8s.io/klog" // integration tests set glog flags.
)

Copy link
Contributor

Choose a reason for hiding this comment

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

Would also like to see proxy tests here or in integration tests

@jcpowermac
Copy link
Contributor Author

@abhinavdahiya updated PTAL. I will work on tests once everything else looks good. Thanks!

// NewClient creates a new Cincinnati client with the given client identifier.
func NewClient(id uuid.UUID) Client {
return Client{id: id}
func NewClient(id uuid.UUID, url *url.URL) Client {
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the url, comments will be useful

"k8s.io/klog"

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

Copy link
Contributor

Choose a reason for hiding this comment

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

extra line

pkg/cvo/cvo.go Outdated
proxyInformer.Informer().AddEventHandler(optr.eventHandler())

optr.proxyLister = proxyInformer.Lister()
optr.cacheSynced = append(optr.cacheSynced, proxyInformer.Informer().HasSynced)
Copy link
Contributor

Choose a reason for hiding this comment

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

4.2 the type exists for proxy.
but 4.1 the type doesn't exit for proxy.

So when user goes from 4.1.z to 4.2.z ; the CVO updates itself to a version that expects proxy type to exist, but the proxy type will be created by the cluster-config-operator. So this cache will never sync and CVO will be stuck.

So it's important our changes keep in mind that the type might not exist.

func (optr *Operator) getHTTPSProxyURL() (*url.URL, error) {
proxy, err := optr.proxyLister.Get("cluster")

if errors.IsNotFound(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

type Client struct {
id uuid.UUID
id uuid.UUID
url *url.URL
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, how is url separate from upstream in GetUpdates

@jcpowermac
Copy link
Contributor Author

/retest

pkg/cvo/cvo.go Outdated
}

discover := kubeClient.Discovery()
apiResourcesList, err := discover.ServerResourcesForGroupVersion("config.openshift.io/v1")
Copy link
Contributor

@abhinavdahiya abhinavdahiya Jul 15, 2019

Choose a reason for hiding this comment

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

The discovery is not useful.. this will always be false for CVO start...

the proxy CRD is created by an top-level operator cluster-config-operator... that is created by cluster-version-operator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If that is the case how would we check if Proxy kind exists? It seems like any check would fail based on the above description.

Copy link
Contributor

@abhinavdahiya abhinavdahiya Jul 15, 2019

Choose a reason for hiding this comment

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

when you go to GET proxy object and you get not found, you don't use the proxy codepath..

Copy link
Contributor

Choose a reason for hiding this comment

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

if the proxy api exists and the resource exists, you will be able to GET successfully and then we should start using the Proxy codepath.


if errors.IsNotFound(err) {
return nil, nil
} else if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need the else if ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking we would want to know what the error was if it was anything except IsNotFound

Copy link
Contributor

Choose a reason for hiding this comment

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

errros.IsNotFound only returns true when the err is not-found..
ie if err is nil, it will not be true.. and if err is not-nil and but not not-found, it will not be true..

so

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

cover's all the cases...

pkg/cvo/cvo.go Outdated
proxyExists: false,
}

_, err := client.ConfigV1().Proxies().Get("cluster", metav1.GetOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

there's no requirement for this conditional setup of the informer.

pkg/cvo/cvo.go Outdated
if err == nil {
optr.proxyLister = proxyInformer.Lister()
proxyInformer.Informer().AddEventHandler(optr.eventHandler())
optr.cacheSynced = append(optr.cacheSynced, proxyInformer.Informer().HasSynced)
Copy link
Contributor

Choose a reason for hiding this comment

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

just drop the proxy from cachedSynced... it's goal is to make sure we don't start action on inconsistent cache... but there's no such requirement for proxy informer.

}

func calculateAvailableUpdatesStatus(clusterID, upstream, channel, version string) ([]configv1.Update, configv1.ClusterOperatorStatusCondition) {
func calculateAvailableUpdatesStatus(clusterID, upstream, channel, version string, proxyURL *url.URL) ([]configv1.Update, configv1.ClusterOperatorStatusCondition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

proxyURL should be next to clusterID.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 15, 2019
- Modified Cincinnati client to accept a url.URL
so that a https proxy can be set
- Created new function getHTTPSProxyURL() that
retrieves the proxy config, creates the url.URL and returns the
url ptr.
- Modified tests to include proxy lister
- Added ProxyLister to Operator struct, modified New()
- Modified start.go for ProxyLister operator struct change
@jcpowermac jcpowermac changed the title [WIP] Add http transport for cincinnati to enable proxy Add http transport for cincinnati to enable proxy Jul 16, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 16, 2019
@abhinavdahiya
Copy link
Contributor

/lgtm

/retest

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 18, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, jcpowermac

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 18, 2019
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@jcpowermac
Copy link
Contributor Author

/test e2e-aws

@openshift-merge-robot openshift-merge-robot merged commit eedb815 into openshift:master Jul 19, 2019
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 2, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been loading proxy config from
the spec property.  We should be loading from status instead, so we
benefit from the network operator's validation.  Risk is small,
because unlike some other in-cluster components, the CVO is unlikely
to break things if it is temporarily consuming a broken proxy
configuration.

This is similar to c9fab43 (pkg/cvo: Fetch proxy CA certs from
openshift-config-managed/trusted-ca-bundle, 2020-01-31, openshift#311), where
we moved our trusted CA source from the user-configured ConfigMap to
the network-operator-validated ConfigMap.
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 3, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been consuming httpsProxy, but
not httpProxy or noProxy [1].  This commit fixes that.  I'm handing
off the logic that mixes those three together to pick the proxy URI to
the httpproxy library, which is also what the Go standard library uses
for this purpose.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1978749
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 3, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been consuming httpsProxy, but
not httpProxy or noProxy [1].  This commit fixes that.  I'm handing
off the logic that mixes those three together to pick the proxy URI to
the httpproxy library, which is also what the Go standard library uses
for this purpose.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1978749
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 3, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been consuming httpsProxy, but
not httpProxy or noProxy [1].  This commit fixes that.  I'm handing
off the logic that mixes those three together to pick the proxy URI to
the httpproxy library, which is also what the Go standard library uses
for this purpose.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1978749
wking added a commit to wking/cluster-version-operator that referenced this pull request Jul 5, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been consuming httpsProxy, but
not httpProxy or noProxy [1].  This commit fixes that.  I'm handing
off the logic that mixes those three together to pick the proxy URI to
the httpproxy library, which is also what the Go standard library uses
for this purpose.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1978749
palonsoro added a commit to palonsoro/cluster-version-operator that referenced this pull request Jul 8, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been loading proxy config from
the spec property.  We should be loading from status instead, so we
benefit from the network operator's validation.  Risk is small,
because unlike some other in-cluster components, the CVO is unlikely
to break things if it is temporarily consuming a broken proxy
configuration.

This is similar to c9fab43 (pkg/cvo: Fetch proxy CA certs from
openshift-config-managed/trusted-ca-bundle, 2020-01-31, openshift#311), where
we moved our trusted CA source from the user-configured ConfigMap to
the network-operator-validated ConfigMap.
jottofar pushed a commit to jottofar/cluster-version-operator that referenced this pull request Sep 24, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been loading proxy config from
the spec property.  We should be loading from status instead, so we
benefit from the network operator's validation.  Risk is small,
because unlike some other in-cluster components, the CVO is unlikely
to break things if it is temporarily consuming a broken proxy
configuration.

This is similar to c9fab43 (pkg/cvo: Fetch proxy CA certs from
openshift-config-managed/trusted-ca-bundle, 2020-01-31, openshift#311), where
we moved our trusted CA source from the user-configured ConfigMap to
the network-operator-validated ConfigMap.
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/cluster-version-operator that referenced this pull request Sep 24, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been loading proxy config from
the spec property.  We should be loading from status instead, so we
benefit from the network operator's validation.  Risk is small,
because unlike some other in-cluster components, the CVO is unlikely
to break things if it is temporarily consuming a broken proxy
configuration.

This is similar to c9fab43 (pkg/cvo: Fetch proxy CA certs from
openshift-config-managed/trusted-ca-bundle, 2020-01-31, openshift#311), where
we moved our trusted CA source from the user-configured ConfigMap to
the network-operator-validated ConfigMap.
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/cluster-version-operator that referenced this pull request Oct 14, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been loading proxy config from
the spec property.  We should be loading from status instead, so we
benefit from the network operator's validation.  Risk is small,
because unlike some other in-cluster components, the CVO is unlikely
to break things if it is temporarily consuming a broken proxy
configuration.

This is similar to c9fab43 (pkg/cvo: Fetch proxy CA certs from
openshift-config-managed/trusted-ca-bundle, 2020-01-31, openshift#311), where
we moved our trusted CA source from the user-configured ConfigMap to
the network-operator-validated ConfigMap.
palonsoro pushed a commit to palonsoro/cluster-version-operator that referenced this pull request Nov 12, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been consuming httpsProxy, but
not httpProxy or noProxy [1].  This commit fixes that.  I'm handing
off the logic that mixes those three together to pick the proxy URI to
the httpproxy library, which is also what the Go standard library uses
for this purpose.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1978749

Cherry-pick of: e43080d
palonsoro pushed a commit to palonsoro/cluster-version-operator that referenced this pull request Dec 10, 2021
Since 4.2's ea5e3bc (Add http transport for cincinnati to enable
proxy, 2019-07-16, openshift#219), the CVO has been consuming httpsProxy, but
not httpProxy or noProxy [1].  This commit fixes that.  I'm handing
off the logic that mixes those three together to pick the proxy URI to
the httpproxy library, which is also what the Go standard library uses
for this purpose.

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1978749

Cherry-pick of: e43080d
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. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants