Repository: knative/serving
Pull request #10369 (2020-12-15 04:49:48)

Add a get by tag method to use during ingress construction
This can be optimized with caching/mapping but it's for latter
when we optimize the whole process.

/assign @tcnghia @ZhiminXiang 

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/serving/pull/10369#" title="Author self-approved">vagababov</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fserving).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[pkg/reconciler/route/OWNERS](https://github.com/knative/serving/blob/master/pkg/reconciler/route/OWNERS)~~ [vagababov]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
codecov[bot]: # [Codecov](https://codecov.io/gh/knative/serving/pull/10369?src=pr&el=h1) Report
> Merging [#10369](https://codecov.io/gh/knative/serving/pull/10369?src=pr&el=desc) (4843d74) into [master](https://codecov.io/gh/knative/serving/commit/cf4eab82b09ef21f8714e5d4bf316221c04e64b1?el=desc) (cf4eab8) will **decrease** coverage by `0.13%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/knative/serving/pull/10369/graphs/tree.svg?width=650&height=150&src=pr&token=MPpDfAj4Ui)](https://codecov.io/gh/knative/serving/pull/10369?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #10369      +/-   ##
==========================================
- Coverage   88.13%   87.99%   -0.14%     
==========================================
  Files         186      186              
  Lines        8712     8721       +9     
==========================================
- Hits         7678     7674       -4     
- Misses        801      810       +9     
- Partials      233      237       +4     
```


| [Impacted Files](https://codecov.io/gh/knative/serving/pull/10369?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/reconciler/route/reconcile\_resources.go](https://codecov.io/gh/knative/serving/pull/10369/diff?src=pr&el=tree#diff-cGtnL3JlY29uY2lsZXIvcm91dGUvcmVjb25jaWxlX3Jlc291cmNlcy5nbw==) | `80.67% <100.00%> (-7.16%)` | :arrow_down: |
| [pkg/reconciler/route/traffic/rollout.go](https://codecov.io/gh/knative/serving/pull/10369/diff?src=pr&el=tree#diff-cGtnL3JlY29uY2lsZXIvcm91dGUvdHJhZmZpYy9yb2xsb3V0Lmdv) | `100.00% <100.00%> (ø)` | |
| [pkg/autoscaler/statforwarder/leases.go](https://codecov.io/gh/knative/serving/pull/10369/diff?src=pr&el=tree#diff-cGtnL2F1dG9zY2FsZXIvc3RhdGZvcndhcmRlci9sZWFzZXMuZ28=) | `76.97% <0.00%> (-1.44%)` | :arrow_down: |
| [pkg/activator/net/revision\_backends.go](https://codecov.io/gh/knative/serving/pull/10369/diff?src=pr&el=tree#diff-cGtnL2FjdGl2YXRvci9uZXQvcmV2aXNpb25fYmFja2VuZHMuZ28=) | `90.49% <0.00%> (-0.91%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/knative/serving/pull/10369?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/knative/serving/pull/10369?src=pr&el=footer). Last update [44aebb6...9a65ed0](https://codecov.io/gh/knative/serving/pull/10369?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

knative-prow-robot: @vagababov: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-serving-istio-stable-no-mesh-tls | 9a65ed049870324eec967bbebf0cbed13f896e84 | [link](https://prow.knative.dev/view/gs/knative-prow/pr-logs/pull/knative_serving/10369/pull-knative-serving-istio-stable-no-mesh-tls/1338707834891669504) | `/test pull-knative-serving-istio-stable-no-mesh-tls`

[Full PR test history](https://gubernator.knative.dev/pr/knative_serving/10369). [Your PR dashboard](https://gubernator.knative.dev/pr/vagababov).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
knative-prow-robot: @vagababov: The following tests **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
pull-knative-serving-istio-stable-no-mesh-tls | 9a65ed049870324eec967bbebf0cbed13f896e84 | [link](https://prow.knative.dev/view/gs/knative-prow/pr-logs/pull/knative_serving/10369/pull-knative-serving-istio-stable-no-mesh-tls/1338707834891669504) | `/test pull-knative-serving-istio-stable-no-mesh-tls`
pull-knative-serving-unit-tests | 8a1533395942ef38f421733dab8ead228b8aa9d1 | [link](https://prow.knative.dev/view/gs/knative-prow/pr-logs/pull/knative_serving/10369/pull-knative-serving-unit-tests/1338729685672005632) | `/test pull-knative-serving-unit-tests`

[Full PR test history](https://gubernator.knative.dev/pr/knative_serving/10369). [Your PR dashboard](https://gubernator.knative.dev/pr/vagababov).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->
knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative/serving/pull/10369#pullrequestreview-552148031" title="LGTM">tcnghia</a>*, *<a href="https://github.com/knative/serving/pull/10369#" title="Author self-approved">vagababov</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative%2Fserving).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[pkg/reconciler/route/OWNERS](https://github.com/knative/serving/blob/master/pkg/reconciler/route/OWNERS)~~ [tcnghia,vagababov]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/pkg/reconciler/route/traffic/rollout.go b/pkg/reconciler/route/traffic/rollout.go
index 926aad1cb..d8ff08154 100644
--- a/pkg/reconciler/route/traffic/rollout.go
+++ b/pkg/reconciler/route/traffic/rollout.go
@@ -92,6 +92,18 @@ type RevisionRollout struct {
 	Percent int `json:"percent"`
 }
 
+// RolloutsByTag returns the ConfigurationRollout(s) for the given tag.
+func (cur *Rollout) RolloutsByTag(t string) []*ConfigurationRollout {
+	// TODO(vagababov): add an intermediate cache later.
+	ret := []*ConfigurationRollout{}
+	for i := range cur.Configurations {
+		if cr := cur.Configurations[i]; cr.Tag == t {
+			ret = append(ret, &cr)
+		}
+	}
+	return ret
+}
+
 // Done returns true if there is no active rollout going on
 // for the configuration.
 func (cur *ConfigurationRollout) Done() bool {


Test patch:
diff --git a/pkg/reconciler/route/traffic/rollout_test.go b/pkg/reconciler/route/traffic/rollout_test.go
index 856b4662e..97ef7a7e5 100644
--- a/pkg/reconciler/route/traffic/rollout_test.go
+++ b/pkg/reconciler/route/traffic/rollout_test.go
@@ -1579,3 +1579,73 @@ func TestStepRevisions(t *testing.T) {
 		})
 	}
 }
+
+func TestGetByTag(t *testing.T) {
+	r := &Rollout{
+		Configurations: []ConfigurationRollout{{
+			ConfigurationName: "one",
+			Percent:           50,
+			Revisions: []RevisionRollout{{
+				RevisionName: "rob",
+				Percent:      10,
+			}, {
+				RevisionName: "roy",
+				Percent:      40,
+			}},
+		}, {
+			ConfigurationName: "two",
+			Percent:           40,
+			Revisions: []RevisionRollout{{
+				RevisionName: "wish",
+				Percent:      40,
+			}},
+		}, {
+			ConfigurationName: "two",
+			Tag:               "gilberto",
+			Percent:           100,
+			Revisions: []RevisionRollout{{
+				RevisionName: "wish",
+				Percent:      100,
+			}},
+		}, {
+			ConfigurationName: "three",
+			Percent:           10,
+			Revisions: []RevisionRollout{{
+				RevisionName: "forty-two",
+				Percent:      5,
+			}, {
+				RevisionName: "flowers",
+				Percent:      5,
+			}},
+		}, {
+			ConfigurationName: "three",
+			Tag:               "jobim",
+			Percent:           100,
+			Revisions: []RevisionRollout{{
+				RevisionName: "forty-two",
+				Percent:      60,
+			}, {
+				RevisionName: "flowers",
+				Percent:      40,
+			}},
+		}},
+	}
+	sortRollout(r)
+
+	wantDef := []*ConfigurationRollout{&r.Configurations[0], &r.Configurations[1], &r.Configurations[2]}
+	wantGilberto := []*ConfigurationRollout{&r.Configurations[3]}
+	wantJobim := []*ConfigurationRollout{&r.Configurations[4]}
+
+	if got, want := r.RolloutsByTag(""), wantDef; !cmp.Equal(got, want) {
+		t.Errorf(`RolloutsByTag("") mismatch: diff(-want,+got):\n%s`, cmp.Diff(want, got))
+	}
+	if got, want := r.RolloutsByTag("gilberto"), wantGilberto; !cmp.Equal(got, want) {
+		t.Errorf(`RolloutsByTag("gilberto") mismatch: diff(-want,+got):\n%s`, cmp.Diff(want, got))
+	}
+	if got, want := r.RolloutsByTag("jobim"), wantJobim; !cmp.Equal(got, want) {
+		t.Errorf(`RolloutsByTag("jobim") mismatch: diff(-want,+got):\n%s`, cmp.Diff(want, got))
+	}
+	if got, want := r.RolloutsByTag("nyaful"), []*ConfigurationRollout{}; !cmp.Equal(got, want) {
+		t.Errorf(`RolloutsByTag("nyaful") mismatch: diff(-want,+got):\n%s`, cmp.Diff(want, got))
+	}
+}
diff --git a/third_party/contour-latest/contour.yaml b/third_party/contour-latest/contour.yaml
index 147d585b7..95b52515b 100644
--- a/third_party/contour-latest/contour.yaml
+++ b/third_party/contour-latest/contour.yaml
@@ -1482,7 +1482,7 @@ spec:
     spec:
       containers:
         - name: contour
-          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:482d27526d99b97166c7912ee8d6f3f43bd97cb72d8235027906b5aaa4055c2a
+          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:542f92cdbe8f41c3bf2478b01f99db5002ad978d0007022fe907fead04ce1edf
           imagePullPolicy: Always
           command:
             - contour
@@ -1709,7 +1709,7 @@ spec:
             - --contour-key-file=/certs/tls.key
             - --config-path=/config/contour.yaml
           command: ["contour"]
-          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:482d27526d99b97166c7912ee8d6f3f43bd97cb72d8235027906b5aaa4055c2a
+          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:542f92cdbe8f41c3bf2478b01f99db5002ad978d0007022fe907fead04ce1edf
           imagePullPolicy: IfNotPresent
           name: contour
           ports:
@@ -1798,7 +1798,7 @@ spec:
           args:
             - envoy
             - shutdown-manager
-          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:482d27526d99b97166c7912ee8d6f3f43bd97cb72d8235027906b5aaa4055c2a
+          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:542f92cdbe8f41c3bf2478b01f99db5002ad978d0007022fe907fead04ce1edf
           imagePullPolicy: IfNotPresent
           lifecycle:
             preStop:
@@ -1875,7 +1875,7 @@ spec:
             - --envoy-key-file=/certs/tls.key
           command:
             - contour
-          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:482d27526d99b97166c7912ee8d6f3f43bd97cb72d8235027906b5aaa4055c2a
+          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:542f92cdbe8f41c3bf2478b01f99db5002ad978d0007022fe907fead04ce1edf
           imagePullPolicy: IfNotPresent
           name: envoy-initconfig
           volumeMounts:
@@ -2097,7 +2097,7 @@ spec:
     spec:
       containers:
         - name: contour
-          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:482d27526d99b97166c7912ee8d6f3f43bd97cb72d8235027906b5aaa4055c2a
+          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:542f92cdbe8f41c3bf2478b01f99db5002ad978d0007022fe907fead04ce1edf
           imagePullPolicy: Always
           command:
             - contour
@@ -2217,7 +2217,7 @@ spec:
             - --contour-key-file=/certs/tls.key
             - --config-path=/config/contour.yaml
           command: ["contour"]
-          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:482d27526d99b97166c7912ee8d6f3f43bd97cb72d8235027906b5aaa4055c2a
+          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:542f92cdbe8f41c3bf2478b01f99db5002ad978d0007022fe907fead04ce1edf
           imagePullPolicy: IfNotPresent
           name: contour
           ports:
@@ -2306,7 +2306,7 @@ spec:
           args:
             - envoy
             - shutdown-manager
-          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:482d27526d99b97166c7912ee8d6f3f43bd97cb72d8235027906b5aaa4055c2a
+          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:542f92cdbe8f41c3bf2478b01f99db5002ad978d0007022fe907fead04ce1edf
           imagePullPolicy: IfNotPresent
           lifecycle:
             preStop:
@@ -2383,7 +2383,7 @@ spec:
             - --envoy-key-file=/certs/tls.key
           command:
             - contour
-          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:482d27526d99b97166c7912ee8d6f3f43bd97cb72d8235027906b5aaa4055c2a
+          image: gcr.io/knative-nightly/github.com/projectcontour/contour/cmd/contour@sha256:542f92cdbe8f41c3bf2478b01f99db5002ad978d0007022fe907fead04ce1edf
           imagePullPolicy: IfNotPresent
           name: envoy-initconfig
           volumeMounts:
diff --git a/third_party/contour-latest/net-contour.yaml b/third_party/contour-latest/net-contour.yaml
index 95e0c5f94..fb02e657f 100644
--- a/third_party/contour-latest/net-contour.yaml
+++ b/third_party/contour-latest/net-contour.yaml
@@ -33,7 +33,7 @@ metadata:
   namespace: knative-serving
   labels:
     networking.knative.dev/ingress-provider: contour
-    serving.knative.dev/release: "v20201210-37580d65"
+    serving.knative.dev/release: "v20201214-8f5f70f3"
 data:
   _example: |
     ################################
@@ -103,7 +103,7 @@ spec:
         - name: controller
           # This is the Go import path for the binary that is containerized
           # and substituted here.
-          image: gcr.io/knative-nightly/knative.dev/net-contour/cmd/controller@sha256:5d3e54c3b13e19ffb45b4d271478a18699c6080b846baa248cf9bb32b8757ad3
+          image: gcr.io/knative-nightly/knative.dev/net-contour/cmd/controller@sha256:1bd4380e2d1aa9c1bb50aaf17264b5e866e8389eb3b33ffdd5411eb670a98325
           resources:
             requests:
               cpu: 40m