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

Fix haproxy router config manager issue where sanitize pems cause a blueprint route to not be selected #20646

Merged

Conversation

ramr
Copy link
Contributor

@ramr ramr commented Aug 15, 2018

Fix haproxy router config manager issue where sanitize pems don't match when
extended validation is enabled (causes a reload where none is needed).
fixes bugz #1615802
(Sorta depends on #20630 to merge to test dynamic blueprint changes).

/cc @openshift/sig-network-edge

@openshift-ci-robot openshift-ci-robot added sig/network-edge size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 15, 2018
@@ -915,8 +928,23 @@ func (entry *routeBackendEntry) BuildMapAssociations(route *routeapi.Route) {
}
}

// validateBlueprint runs extended validation on a blueprint route.
func validateBlueprintRoute(route *routeapi.Route) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

The function name in the comment and the actual function name differ.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack will fix - thx.

@@ -915,8 +928,23 @@ func (entry *routeBackendEntry) BuildMapAssociations(route *routeapi.Route) {
}
}

// validateBlueprint runs extended validation on a blueprint route.
func validateBlueprintRoute(route *routeapi.Route) error {
errs := validation.ExtendedValidateRoute(route)
Copy link
Contributor

Choose a reason for hiding this comment

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

Check out this package for easier aggregated error handling.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - will use.

@@ -199,6 +204,14 @@ func (cm *haproxyConfigManager) AddBlueprint(route *routeapi.Route) {
newRoute.Namespace = blueprintRoutePoolNamespace
newRoute.Spec.Host = ""

if cm.extendedValidation {
if err := validateBlueprintRoute(newRoute); err != nil {
glog.Errorf("Skipping blueprint route %s/%s due to invalid configuration: %v",
Copy link
Contributor

Choose a reason for hiding this comment

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

If invalid routes are present, what's the impact to the cluster, and what action must the admin take? What's the likelihood the admin would ever see this error? Are invalid blueprint route errors surfaced in some other way (e.g. via status)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So in the normal case if a route is invalid, the route is not admitted by the router and the status is updated (if router has perms) with the invalidation errors.

In the case of blueprint routes, we aren't really updating the status - it may well end up happening (explained below) but we can only log here that there was an error and ignore that blueprint.

Now its possible the blueprint route is in a namespace that is also being served by the router - in which case the router will update the status of the blueprint route (well as far as the router is concerned in this case its just another route) with the errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will the error continue to happen every resync interval as long as the naughty route exists? Would an event be more useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, that's true - yeah, it would happen every resync interval.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ironcladlou looked at event generation fixes here - it might end up being a wee bit too invasive here for a bug fix as we don't have the client here, etc.
I'd rather do that separately in a follow on PR - which you can decide whether or not to put in this release. That sound good?

Copy link
Contributor

Choose a reason for hiding this comment

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

Had a chance to actually read some of the controller code.... looks like the admin controls the namespace containing the route templates, and so probably also controls the routes in the blueprint namespace. So, if there's an invalid route there which was causing an issue of any kind, the route could presumably be modified to be valid or be removed. Does that sound accurate? Thanks for being patient with explanations!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that is correct - the admin does control the namespace.
So generating an event might be a wee bit lower in priority but I think generating an event will still be better (after logging an initial error).

…ch when

extended validation is enabled (causes a reload where none is needed).
fixes bugz #1615802
  o address review comments.
@ramr ramr force-pushed the fix-extended-validation-diffs branch from fc23518 to 8773471 Compare August 15, 2018 21:48
@@ -915,8 +928,18 @@ func (entry *routeBackendEntry) BuildMapAssociations(route *routeapi.Route) {
}
}

// validateBlueprintRoute runs extended validation on a blueprint route.
func validateBlueprintRoute(route *routeapi.Route) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can actually delete this entire function and replace all usages with:

if err := validation.ExtendedValidateRoute(newRoute).ToAggregate(); err != nil {
	glog.Errorf("Skipping blueprint route %s/%s due to invalid configuration: %s", route.Namespace, route.Name, err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do it in a followup. Thx

@ironcladlou
Copy link
Contributor

@ramr Just a small nit with some potentially redundant code (#20646 (comment)), no reason to block on it. Can refactor in a tiny followup if you agree. Thanks for the fix!

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 16, 2018
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ironcladlou, ramr

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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 16, 2018
@openshift-merge-robot openshift-merge-robot merged commit e787316 into openshift:master Aug 16, 2018
@ramr ramr deleted the fix-extended-validation-diffs branch August 16, 2018 20:39
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. sig/network-edge size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants