Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit ff926d0

Browse files
committed
Update to Go 1.20 and latest KRTE for e2e tests
E2Es broke a few days ago, likely when test-infra upgraded to 1.20. I also couldn't run staticcheck on my Google workstation, which has 1.20, with the same failure message. Upgrading staticcheck fixed the problem; I also took the opportunity to match the test-infra krte image as well as the Golang version (which caused some minor reformatting). Tested: couldn't build on my workstation on Go 1.20 before this change; can after it.
1 parent 3dac447 commit ff926d0

File tree

445 files changed

+39501
-11985
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

445 files changed

+39501
-11985
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ staticcheck: build-staticcheck
206206
$(STATICCHECK) ${DIRS}
207207

208208
build-staticcheck:
209+
@echo "If this next step fails, try updating honnef.co/go/tools in go.mod"
209210
go build -o $(STATICCHECK) honnef.co/go/tools/cmd/staticcheck
210211

211212
# Generate code
@@ -220,6 +221,8 @@ check-generate: generate
220221
# Use the version of controller-gen that's checked into vendor/ (see
221222
# hack/tools.go to see how it got there).
222223
controller-gen:
224+
@echo "Go version (for logging posterity):"
225+
@go version
223226
go build -o $(CONTROLLER_GEN) sigs.k8s.io/controller-tools/cmd/controller-gen
224227

225228
###################### DEPLOYABLE ARTIFACTS AND ACTIONS #########################

go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module sigs.k8s.io/hierarchical-namespaces
22

3-
go 1.17
3+
go 1.20
44

