Skip to content

Conversation

@lukasschwab
Copy link
Contributor

@lukasschwab lukasschwab commented Dec 8, 2021

Description

Merges the latest released changes to k8s.io/apimachinery (v0.23.0). Literally git merge v0.23.0 after fetching the upstream repo.

If this PR is merged, it'll need to be followed by a new indentinc/apimachinery release and an update to go.mod to pin the latest release.

Testing

Confirmed that this doesn't change our modified logic by diffing this feature branch against our main branch. This is essentially the diff we care about; the rest of the diff in this PR should be extraneous to our modifications and non-breaking.

Summarizing our modified logic

From main, list the files in our changes:

$ git diff --name-only 02cfb53916346d085a6c6c7c66f882e3c6b0eca6
.github/PULL_REQUEST_TEMPLATE.md
.github/workflows/build.yaml
README.md
pkg/apis/meta/v1/validation/validation.go
pkg/apis/meta/v1/validation/validation_test.go
pkg/labels/selector.go
pkg/labels/selector_test.go
pkg/util/naming/from_stack_test.go
pkg/util/validation/indent.go
pkg/util/validation/validation.go
pkg/util/validation/validation_test.go

git diff main -- pkg/apis/meta/v1/validation

diff --git a/pkg/apis/meta/v1/validation/validation.go b/pkg/apis/meta/v1/validation/validation.go
index 5b990bf1..c7cb1364 100644
--- a/pkg/apis/meta/v1/validation/validation.go
+++ b/pkg/apis/meta/v1/validation/validation.go
@@ -96,17 +96,19 @@ func ValidateDeleteOptions(options *metav1.DeleteOptions) field.ErrorList {
 }
 
 func ValidateCreateOptions(options *metav1.CreateOptions) field.ErrorList {
-	return append(
-		ValidateFieldManager(options.FieldManager, field.NewPath("fieldManager")),
-		ValidateDryRun(field.NewPath("dryRun"), options.DryRun)...,
-	)
+	allErrs := field.ErrorList{}
+	allErrs = append(allErrs, ValidateFieldManager(options.FieldManager, field.NewPath("fieldManager"))...)
+	allErrs = append(allErrs, ValidateDryRun(field.NewPath("dryRun"), options.DryRun)...)
+	allErrs = append(allErrs, ValidateFieldValidation(field.NewPath("fieldValidation"), options.FieldValidation)...)
+	return allErrs
 }
 
 func ValidateUpdateOptions(options *metav1.UpdateOptions) field.ErrorList {
-	return append(
-		ValidateFieldManager(options.FieldManager, field.NewPath("fieldManager")),
-		ValidateDryRun(field.NewPath("dryRun"), options.DryRun)...,
-	)
+	allErrs := field.ErrorList{}
+	allErrs = append(allErrs, ValidateFieldManager(options.FieldManager, field.NewPath("fieldManager"))...)
+	allErrs = append(allErrs, ValidateDryRun(field.NewPath("dryRun"), options.DryRun)...)
+	allErrs = append(allErrs, ValidateFieldValidation(field.NewPath("fieldValidation"), options.FieldValidation)...)
+	return allErrs
 }
 
 func ValidatePatchOptions(options *metav1.PatchOptions, patchType types.PatchType) field.ErrorList {
@@ -123,6 +125,7 @@ func ValidatePatchOptions(options *metav1.PatchOptions, patchType types.PatchTyp
 	}
 	allErrs = append(allErrs, ValidateFieldManager(options.FieldManager, field.NewPath("fieldManager"))...)
 	allErrs = append(allErrs, ValidateDryRun(field.NewPath("dryRun"), options.DryRun)...)
+	allErrs = append(allErrs, ValidateFieldValidation(field.NewPath("fieldValidation"), options.FieldValidation)...)
 	return allErrs
 }
 
@@ -159,6 +162,18 @@ func ValidateDryRun(fldPath *field.Path, dryRun []string) field.ErrorList {
 	return allErrs
 }
 
+var allowedFieldValidationValues = sets.NewString("", metav1.FieldValidationIgnore, metav1.FieldValidationWarn, metav1.FieldValidationStrict)
+
+// ValidateFieldValidation validates that a fieldValidation query param only contains allowed values.
+func ValidateFieldValidation(fldPath *field.Path, fieldValidation string) field.ErrorList {
+	allErrs := field.ErrorList{}
+	if !allowedFieldValidationValues.Has(fieldValidation) {
+		allErrs = append(allErrs, field.NotSupported(fldPath, fieldValidation, allowedFieldValidationValues.List()))
+	}
+	return allErrs
+
+}
+
 const UninitializedStatusUpdateErrorMsg string = `must not update status when the object is uninitialized`
 
 // ValidateTableOptions returns any invalid flags on TableOptions.

