-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Revisions should wait for minScale replicas to report ready #3493
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
Merged
knative-prow-robot
merged 6 commits into
knative:master
from
joshrider:min-scale-readiness
May 27, 2019
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bd3f49d
revisions become ready with minScale reached
joshrider 4a65cf6
remove redundant condition
joshrider 7978faa
revert accidental spacing changes
joshrider f60addb
cleanup test helpers
joshrider 2965aa0
cleanup tests
joshrider 946e45c
remove copypasted comment
joshrider 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // +build e2e | ||
|
|
||
| /* | ||
| Copyright 2019 The Knative Authors | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package e2e | ||
|
|
||
| import ( | ||
| "strconv" | ||
| "testing" | ||
|
|
||
| "github.com/knative/serving/pkg/apis/autoscaling" | ||
| "github.com/knative/serving/pkg/apis/serving/v1alpha1" | ||
| "github.com/knative/serving/test" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| func TestMinScale(t *testing.T) { | ||
| const minScale = 4 | ||
|
|
||
| clients := Setup(t) | ||
|
|
||
| names := test.ResourceNames{ | ||
| Config: test.ObjectNameForTest(t), | ||
| Image: "helloworld", | ||
| } | ||
|
|
||
| if _, err := test.CreateConfiguration(t, clients, names, &test.Options{}, func(cfg *v1alpha1.Configuration) { | ||
| if cfg.Spec.Template.Annotations == nil { | ||
| cfg.Spec.Template.Annotations = make(map[string]string) | ||
| } | ||
|
|
||
| cfg.Spec.Template.Annotations[autoscaling.MinScaleAnnotationKey] = strconv.Itoa(minScale) | ||
|
|
||
| }); err != nil { | ||
| t.Fatalf("Failed to create Configuration: %v", err) | ||
| } | ||
|
|
||
| test.CleanupOnInterrupt(func() { test.TearDown(clients, names) }) | ||
| defer test.TearDown(clients, names) | ||
|
|
||
| // Wait for the Config have a LatestCreatedRevisionName | ||
| if err := test.WaitForConfigurationState(clients.ServingClient, names.Config, test.ConfigurationHasCreatedRevision, "ConfigurationHasCreatedRevision"); err != nil { | ||
| t.Fatalf("The Configuration %q does not have a LatestCreatedRevisionName: %v", names.Config, err) | ||
| } | ||
|
|
||
| config, err := clients.ServingClient.Configs.Get(names.Config, metav1.GetOptions{}) | ||
| if err != nil { | ||
| t.Fatalf("Failed to get Configuration after it was seen to be live: %v", err) | ||
| } | ||
|
|
||
| revName := config.Status.LatestCreatedRevisionName | ||
|
|
||
| if err = test.WaitForRevisionState(clients.ServingClient, revName, test.IsRevisionReady, "RevisionIsReady"); err != nil { | ||
| t.Fatal("Revision did not become ready.") | ||
| } | ||
|
|
||
| deployment, err := clients.KubeClient.Kube.ExtensionsV1beta1().Deployments(test.ServingNamespace).Get(revName+"-deployment", metav1.GetOptions{}) | ||
| if err != nil { | ||
| t.Fatalf("Failed to get Deployment for Revision %s, err: %v", revName, err) | ||
| } | ||
|
|
||
| if deployment.Status.AvailableReplicas < int32(minScale) { | ||
| t.Fatalf("Reported ready with %d replicas when minScale was %d", deployment.Status.AvailableReplicas, minScale) | ||
| } | ||
| } |
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.
why not
desiredScale = scaleUnknownstill?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.
Note: I'm not asking about the condition, but the early return.
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.
It was put into place to accommodate the moved
desiredScale < 0guard in the caller in order to maintain the existing functionality of returningscaleUnknownand not "applying" the scale.Happy to move the
desiredScale < 0check back and switch this over if it's preferred.