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

WINC-1152, OCPBUGS-24264: [cluster] Keep comma as delimiter in noProxy list #1998

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

saifshaikh48
Copy link
Contributor

Reverts an erroneous sanitization step in WMCO that replaced commas with semicolons in the user's cluster-wide proxy configuration. This was causing Windows to ignore the values set in the noProxy environment variable, incorrectly sending traffic through the proxy.

From the Azure PowerShell docs:
NO_PROXY: a comma-separated list of hostnames that should be excluded from proxying. [1]
noProxy list should not contain semicolon delimiters (;). Use (,) to delimit the noProxy domains. [2]

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 4, 2024
Copy link
Contributor

openshift-ci bot commented Jan 4, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Reverts an erroneous sanitization step in WMCO that replaced commas with
semicolons in the user's cluster-wide proxy configuration. This was
causing Windows to ignore the values set in the noProxy environment variable,
incorrectly sending traffic through the proxy.

From the Azure PowerShell docs:
`NO_PROXY: a comma-separated list of hostnames that should be excluded from proxying.`
`noProxy list should not contain semicolon delimiters (;). Use (,) to delimit the noProxy domains.`
@saifshaikh48
Copy link
Contributor Author

/test vsphere-proxy-e2e-operator
/test wicd-unit-vsphere

@saifshaikh48
Copy link
Contributor Author

/test vsphere-proxy-e2e-operator

Copy link
Contributor

@jrvaldes jrvaldes left a comment

Choose a reason for hiding this comment

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

@saifshaikh48 thanks for working on this. PTAL at my comments.

// on Windows, hostname lists are separated by semicolons rather than the Linux default of commas
sanitizedVal := strings.ReplaceAll(value, ",", ";")
clusterWideProxyVars[envVar] = sanitizedVal
clusterWideProxyVars[envVar] = value
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure about unquestioningly trusting the content of value. Does this mertis a check/validation here?

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about trimming spaces? How does Windows react to localhost, 127.0.0.2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Managing entities (CVO and/or OLM) do basic validations around this to ensure the URLs/domains are well-formed. No further checks needed from our side

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking more about the token separator, i.e. ; or ,

existingEnvVars: map[string]string{"NO_PROXY": "localhost;127.0.0.1", "HTTP_PROXY": "http://example.com"},
configMapEnvVars: map[string]string{"NO_PROXY": "localhost;127.0.0.1"},
existingEnvVars: map[string]string{"NO_PROXY": "localhost,127.0.0.1", "HTTP_PROXY": "http://example.com"},
configMapEnvVars: map[string]string{"NO_PROXY": "localhost,127.0.0.1"},
Copy link
Contributor

Choose a reason for hiding this comment

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

If a check is introduced, consider adding a test with an invalid value. e.g localhost;27.0.0.2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

semicolon-separated value is still valid from WICD unit test/Windows OS perspective. The WMCO e2e integration tests would fail/signal to handle this

