-
Notifications
You must be signed in to change notification settings - Fork 212
Add http transport for cincinnati to enable proxy #219
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
Conversation
|
https://github.com/openshift/cluster-version-operator/blob/master/vendor/github.com/openshift/api/config/v1/types_proxy.go |
|
@abhinavdahiya when you have a moment to take a look for a initial review, thanks! |
pkg/cvo/availableupdates.go
Outdated
|
|
||
| func getHTTPTransportProxy() (*http.Transport, error) { | ||
| transport := http.Transport{} | ||
| config, err := rest.InClusterConfig() |
There was a problem hiding this comment.
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
pkg/cincinnati/cincinnati.go
Outdated
| // 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 { |
There was a problem hiding this comment.
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. | ||
| ) | ||
|
|
There was a problem hiding this comment.
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
|
@abhinavdahiya updated PTAL. I will work on tests once everything else looks good. Thanks! |
pkg/cincinnati/cincinnati.go
Outdated
| // 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 { |
There was a problem hiding this comment.
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" | ||
|
|
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see https://github.com/openshift/cluster-version-operator/pull/219/files#r301772882
we should do a no-op when the type doesn't exist.
pkg/cincinnati/cincinnati.go
Outdated
| type Client struct { | ||
| id uuid.UUID | ||
| id uuid.UUID | ||
| url *url.URL |
There was a problem hiding this comment.
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
|
/retest |
pkg/cvo/cvo.go
Outdated
| } | ||
|
|
||
| discover := kubeClient.Discovery() | ||
| apiResourcesList, err := discover.ServerResourcesForGroupVersion("config.openshift.io/v1") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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.
pkg/cvo/availableupdates.go
Outdated
|
|
||
| if errors.IsNotFound(err) { | ||
| return nil, nil | ||
| } else if err != nil { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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{}) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
pkg/cvo/availableupdates.go
Outdated
| } | ||
|
|
||
| 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) { |
There was a problem hiding this comment.
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.
- 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
|
/lgtm /retest |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/test e2e-aws |
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.
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
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
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
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
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.
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.
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.
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.
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
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
so that a https proxy can be set
retrieves the proxy config, creates the transport and returns the
transport ptr.