git diff main -- pkg/labels

diff --git a/pkg/labels/selector_test.go b/pkg/labels/selector_test.go
index 9c266b55..42fa6c7a 100644
--- a/pkg/labels/selector_test.go
+++ b/pkg/labels/selector_test.go
@@ -150,8 +150,7 @@ func expectMatchDirect(t *testing.T, selector, ls Set) {
 	}
 }
 
-//lint:ignore U1000 currently commented out in TODO of TestSetMatches
-//nolint:unused,deadcode
+//nolint:staticcheck,unused //iccheck // U1000 currently commented out in TODO of TestSetMatches
 func expectNoMatchDirect(t *testing.T, selector, ls Set) {
 	if SelectorFromSet(selector).Matches(ls) {
 		t.Errorf("Wanted '%s' to not match '%s', but it did.", selector, ls)
diff --git a/pkg/labels/zz_generated.deepcopy.go b/pkg/labels/zz_generated.deepcopy.go
index 4d482947..fdf4c31e 100644
--- a/pkg/labels/zz_generated.deepcopy.go
+++ b/pkg/labels/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 /*

git diff main -- pkg/util/validation

diff --git a/pkg/util/validation/field/errors.go b/pkg/util/validation/field/errors.go
index c283ad18..2ed368f5 100644
--- a/pkg/util/validation/field/errors.go
+++ b/pkg/util/validation/field/errors.go
@@ -239,6 +239,9 @@ func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher {
 
 // ToAggregate converts the ErrorList into an errors.Aggregate.
 func (list ErrorList) ToAggregate() utilerrors.Aggregate {
+	if len(list) == 0 {
+		return nil
+	}
 	errs := make([]error, 0, len(list))
 	errorMsgs := sets.NewString()
 	for _, err := range list {
diff --git a/pkg/util/validation/validation.go b/pkg/util/validation/validation.go
index ffa20285..501e3d15 100644
--- a/pkg/util/validation/validation.go
+++ b/pkg/util/validation/validation.go
@@ -25,6 +25,7 @@ import (
 	"strings"
 
 	"k8s.io/apimachinery/pkg/util/validation/field"
+	netutils "k8s.io/utils/net"
 )
 
 const qnameCharFmt string = "[A-Za-z0-9]"
@@ -346,7 +347,7 @@ func IsValidPortName(port string) []string {
 
 // IsValidIP tests that the argument is a valid IP address.
 func IsValidIP(value string) []string {
-	if net.ParseIP(value) == nil {
+	if netutils.ParseIPSloppy(value) == nil {
 		return []string{"must be a valid IP address, (e.g. 10.9.8.7 or 2001:db8::ffff)"}
 	}
 	return nil
@@ -355,7 +356,7 @@ func IsValidIP(value string) []string {
 // IsValidIPv4Address tests that the argument is a valid IPv4 address.
 func IsValidIPv4Address(fldPath *field.Path, value string) field.ErrorList {
 	var allErrors field.ErrorList
-	ip := net.ParseIP(value)
+	ip := netutils.ParseIPSloppy(value)
 	if ip == nil || ip.To4() == nil {
 		allErrors = append(allErrors, field.Invalid(fldPath, value, "must be a valid IPv4 address"))
 	}
@@ -365,7 +366,7 @@ func IsValidIPv4Address(fldPath *field.Path, value string) field.ErrorList {
 // IsValidIPv6Address tests that the argument is a valid IPv6 address.
 func IsValidIPv6Address(fldPath *field.Path, value string) field.ErrorList {
 	var allErrors field.ErrorList
-	ip := net.ParseIP(value)
+	ip := netutils.ParseIPSloppy(value)
 	if ip == nil || ip.To4() != nil {
 		allErrors = append(allErrors, field.Invalid(fldPath, value, "must be a valid IPv6 address"))
 	}

Type of change

  • New feature (non-breaking change that adds functionality)

Fixes

  • ID-1143

Checklists

  • Pull request has a descriptive title and summary.
  • Pull request has been linked to Jira.
  • Pull request has reviewers assigned.

FabianKramm and others added 30 commits December 16, 2020 17:37
Signed-off-by: fabiankramm <[email protected]>

Kubernetes-commit: b1a6f8cdf90c0a3861157fea24dcfa89c2aafcf9
Kubernetes-commit: 3d1076ebf310820a2e6163a48f1485e1ab2d670b
This replaces the experimental logr v0.4 with the stable v1.1.0
release. This is a breaking API change for some users because:
- Comparing logr.Logger against nil is not possible anymore:
  it's now a struct instead of an interface. Code which
  allows a nil logger should switch to *logr.Logger as type.
- Logger implementations must be updated in lockstep.

Instead of updating the forked zapr code in json.go, directly using
the original go-logr/zapr is simpler and avoids duplication of effort.

The updated zapr supports logging of numeric verbosity. Error messages
don't have a verbosity (= always get logged), so "v" is not getting
added to them anymore.

Source code logging for panic messages got fixed so that it references
the code with the invalid log call, not the json.go implementation.

Finally, zapr includes additional information in its panic
messages ("zap field", "ignored key", "invalid key").

Kubernetes-commit: cb6a65377775110631bc865acc06c3f957592813
…nverter.

Kubernetes-commit: 7db782ee039a6740c3abd2352dfff1ea74e40209
Signed-off-by: Stephen Augustus <[email protected]>

Kubernetes-commit: 0be115722bf30f42c7a954d5cdd4b48efd70ae77
Signed-off-by: Stephen Augustus <[email protected]>

Kubernetes-commit: 481cf6fbe753b9eb2a47ced179211206b0a99540
Kubernetes-commit: 0cd75e8fec62a2531637e80bb950ac9983cac1b0
Kubernetes-commit: 2c73d7834acb5ddf380441b9ef3260db4168557d
golang 1.17 fails to parse IPs with leading zeros

Kubernetes-commit: b0bc8adbc2178e15872f9ef040355c51c45d04bb
kubectl proxy: append context host path to request path

Kubernetes-commit: 341d312066bd650e70995cd1a15925035b524a7d
…erter

apimachinery: remove unused ignoredConversions map in converter.

Kubernetes-commit: a7997683523cd87d1765933d20d6890907496462
hack/pin-dependency.sh golang.org/x/crypto master
hack/pin-dependency.sh golang.org/x/net master
hack/pin-dependency.sh golang.org/x/oauth2 master
hack/pin-dependency.sh golang.org/x/sync master
hack/pin-dependency.sh golang.org/x/sys master
hack/pin-dependency.sh golang.org/x/term master
hack/pin-dependency.sh golang.org/x/time master
hack/pin-dependency.sh golang.org/x/tools master

Signed-off-by: Stephen Augustus <[email protected]>

Kubernetes-commit: 0e9881a9dc9d06aaf93723b4dfc7f4e1cb92e215
[go1.17] Update to go1.17

Kubernetes-commit: c1e69551be1a72f0f8db6778f20658199d3a686d
Signed-off-by: Vince Prignano <[email protected]>

Kubernetes-commit: 8a9d61278f6c2177309f58bf2655f2269e8f6afd
Signed-off-by: Mateusz Gozdek <[email protected]>

Kubernetes-commit: 53892932973a3c400550c7854423e7fd5f2f9067
Fractional binary SI quantities that cannot be represented as decimal
internally were incorrectly calculated.

Kubernetes-commit: 2d7a9160a678685fed7376ede218f3dc6dff4958
Kubernetes-commit: 117fb6a45b2fda8fd7fd4a10c19d5244e924b771
Object creation with generateName should return AlreadyExists instead of a Timeout

Kubernetes-commit: 85b11ad24e996e2db4aa00a99e16f066544b22b0
Update the valid string from rand.go

Kubernetes-commit: f30f5a6862fd748e74d4a5bbe4cb673d6b0a3ae6
fix AsApproximateFloat64() for BinarySI

Kubernetes-commit: c0c7039f3a114b3d0e24e42efb9e8bf548161ba4
klog 2.20.0, logr v1.1.0, zapr v1.1.0

Kubernetes-commit: 5b49d125b76b4d92d5f782630b75b911fee75aaa
Fix typos in files which are used for generating OpenAPI

Kubernetes-commit: c91287c7b9abf59f4ca83984991d0dad6a5e76fd
It iterates over the wrapped transports until it finds one
that implements the CloseIdleConnections method and executes it.

add test for closeidle http1 connections

add test for http1.1 reconnect with inflight request

add test to reuse connection request

add test for request connect after timeout

add test for client-go request concurrency

Kubernetes-commit: b9d865a8185b62d83e9ff81b0e3499a26ac6960d
Kubernetes-commit: c5b4e05834d8edceac94ab1a91c3153581534393
Kubernetes-commit: 434ce4336ab06b3c34208822d558c0432ada3ad3
Kubernetes-commit: adf82f050c94f844a7f7c2b65c467a8a7f8e923b
Kubernetes-commit: 74ca1b953a875d5458e04008f4f5bdc535838415
Updated json-iterator version to 1.1.12 from 1.1.11

Kubernetes-commit: 6a49ed41eab79d745c53723ce7f134222279545e
Unify towards k8s.io/utils/clock - part 2

Kubernetes-commit: 9918aa1e035a00bc7c0f16a05e1b222650b3eabc
Kubernetes-commit: bb7dac443a2039f97c822f610e78d4b65482c56d
liggitt and others added 23 commits October 28, 2021 00:16
Kubernetes-commit: 091724a6d86eb8ce86ffd4aaca4e8d4fb07785ef
PodSecurity: return namespace validation errors in standard field.ErrorList format

Kubernetes-commit: 1d9d530ee1b672acb9f2ba089123b5350d64dc3b
Kubernetes-commit: a4f6152743af5201fdbb48bda6730797d3c8f572
Upgrade sigs.k8s.io/structured-merge-diff/v4 to v4.2.0

Kubernetes-commit: 8e2d7a3d64976eb23e1a4fdc8c068f5210014da6
Updates to consume the aggregated OpenAPI spec lazy-marshaling behaviour
introduced with: kubernetes/kube-openapi#251

Signed-off-by: Alper Rifat Ulucinar <[email protected]>

Kubernetes-commit: 38f888bdd14b8eddb86ec8ca8461267fe7f8ded1
Fix bug where using kubectl patch with $deleteFromPrimitiveList on an empty or nonexistent list adds the item to be removed

Kubernetes-commit: 0b0007ae68c464cf97759057226a0930f91c3893
Bump k8s.io/kube-openapi to commit ee342a809c29

Kubernetes-commit: f59b0a56c6ebc1a1891435ba5b094b9afe8c1c3c
Kubernetes-commit: d73403dc12ad1d9576d65b5c65e30a87d17ad314
Add wired off code for Validation rules for Custom Resource Definitions using the CEL expression language

Kubernetes-commit: 6b41d75794381487ef7204b016faa75e350a32b7
Kubernetes-commit: 73ffb492032896c1c87edfa1d85de5fc74bb526c
… (staticcheck)

Kubernetes-commit: fa3c4b953fb8192c60dcc3874bff8f9c12ffd54d
Kubernetes-commit: 31d45d000b83f982476d175a4e8a13d97cf95def
Kubernetes-commit: c4080c2ad1e0af0dbb8fc6871f3310b3c18a7024
Kubernetes-commit: 35c05a3afa6fc9fee3ab202329ce988faf1dc651
CloseIdleConnections of wrapped Transport RoundTrippers

Kubernetes-commit: 45f77ca4bab08da88bdda267be2157dc10bc64ac
Kubernetes-commit: 98884f733a019ab991da29aaba3e42d89bf202ec
…ure-enablement

Add Support for OpenAPIEnum in OpenAPI v2

Kubernetes-commit: e14bdbaa1c4ed2b31dbce1b03160402483d26889
ResettableRESTMapper to make it possible to reset wrapped mappers

Kubernetes-commit: 165b581759794157b4f4b8d7dfe2501d0e965ff4
Kubernetes-commit: d126b1483840b5ea7c0891d3e7a693bd50fae7f8
use golangci-lint

Kubernetes-commit: 1367cca8fd67b09606b01c0a9e46cef59aef3424
Implements server side field validation behind the
`ServerSideFieldValidation` feature gate. With the
feature enabled, any create/update/patch request
with the `fieldValidation` query param set to
"Strict" will error if the object in the request
body have unknown fields. A value of "Warn"
(also the default when the feautre is enabled)
will succeed the request with a warning.

When the feature is disabled (or the query param
has a value of "Ignore"), the request will succeed
as it previously had with no indications of any
unknown or duplicate fields.

Kubernetes-commit: e50e2bbc889eb274ad1463a54188a2805767bfde
Kubernetes-commit: d148bbcee39e3c290f9d5663e848a398d402152d
…660-upstream-release-1.23

Automated cherry pick of #106660: Revert sigs.k8s.io/structured-merge-diff/v4 to v4.1.2

Kubernetes-commit: 724289524084f6edbbe53e31d2c6e636343fdebb
@lukasschwab lukasschwab changed the title feat: merge upstream k8s.io/apimachinery v0.23.0 feat: merge upstream k8s.io/apimachinery v0.23.0 [ID-1143] Dec 8, 2021
Kubernetes release v1.23.0

Based on https://github.com/kubernetes/kubernetes/releases/tag/v1.23.0

Pin go-version 1.17 in build workflow: requires Go ≥1.16
@lukasschwab lukasschwab marked this pull request as ready for review December 8, 2021 20:22
@lukasschwab lukasschwab merged commit 3fd9737 into main Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.