55
require (
66
contrib.go.opencensus.io/exporter/prometheus v0.4.0
@@ -14,7 +14,7 @@ require (
1414
github.com/spf13/cobra v1.2.1
1515
go.opencensus.io v0.23.0
1616
go.uber.org/zap v1.19.1
17-
honnef.co/go/tools v0.3.0
17+
honnef.co/go/tools v0.4.0
1818
k8s.io/api v0.23.2
1919
k8s.io/apiextensions-apiserver v0.23.2
2020
k8s.io/apimachinery v0.23.2
@@ -32,7 +32,7 @@ require (
3232
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
3333
github.com/Azure/go-autorest/logger v0.2.1 // indirect
3434
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
35-
github.com/BurntSushi/toml v0.4.1 // indirect
35+
github.com/BurntSushi/toml v1.2.1 // indirect
3636
github.com/PuerkitoBio/purell v1.1.1 // indirect
3737
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
3838
github.com/aws/aws-sdk-go v1.23.20 // indirect
@@ -89,16 +89,16 @@ require (
8989
go.uber.org/atomic v1.7.0 // indirect
9090
go.uber.org/multierr v1.6.0 // indirect
9191
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
92-
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
93-
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
94-
golang.org/x/net v0.0.0-20220403103023-749bd193bc2b // indirect
92+
golang.org/x/exp/typeparams v0.0.0-20221208152030-732eee02a75a // indirect
93+
golang.org/x/mod v0.7.0 // indirect
94+
golang.org/x/net v0.3.0 // indirect
9595
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
96-
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
97-
golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 // indirect
98-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
99-
golang.org/x/text v0.3.7
96+
golang.org/x/sync v0.1.0 // indirect
97+
golang.org/x/sys v0.3.0 // indirect
98+
golang.org/x/term v0.3.0 // indirect
99+
golang.org/x/text v0.5.0
100100
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
101-
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a // indirect
101+
golang.org/x/tools v0.4.1-0.20221208213631-3f74d914ae6d // indirect
102102
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
103103
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
104104
google.golang.org/api v0.44.0 // indirect

go.sum

Lines changed: 20 additions & 21 deletions
Large diffs are not rendered by default.

hack/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PROW_TMP := $(shell mktemp -d)
1616
#
1717
# Also, when you do this, please also upgrade the version of Kind we download
1818
# in prow-run-e2e.sh in this directory.
19-
KRTE_IMG ?= gcr.io/k8s-staging-test-infra/krte:v20220322-c5eee43783-master
19+
KRTE_IMG ?= gcr.io/k8s-staging-test-infra/krte:v20230207-ce569a5e37-master
2020

2121
# The variant of HNC to test; this can be default, ha, or omitted (defaults to
2222
# "default"). See prow-run-e2e.sh for details.

internal/anchor/reconciler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ func (r *Reconciler) writeInstance(ctx context.Context, log logr.Logger, inst *a
358358

359359
// deleteInstance deletes the anchor instance. Note: Make sure there's no
360360
// finalizers on the instance before calling this function.
361+
//
361362
//lint:ignore U1000 Ignore for now, as it may be used again in the future
362363
func (r *Reconciler) deleteInstance(ctx context.Context, inst *api.SubnamespaceAnchor) error {
363364
if err := r.Delete(ctx, inst); err != nil {

internal/forest/namespacehrq.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ func (n *Namespace) canUseResources(u v1.ResourceList) error {
132132
// UseResources can be called in the following scenarios:
133133
// - Called by the HRQ admission controller when a request is allowed
134134
// - Called by the HRQ ResourceQuota reconciler when it observes `local`
135-
// usages are different from ResourceQuota.Status.Used
135+
// usages are different from ResourceQuota.Status.Used
136136
// - Called by the HRQ Namespace reconciler to remove `local` usages of a
137-
// namespace from the subtree usages of the previous ancestors of the namespace.
137+
// namespace from the subtree usages of the previous ancestors of the namespace.
138138
// - Called by the SetParent to remove `local` usages of a namespace from
139-
// the subtree usages of the previous ancestors of the namespace and add the
140-
// usages to the new ancestors following a parent update
139+
// the subtree usages of the previous ancestors of the namespace and add the
140+
// usages to the new ancestors following a parent update
141141
func (n *Namespace) UseResources(newUsage v1.ResourceList) {
142142
oldUsage := n.quotas.used.local
143143

internal/foresttest/foresttest.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ import (
1313
// subnamespace as well:
1414
// * If the string element is a hyphen ('-'), the namespace is a root.
1515
// * If the string element is a lowercase letter, the referenced namespace is a normal parent.
16-
// * If the referenced namespace is not in len(desc), it will not exist and we'll set
17-
// ParentMissing on the child.
16+
// - If the referenced namespace is not in len(desc), it will not exist and we'll set
17+
// ParentMissing on the child.
18+
//
1819
// * If the string element is an uppercase letter, that namespaces will be the parent and the
1920
// *current* namespace will be a subnamespace.
2021
//
2122
// Examples:
22-
// * "-" -> creates a single namespace "a" that is a root
23-
// * "-a" -> creates the tree a <- b
24-
// * "-A" -> creates the tree a <- b where b is a subnamespace of a
25-
// * "z" -> creates the tree z <- a where z does not exist and a has ParentMissing
26-
// * "-aa" -> creates namespace `a` with two children, `b` and `c`
27-
// * "-aA" -> as above, but c is a subnamespace and b is a full namespace
28-
// * "ba" -> creates a cycle
29-
// * "-aa-dd" -> creates two trees, one with root `a` and children `b` and `c`, the other with root
30-
// `d` and children `e` and `f`
23+
// - "-" -> creates a single namespace "a" that is a root
24+
// - "-a" -> creates the tree a <- b
25+
// - "-A" -> creates the tree a <- b where b is a subnamespace of a
26+
// - "z" -> creates the tree z <- a where z does not exist and a has ParentMissing
27+
// - "-aa" -> creates namespace `a` with two children, `b` and `c`
28+
// - "-aA" -> as above, but c is a subnamespace and b is a full namespace
29+
// - "ba" -> creates a cycle
30+
// - "-aa-dd" -> creates two trees, one with root `a` and children `b` and `c`, the other with root
31+
// `d` and children `e` and `f`
3132
func Create(desc string) *forest.Forest {
3233
const upper = 'A'
3334
const lower = 'a'

internal/hncconfig/reconciler_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ func setTypeConfig(ctx context.Context, group, resource string, mode api.Synchro
447447

448448
// updateTypeConfig is like setTypeConfig but it doesn't wait to confirm that the change was
449449
// successful.
450+
//
450451
//lint:ignore U1000 Ignore for now, as it may be used again in the future
451452
func updateTypeConfig(ctx context.Context, group, resource string, mode api.SynchronizationMode) {
452453
updateTypeConfigWithOffset(ctx, 1, group, resource, mode)

internal/hrq/hrqreconciler.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ type RQEnqueuer interface {
3232

3333
// HierarchicalResourceQuotaReconciler reconciles a HierarchicalResourceQuota object. It has three key
3434
// purposes:
35-
// 1. Update the in-memory forest with all the limits defined in the HRQ spec, so that they can be
36-
// used during admission control to reject requests.
37-
// 2. Write all the usages from the in-memory forest back to the HRQ status.
38-
// 3. Enqueue all relevant RQs when an HRQ changes.
35+
// 1. Update the in-memory forest with all the limits defined in the HRQ spec, so that they can be
36+
// used during admission control to reject requests.
37+
// 2. Write all the usages from the in-memory forest back to the HRQ status.
38+
// 3. Enqueue all relevant RQs when an HRQ changes.
3939
type HierarchicalResourceQuotaReconciler struct {
4040
client.Client
4141
Log logr.Logger

internal/hrq/hrqvalidator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package hrq
22

33
import (
44
"context"
5+
"crypto/rand"
56
"fmt"
6-
"math/rand"
77
"strings"
88

99
"github.com/go-logr/logr"

0 commit comments

Comments
 (0)