Skip to content

Commit 4a7299f

Browse files
tcnghiaknative-prow-robot
authored andcommitted
More output for Blue/Green test when Revision fails to come up. (knative#1948)
* BlueGreenTest to allow inactive revisions. Print Status when fail. * Revert to waiting for Revision to be Ready. Added explanation.
1 parent 85de339 commit 4a7299f

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

test/conformance/blue_green_test.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ func sendRequests(client spoof.Interface, domain string, num int) ([]string, err
8989
return nil
9090
})
9191
}
92-
9392
return responses, g.Wait()
9493
}
9594

@@ -208,14 +207,22 @@ func TestBlueGreenRoute(t *testing.T) {
208207
t.Fatalf("Configuration %s was not updated with the Revision for image %s: %v", names.Config, image2, err)
209208
}
210209

211-
// TODO(#882): Remove these?
210+
// We should only need to wait until the Revision is routable,
211+
// i.e. Ready or Inactive. At that point, activator could start
212+
// queuing requests until the Revision wakes up. However, due to
213+
// #882 we are currently lumping the inactive splits and that
214+
// would result in 100% requests reaching Blue or Green.
215+
//
216+
// TODO: After we implement #1583 and honor the split percentage
217+
// for inactive cases, change this wait to allow for inactive
218+
// revisions as well.
212219
logger.Infof("Waiting for revision %q to be ready", blue.Revision)
213220
if err := test.WaitForRevisionState(clients.ServingClient, blue.Revision, test.IsRevisionReady, "RevisionIsReady"); err != nil {
214-
t.Fatalf("The Revision %q was not marked as Ready: %v", blue.Revision, err)
221+
t.Fatalf("The Revision %q still can't serve traffic: %v", blue.Revision, err)
215222
}
216223
logger.Infof("Waiting for revision %q to be ready", green.Revision)
217224
if err := test.WaitForRevisionState(clients.ServingClient, green.Revision, test.IsRevisionReady, "RevisionIsReady"); err != nil {
218-
t.Fatalf("The Revision %q was not marked as Ready: %v", green.Revision, err)
225+
t.Fatalf("The Revision %q still can't serve traffic: %v", green.Revision, err)
219226
}
220227

221228
// Set names for traffic targets to make them directly routable.

test/crd_checks.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
pkgTest "github.com/knative/pkg/test"
2828
"github.com/knative/serving/pkg/apis/serving/v1alpha1"
29+
"github.com/pkg/errors"
2930
"go.opencensus.io/trace"
3031
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3132
"k8s.io/apimachinery/pkg/util/wait"
@@ -34,7 +35,7 @@ import (
3435

3536
const (
3637
interval = 1 * time.Second
37-
timeout = 5 * time.Minute
38+
timeout = 6 * time.Minute
3839
)
3940

4041
// WaitForRouteState polls the status of the Route called name from client every
@@ -114,13 +115,24 @@ func WaitForRevisionState(client *ServingClients, name string, inState func(r *v
114115
_, span := trace.StartSpan(context.Background(), metricName)
115116
defer span.End()
116117

117-
return wait.PollImmediate(interval, timeout, func() (bool, error) {
118+
waitErr := wait.PollImmediate(interval, timeout, func() (bool, error) {
118119
r, err := client.Revisions.Get(name, metav1.GetOptions{})
119120
if err != nil {
120121
return true, err
121122
}
122123
return inState(r)
123124
})
125+
// Attempt to add revision Status to error message.
126+
if waitErr != nil {
127+
r, err := client.Revisions.Get(name, metav1.GetOptions{})
128+
if err != nil {
129+
// Cant' look for Revision, don't append Status to error message.
130+
return waitErr
131+
}
132+
// Wrap error with information about Status.
133+
return errors.Wrapf(waitErr, "Status=%#v", r.Status)
134+
}
135+
return nil
124136
}
125137

126138
// CheckRevisionState verifies the status of the Revision called name from client

0 commit comments

Comments
 (0)