Repository: knative/pkg
Pull request #1472 (2020-07-09 18:44:44)

Use quotation marks for generated checksums
* If you win the hashcode lottery and get a checksum that is all numeric, this parses as an int instead of a string and fails.
    * Quotes ensure proper parsing
    * This was mysterious and confusing in: #8582

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

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1472#" title="Author self-approved">whaught</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **vagababov**
You can assign the PR to them by writing `/assign @vagababov` in a comment when ready.

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

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

- **[configmap/OWNERS](https://github.com/knative/pkg/blob/master/configmap/OWNERS)**

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":["vagababov"]} -->
whaught: /assign @vagababov
knative-metrics-robot: The following is the coverage report on the affected files.
Say `/test pull-knative-pkg-go-coverage` to re-run this coverage report

File | Old Coverage | New Coverage | Delta
---- |:------------:|:------------:|:-----:
[configmap/hash-gen/main.go](https://storage.cloud.google.com/knative-prow/pr-logs/pull/knative_pkg/1472/pull-knative-pkg-go-coverage/1281298340805349378/artifacts/line-cov.html#file0) | 68.0% | 69.2% | 1.2

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

This pull-request has been approved by: *<a href="https://github.com/knative/pkg/pull/1472#pullrequestreview-445896849" title="Approved">vagababov</a>*, *<a href="https://github.com/knative/pkg/pull/1472#" title="Author self-approved">whaught</a>*

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

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:

- ~~[configmap/OWNERS](https://github.com/knative/pkg/blob/master/configmap/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":[]} -->

Patch:
diff --git a/RELEASING.md b/RELEASING.md
index 025bc8314..ca77e229c 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -24,16 +24,16 @@ additional caution should be used when merging big changes.
 ### Collect release-notes
 
 Make a copy of the
-[last release notes document](https://docs.google.com/document/d/1zQYVA4IorYFsIONpY8Hb5H6gU-ND1BWfm2nOdN7jJk0/edit),
+[last release notes document](https://docs.google.com/document/d/1FTL_fMXU2hv2POh9uN_8IJe9FbqEIzFdRZZRXI0WaT4/edit),
 empty it out and send it to the WG leads of the respective project (serving or
 eventing) to fill in. Coordinate with both serving and eventing leads.
 
-### Cut `release-x.y` in `pkg` and `test-infra` libraries
+### Cut `release-x.y` in `test-infra`, `pkg`, `caching`, and `networking` libraries
 
-Shared dependencies like `knative/pkg` and `knative/test-infra` are kept
-up-to-date nightly in each of the releasing repositories. To stabilize things
-shortly before the release we cut the `release-x.y` branches on those 7 days
-prior to the main release.
+Shared dependencies like `knative/{test-infra, pkg, caching, networking}` are
+kept up-to-date nightly in each of the releasing repositories. To stabilize
+things shortly before the release we cut the `release-x.y` branches on those 7
+days prior to the main release.
 
 Both `pkg` and `test-infra` also need to pin each other's release branch. To do
 that, edit `hack/update-deps.sh` in the respective repo **on the newly created
@@ -61,7 +61,11 @@ index a39fc858..0634362f 100755
 PR the changes to each repository respectively, prepending the PR title with
 `[RELEASE]`.
 
-### Pin `pkg` and `test-infra` in downstream repositories
+After `test-infra` and `pkg` are pinned, change `caching` and `networking`'s
+`update-deps.sh` to use `release-x.y` branch of `test-infra` and `pkg`.
+Following that, cut new `release-x.y` branches for `caching` and `networking`.
+
+### Pin `test-infra`, `pkg`, `caching`, `networking` in downstream repositories
 
 Similar to how the pin between `pkg` and `test-infra` themselves work, all
 downstream users must be pinned to the newly cut `release-x.y` branches on those
@@ -79,15 +83,18 @@ index b277dd3ff..1989885ce 100755
  FLOATING_DEPS=(
 -  "knative.dev/test-infra@${VERSION}"
 -  "knative.dev/pkg@${VERSION}"
+-  "knative.dev/caching@${VERSION}"
+-  "knative.dev/networking@${VERSION}"
 +  "knative.dev/test-infra@release-x.y"
 +  "knative.dev/pkg@release-x.y"
-   "knative.dev/caching@${VERSION}"
++  "knative.dev/caching@release-x.y"
++  "knative.dev/networking@release-x.y"
  )
 ```
 
 The downstream repositories this needs to happen on are:
 
-- [knative/caching](https://github.com/knative/caching)
+- [knative/client](https://github.com/knative/client)
 - [knative/eventing-contrib](https://github.com/knative/eventing-contrib)
 - [knative/eventing](https://github.com/knative/eventing)
 - [knative/net-certmanager](https://github.com/knative/net-certmanager)
@@ -103,13 +110,6 @@ Apply the changes the the **master branches**, run
 necessary) and PR the changes to the **master branch**. Don't cut the release
 branch yet.
 
-### Cut and pin `caching`
-
-`caching` sees very little traffic, so we cut it 1 week prior to the actual
-release to unblock the `serving` release (it depends on caching). Cut a
-`release-x.y` branch and pin it in `serving` as shown above. You can potentially
-collapse this pin with the `pkg`/`test-infra` pin to `serving` per step 2.
-
 ### Verify nightly release automation is intact
 
 The automation used to cut the actual releases is the very same as the
@@ -183,4 +183,6 @@ create the respective tags.
 Revert all pins in all repositories to pin the **master** branches again, run
 `hack/update-deps.sh --upgrade` and PR the changes.
 
+### Change this file to reflect new modification to the release if applicable
+
 ---
diff --git a/configmap/hash-gen/main.go b/configmap/hash-gen/main.go
index 72230b545..8d9b7bfe0 100644
--- a/configmap/hash-gen/main.go
+++ b/configmap/hash-gen/main.go
@@ -85,9 +85,10 @@ func process(data []byte) ([]byte, error) {
 	if existingAnnotation != nil {
 		existingAnnotation.Value = checksum
 	} else {
+		sumNode := strNode(checksum)
+		sumNode.Style = yaml.DoubleQuotedStyle
 		annotations.Content = append(annotations.Content,
-			strNode(configmap.ExampleChecksumAnnotation),
-			strNode(checksum))
+			strNode(configmap.ExampleChecksumAnnotation), sumNode)
 	}
 
 	var buffer bytes.Buffer


Test patch:
diff --git a/configmap/hash-gen/testdata/add_want.yaml b/configmap/hash-gen/testdata/add_want.yaml
index 31ae5e63e..083055bc6 100644
--- a/configmap/hash-gen/testdata/add_want.yaml
+++ b/configmap/hash-gen/testdata/add_want.yaml
@@ -20,7 +20,7 @@ metadata:
   labels:
     serving.knative.dev/release: devel
   annotations:
-    knative.dev/example-checksum: 05d48218
+    knative.dev/example-checksum: "05d48218"
 data:
   leave-me: "alone"
   _example: |
diff --git a/configmap/hash-gen/testdata/update.yaml b/configmap/hash-gen/testdata/update.yaml
index 1e5874f6d..1a717ae49 100644
--- a/configmap/hash-gen/testdata/update.yaml
+++ b/configmap/hash-gen/testdata/update.yaml
@@ -20,7 +20,7 @@ metadata:
   labels:
     serving.knative.dev/release: devel
   annotations:
-    knative.dev/example-checksum: bla
+    knative.dev/example-checksum: "bla"
 data:
   leave-me: "alone"
   _example: |
diff --git a/configmap/hash-gen/testdata/update_want.yaml b/configmap/hash-gen/testdata/update_want.yaml
index 31ae5e63e..083055bc6 100644
--- a/configmap/hash-gen/testdata/update_want.yaml
+++ b/configmap/hash-gen/testdata/update_want.yaml
@@ -20,7 +20,7 @@ metadata:
   labels:
     serving.knative.dev/release: devel
   annotations:
-    knative.dev/example-checksum: 05d48218
+    knative.dev/example-checksum: "05d48218"
 data:
   leave-me: "alone"
   _example: |
diff --git a/hash/hash_test.go b/hash/hash_test.go
index bb87eccf0..833800302 100644
--- a/hash/hash_test.go
+++ b/hash/hash_test.go
@@ -29,6 +29,32 @@ import (
 	"k8s.io/apimachinery/pkg/util/sets"
 )
 
+func ExampleSelectOne() {
+	// This example shows how to do consistent bucket
+	// assignment using ChooseSubset.
+
+	tasks := sets.NewString("task1", "task2", "task3")
+
+	ret := ChooseSubset(tasks, 1, "my-key1")
+	fmt.Println(ret.UnsortedList()[0])
+
+	ret = ChooseSubset(tasks, 1, "somthing/another-key")
+	fmt.Println(ret.UnsortedList()[0])
+	// Output: task3
+	// task1
+}
+
+func ExampleSelectMany() {
+	// This example shows how to do consistent bucket
+	// assignment using ChooseSubset.
+
+	tasks := sets.NewString("task1", "task2", "task3", "task4", "task5")
+
+	ret := ChooseSubset(tasks, 2, "my-key1")
+	fmt.Println(ret.List())
+	// Output: [task3 task4]
+}
+
 func TestBuildHashes(t *testing.T) {
 	const target = "a target to remember"
 	set := sets.NewString("a", "b", "c", "e", "f")