@@ -366,9 +366,7 @@ func GetProxyVars() map[string]string {
for _, envVar := range WatchedEnvironmentVars {
Copy link
Contributor

Choose a reason for hiding this comment

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

clusterWideProxyVars = make(map[string]string, 3)

It might be out of scope, but consider avoiding the magic constant (3) with:

  clusterWideProxyVars = make(map[string]string, len(WatchedEnvironmentVars))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice find

@saifshaikh48
Copy link
Contributor Author

I was wondering why I thought semicolons were used in PS. Turns out the manual testing we did was using netsh, one of the only tools (along with Microsoft Edge CLI) that uses a bypass-list

To list multiple addresses and host names, separate them with blank spaces or semicolons in the proxy bypass string

@mansikulkarni96
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels Jan 8, 2024
@saifshaikh48
Copy link
Contributor Author

/test vsphere-proxy-e2e-operator
/test aws-e2e-upgrade

Comment on lines 78 to 80
if err != nil {
require.NoError(t, err)
}
Copy link
Contributor

@sebsoto sebsoto Jan 9, 2024

Choose a reason for hiding this comment

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

there should be no if statement
just require.NoError

test/e2e/proxy_test.go Show resolved Hide resolved
Comment on lines 87 to 89
command := "$response = $(Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/openshift/windows-machine-config-operator/master/README.md); $response.Headers['Via']"
out, err := tc.runPowerShellSSHJob("get-webrequest-via-header", command, addr)
require.NoErrorf(t, err, "unable to retrieve response 'Via' header")

viaHeader := strings.TrimSpace(out)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make a helper function for this.
such as func (tc *testContext) getOutboundProxy or getOutboundHTTPViaHeaders
A documented helper will help with code readability.

Copy link
Contributor

Choose a reason for hiding this comment

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

An example of the returned string would be good here.

Copy link
Contributor

Choose a reason for hiding this comment

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

it also stops the duplicated code thats occuring in the noproxy test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100%, will remove the code duplication in the final draft

Comment on lines 93 to 112
assert.Truef(t, viaHeader == clusterProxy.Status.HTTPProxy || viaHeader == clusterProxy.Status.HTTPSProxy,
"expected response header 'Via' to be either '%s' or '%s' but instead held value: '%s'",
clusterProxy.Status.HTTPProxy, clusterProxy.Status.HTTPSProxy, viaHeader)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can there be multiple via headers?
Seems that way looking at MDN docs.
How is that being handled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I'll change this to search for a via reader whose value is the cluster-wide proxy
along the lines of
$response.Headers["Via"] == clusterProxy.Status.HTTPProxy || $response.Headers["Via"] == clusterProxy.Status.HTTPSProxy

// TODO: circumvent the proxy if the target address is specified in the NO_PROXY list
func (tc *testContext) testNoProxyRequest(t *testing.T) {
clusterProxy, err := tc.client.Config.ConfigV1().Proxies().Get(context.TODO(), "cluster", meta.GetOptions{})
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.

drop the if

test/e2e/proxy_test.go Outdated Show resolved Hide resolved
addr, err := controllers.GetAddress(node.Status.Addresses)
require.NoError(t, err, "unable to get node address")

command := "$response = $(Invoke-WebRequest -UseBasicParsing https://raw.githubusercontent.com/openshift/windows-machine-config-operator/master/README.md); $response.Headers['Via']"
Copy link
Contributor

Choose a reason for hiding this comment

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

remind me, is this only for external connections?
can we launch a service and query that via DNS so we arent relying on google and github?

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 had thought of that initially but, yes external requests only

@saifshaikh48 saifshaikh48 force-pushed the commas-in-noproxy branch 2 times, most recently from c443b9e to 352653a Compare January 9, 2024 18:00
@@ -39,6 +39,9 @@ const (
// userCABundleName is the name of the ConfigMap that holds additional user-provided proxy certs
userCABundleName = "user-ca-bundle"
userCABundleNamespace = "openshift-config"

// whitelist is a list of domains that are not to be proxied
whitelist = "static.redhat.com,redhat.io,google.com"
Copy link
Contributor

Choose a reason for hiding this comment

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

s/whitelist/noProxyList

@@ -39,6 +39,9 @@ const (
// userCABundleName is the name of the ConfigMap that holds additional user-provided proxy certs
userCABundleName = "user-ca-bundle"
userCABundleNamespace = "openshift-config"

// whitelist is a list of domains that are not to be proxied
Copy link
Contributor

Choose a reason for hiding this comment

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

noProxy is a comma-separated list of hostnames and/or CIDRs and/or IPs for
which the proxy should not be used.

As per oc explain proxies.spec.noProxy.

@@ -351,6 +405,21 @@ func (tc *testContext) getEnvVar(addr, name, command string) (map[string]string,
return parseWindowsEnvVars(out), nil
}

// configureNoProxy configures the cluster-wide proxy's bypass list with specific URLs for testing purposes
func (tc *testContext) configureNoProxy() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider passing the no proxy list as a parameter of the function.

Comment on lines +417 to +486
if err != nil {
return fmt.Errorf("unable to patch %s: %w", string(patchData), err)
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider returning just err instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

prefer more context here IMO. Having the patchData in the error makes it much easier to debug if something goes wrong

@saifshaikh48
Copy link
Contributor Author

/test vsphere-proxy-e2e-operator

1 similar comment
@saifshaikh48
Copy link
Contributor Author

/test vsphere-proxy-e2e-operator

Copy link
Member

@mansikulkarni96 mansikulkarni96 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @saifshaikh48 . This looks much clear and concise.

})

t.Run("NO_PROXY request", func(t *testing.T) {
whitelistedUrl := "google.com"
Copy link
Member

Choose a reason for hiding this comment

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

how about permitted/nonproxied URL

@saifshaikh48 saifshaikh48 force-pushed the commas-in-noproxy branch 2 times, most recently from 236d1d3 to 615e880 Compare January 11, 2024 18:32
@saifshaikh48 saifshaikh48 changed the title WIP: [cluster] Keep comma as delimiter in noProxy list OCPBUGS-24264, OCPBUGS-19997: [cluster] Keep comma as delimiter in noProxy list Jan 11, 2024
@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jan 11, 2024
@openshift-ci-robot
Copy link

@saifshaikh48: This pull request references Jira Issue OCPBUGS-19997, which is invalid:

  • expected the bug to target the "4.16.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

Reverts an erroneous sanitization step in WMCO that replaced commas with semicolons in the user's cluster-wide proxy configuration. This was causing Windows to ignore the values set in the noProxy environment variable, incorrectly sending traffic through the proxy.

From the Azure PowerShell docs:
NO_PROXY: a comma-separated list of hostnames that should be excluded from proxying. [1]
noProxy list should not contain semicolon delimiters (;). Use (,) to delimit the noProxy domains. [2]

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 15, 2024
@alinaryan
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 15, 2024
@saifshaikh48
Copy link
Contributor Author

/test vsphere-proxy-e2e-operator

}

// verifyCurlOutput parses the output of a curl request searching for any proxy variables in use and proxy headers
func verifyCurlOutput(output, httpProxyURL, noProxyList string) (bool, bool, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be named noProxyList, or noProxyURL?
if a comma separated list is passed in would that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A list works (that’s what the test does now) and a single URL would also work (if the noProxy value in the cluster wide proxy was just a single URL)

Copy link
Contributor

openshift-ci bot commented Jan 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: saifshaikh48, sebsoto

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 15, 2024
@saifshaikh48 saifshaikh48 marked this pull request as ready for review January 15, 2024 22:41
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 15, 2024
@saifshaikh48
Copy link
Contributor Author

/cherry-pick release-4.15

@openshift-cherrypick-robot

@saifshaikh48: once the present PR merges, I will cherry-pick it on top of release-4.15 in a new PR and assign it to you.

In response to this:

/cherry-pick release-4.15

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.

@saifshaikh48
Copy link
Contributor Author

/cherry-pick release-4.14

@openshift-cherrypick-robot

@saifshaikh48: once the present PR merges, I will cherry-pick it on top of release-4.14 in a new PR and assign it to you.

In response to this:

/cherry-pick release-4.14

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.

@saifshaikh48
Copy link
Contributor Author

/retest-required

Not sure why none of the e2e tests are kicking off automatically.

@saifshaikh48
Copy link
Contributor Author

/test aws-e2e-operator
/test aws-e2e-upgrade
/test azure-e2e-operator
/test azure-e2e-upgrade
/test gcp-e2e-operator
/test nutanix-e2e-operator
/test platform-none-vsphere-e2e-operator
/test vsphere-e2e-operator
/test wicd-unit-vsphere

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 74fd810 and 2 for PR HEAD aa5e824 in total

@saifshaikh48
Copy link
Contributor Author

/test aws-e2e-upgrade

Copy link
Contributor

openshift-ci bot commented Jan 16, 2024

@saifshaikh48: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 626d09c into openshift:master Jan 16, 2024
17 checks passed
@openshift-ci-robot
Copy link

@saifshaikh48: Jira Issue OCPBUGS-24264: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-24264 has been moved to the MODIFIED state.

In response to this:

Reverts an erroneous sanitization step in WMCO that replaced commas with semicolons in the user's cluster-wide proxy configuration. This was causing Windows to ignore the values set in the noProxy environment variable, incorrectly sending traffic through the proxy.

From the Azure PowerShell docs:
NO_PROXY: a comma-separated list of hostnames that should be excluded from proxying. [1]
noProxy list should not contain semicolon delimiters (;). Use (,) to delimit the noProxy domains. [2]

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-cherrypick-robot

@saifshaikh48: new pull request created: #2015

In response to this:

/cherry-pick release-4.15

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-cherrypick-robot

@saifshaikh48: new pull request created: #2016

In response to this:

/cherry-pick release-4.14

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.

@jrvaldes
Copy link
Contributor

/retitle WINC-1152, OCPBUGS-24264: [cluster] Keep comma as delimiter in noProxy list

@openshift-ci openshift-ci bot changed the title OCPBUGS-24264: [cluster] Keep comma as delimiter in noProxy list WINC-1152, OCPBUGS-24264: [cluster] Keep comma as delimiter in noProxy list Apr 23, 2024
@jrvaldes
Copy link
Contributor

/jira refresh

@openshift-ci-robot
Copy link

@jrvaldes: Jira Issue OCPBUGS-24264 is in an unrecognized state (Verified) and will not be moved to the MODIFIED state.

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

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. jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants