-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Also provision empty route rules for revisions that are not yet Active #785
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -764,6 +764,48 @@ func (c *Controller) computeRevisionRoutes( | |
return ret, nil | ||
} | ||
|
||
// computeEmptyRevisionRoutes is a hack to work around https://github.com/istio/istio/issues/5204. | ||
// Here we add empty/dummy route rules for non-target revisions to prepare to switch traffic to | ||
// them in the future. We are tracking this issue in https://github.com/elafros/elafros/issues/348. | ||
// | ||
// TODO: Even though this fixes the 503s when switching revisions, revisions will have empty route | ||
// rules to them for perpetuity, therefore not ideal. We should remove this hack once | ||
// https://github.com/istio/istio/issues/5204 is fixed, probably in 0.8.1. | ||
func (c *Controller) computeEmptyRevisionRoutes( | ||
route *v1alpha1.Route, configMap map[string]*v1alpha1.Configuration, revMap map[string]*v1alpha1.Revision) ([]RevisionRoute, error) { | ||
ns := route.Namespace | ||
elaNS := controller.GetElaNamespaceName(ns) | ||
revClient := c.elaclientset.ElafrosV1alpha1().Revisions(ns) | ||
revRoutes := []RevisionRoute{} | ||
for _, tt := range route.Spec.Traffic { | ||
configName := tt.ConfigurationName | ||
if configName != "" { | ||
// Get the configuration's LatestReadyRevisionName | ||
latestReadyRevName := configMap[tt.ConfigurationName].Status.LatestReadyRevisionName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
revs, err := revClient.List(metav1.ListOptions{ | ||
LabelSelector: fmt.Sprintf("%s=%s", ela.ConfigurationLabelKey, configName), | ||
}) | ||
if err != nil { | ||
glog.Errorf("Failed to fetch revisions of Configuration %q: %s", configName, err) | ||
return nil, err | ||
} | ||
for _, rev := range revs.Items { | ||
if _, ok := revMap[rev.Name]; !ok && rev.Name != latestReadyRevName { | ||
// This is a non-target revision. Adding a dummy rule to make Istio happy, | ||
// so that if we switch traffic to them later we won't cause Istio to | ||
// throw spurious 503s. See https://github.com/istio/istio/issues/5204. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this loop pretty hard to follow. Since I believe this is a temporary workaround, I think it would be better to have:
Above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I believe this means that the number of routes will monotonically increase and that revisions will remain routable in perpetuity, which certainly shouldn't be the end state. We should be clear about the trade-offs here while we wait on a proper fix from Istio. |
||
revRoutes = append(revRoutes, RevisionRoute{ | ||
RevisionName: rev.Name, | ||
Service: fmt.Sprintf("%s.%s", rev.Status.ServiceName, elaNS), | ||
Weight: 0, | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
return revRoutes, nil | ||
} | ||
|
||
func (c *Controller) createOrUpdateRouteRules(route *v1alpha1.Route, configMap map[string]*v1alpha1.Configuration, | ||
revMap map[string]*v1alpha1.Revision) ([]RevisionRoute, error) { | ||
// grab a client that's specific to RouteRule. | ||
|
@@ -789,7 +831,13 @@ func (c *Controller) createOrUpdateRouteRules(route *v1alpha1.Route, configMap m | |
glog.Errorf("Failed to check if should direct traffic to activator: %s", err) | ||
return nil, err | ||
} | ||
|
||
// TODO: remove this once https://github.com/istio/istio/issues/5204 is fixe. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: fixed |
||
emptyRoutes, err := c.computeEmptyRevisionRoutes(route, configMap, revMap) | ||
if err != nil { | ||
glog.Errorf("Failed to get empty routes for %s : %q", route.Name, err) | ||
return nil, err | ||
} | ||
revisionRoutes = append(revisionRoutes, emptyRoutes...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this will be significantly easier to excise later when Istio fixes things! |
||
// Create route rule for the route domain | ||
routeRuleName := controller.GetRouteRuleName(route, nil) | ||
routeRules, err := routeClient.Get(routeRuleName, 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.