Skip to content

Conversation

@danehans
Copy link
Contributor

TODOs

  • Verify whether an admission controller is being used for proxy validation.
  • HTTPS validation. If so, where is the trusted CA bundle located?
  • Unit tests.
  • Create client with infra, network, etc schemes registered from config/v1 api.
  • Check whether TrustedCA field being used. See Add Trusted CA to Proxy API type api#377. If so, is CA validation required?
  • Requires api bump that includes proxy ReadinessEndpoints and possibly TrustedCA.

@sttts @derekwaynecarr @deads2k @bparees @eparis @mrunalp PTAL

@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 16, 2019
@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 16, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: danehans
To complete the pull request process, please assign pweil-
You can assign the PR to them by writing /assign @pweil- in a comment when ready.

The full list of commands accepted by this bot can be found 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

@bparees
Copy link
Contributor

bparees commented Jul 16, 2019

Verify whether an admission controller is being used for proxy validation.

thought we all but concluded it could not be due to the need to dynamically update noproxy w/ the host node ips.

"net/url"

"k8s.io/apimachinery/pkg/util/sets"

Copy link
Contributor

Choose a reason for hiding this comment

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

no empty line

)


// Register registers a plugin
Copy link
Contributor

Choose a reason for hiding this comment

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

which?

return obj, nil
}

type proxyV1 struct {}
Copy link
Contributor

Choose a reason for hiding this comment

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

move up and add godoc describing what this admission plugin does.

allErrs := field.ErrorList{}

if len(spec.HTTPProxy) == 0 && len(spec.HTTPSProxy) == 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec.HTTPProxy"), spec.HTTPProxy, "must be set"))
Copy link
Contributor

Choose a reason for hiding this comment

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

why? These are optional. We also want to start with an empty object.

}
}
if len(spec.HTTPSProxy) != 0 {
if err := validateURI(spec.HTTPSProxy); 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.

does this have to be an https URI? similarly above

allErrs := field.ErrorList{}

if len(spec.HTTPProxy) == 0 && len(spec.HTTPSProxy) == 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec.HTTPProxy"), spec.HTTPProxy, "must be set"))
Copy link
Contributor

Choose a reason for hiding this comment

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

lower-case httpProxy. Same below

allErrs = append(allErrs, field.Invalid(field.NewPath("HTTPSProxy"), spec.HTTPSProxy, err.Error()))
}
}
if len(spec.ReadinessEndpoints) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for the if

}
}
}
if len(spec.NoProxy) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for the if

if len(spec.ReadinessEndpoints) != 0 {
for _, endpoint := range spec.ReadinessEndpoints {
if err := validateURI(endpoint); err != nil {
allErrs = append(allErrs, field.Invalid(field.NewPath("ReadinessEndpoints"), spec.ReadinessEndpoints, err.Error()))
Copy link
Contributor

Choose a reason for hiding this comment

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

lower-case ReadinessEndpoints

}
if len(spec.NoProxy) != 0 {
for _, v := range strings.Split(spec.NoProxy, ",") {
v = strings.TrimSpace(v)
Copy link
Contributor

Choose a reason for hiding this comment

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

why TrimSpace? Are spaces allowed? Why should they?

return allErrs
}

allErrs = append(allErrs, validateProxySpec(obj.Spec)...)
Copy link
Contributor

Choose a reason for hiding this comment

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

will we get an operator which writes the status? If yes, we have to enable the status subresource in the CRD. If no, we have to check that status is empty here.

Copy link
Contributor

Choose a reason for hiding this comment

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

similarly for update below

Copy link
Contributor

Choose a reason for hiding this comment

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

yes status will be written by a controller.

return nil
}

// validateReadinessEndpointWithRetries tries to validate the proxy readinessendpoint in a finite loop,
Copy link
Contributor

Choose a reason for hiding this comment

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

not that infinite: 3 ;-)


// runHTTPReadinessProbe issues an http GET request to endpoint and returns an error
// if a 2XX or 3XX http status code is not returned.
func runHTTPReadinessProbe(endpoint string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we split the file into validate.go, admission.go and readiness.go or something like that?

if err != nil {
return err
}
timeout := time.Duration(5) * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

move up as a constant

return err
}
timeout := time.Duration(5) * time.Second
resp, err := http.Get(url.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

this will break for https most probably, until we have a CA.

// TODO: Create client with configv1 scheme registered.
// Retrieve the cluster infrastructure config.
infraConfig := &configv1.Infrastructure{}
err = kubeClient.Get(context.TODO(), types.NamespacedName{Name: "cluster"}, infraConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

we have a typed client in openshift/client-go

if err != nil {
return "", err
}
apiServerURL, err := url.Parse(getAPIServerURL(infraConfig.Status.APIServerURL))
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 the LB domain, right? Are we sure we don't need a proxy for that? I expect this to depend a lot on the networking environment /cc @wking @squeed

@danehans
Copy link
Contributor Author

danehans commented Aug 2, 2019

PR based off #22102


// validateReadinessEndpointWithRetries tries to validate the proxy readinessendpoint in a finite loop,
// it returns the last result if it never succeeds.
func validateReadinessEndpointWithRetries(endpoint string, retries int) field.ErrorList {
Copy link
Contributor

Choose a reason for hiding this comment

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

we shouldn't be testing this here... it's being done in the controller when it goes to copy spec -> status now.

@bparees
Copy link
Contributor

bparees commented Aug 2, 2019

@danehans not sure how much, if any, of this is still needed?

we should be able to do some amount of basic spec validation via oapi schemas. If we want to do explicit syntax checking for things like urls, then i guess you probably still need this, but worst case the controller can catch those things when copying spec -> status and indicate an error.

@openshift-ci-robot
Copy link

@danehans: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/unit d9b8a9c link /test unit
ci/prow/e2e-aws d9b8a9c link /test e2e-aws
ci/prow/e2e-aws-serial d9b8a9c link /test e2e-aws-serial
ci/prow/images d9b8a9c link /test images
ci/prow/verify d9b8a9c link /test verify
ci/prow/integration d9b8a9c link /test integration
ci/prow/cmd d9b8a9c link /test cmd
ci/prow/images-artifacts d9b8a9c link /test images-artifacts
ci/prow/e2e-aws-upgrade d9b8a9c link /test e2e-aws-upgrade
ci/prow/e2e-gcp-upgrade d9b8a9c link /test e2e-gcp-upgrade

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 17, 2020
@danehans
Copy link
Contributor Author

Due to cluster-wide egress proxy architecture changes, this PR is no longer needed.

@danehans danehans closed this Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. 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