-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[configName].Status.LatestReadyRevisionName | ||
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. | ||
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 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{}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.