Commit Graph

132895 Commits

Author SHA1 Message Date
Kubernetes Prow Robot
16eebeb5ee Merge pull request #134379 from liggitt/gc-race
Lock all mutable fields when printing gc node
2025-10-02 11:40:56 -07:00
Kubernetes Prow Robot
14f808b041 Merge pull request #134310 from humblec/mod-update
cluster/addons: update container images to latest versions
2025-10-02 10:46:57 -07:00
Kubernetes Prow Robot
914f6f1116 Merge pull request #134201 from danwinship/conntrack-workaround
Update comments around an old bug workaround
2025-10-02 08:43:04 -07:00
Kubernetes Prow Robot
f86edc2665 Merge pull request #133929 from huww98/fix-pv-cache-race-v2
scheduler/volumebinding: passive assume cache
2025-10-02 08:42:56 -07:00
Kubernetes Prow Robot
62772eb633 Merge pull request #134377 from borg-land/cos-patch
upgrade to cos 121
2025-10-02 07:46:59 -07:00
upodroid
a7b720ad5b upgrade to cos 121 2025-10-02 16:57:10 +03:00
Jordan Liggitt
6d3d7553fb Lock all mutable fields when printing gc node 2025-10-02 08:50:17 -04:00
Kubernetes Prow Robot
8ac5701d3a Merge pull request #134052 from Jefftree/cle-tests-rename
Rename CLE test files
2025-10-02 00:11:03 -07:00
Kubernetes Prow Robot
c7f910ed1f Merge pull request #133762 from natasha41575/expandQuotaTests
[InPlacePodVerticalScaling] Expand coverage for resourceQuota and limitRanger e2e tests
2025-10-02 00:10:56 -07:00
Humble Devassy Chirammal
6e7762ef0e Update cluster/addons/ip-masq-agent/ip-masq-agent.yaml
Co-authored-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2025-10-02 11:57:15 +05:30
Humble Devassy Chirammal
b5805f28e7 Update cluster/addons/kube-network-policies/kube-network-policies.yaml
Co-authored-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
2025-10-02 11:57:08 +05:30
Kubernetes Prow Robot
48390fb98e Merge pull request #134347 from yongruilin/master_vg-cleanup
feat(validation-gen): Add "cohorts" & Tighten and simplify test framework
2025-10-01 16:40:56 -07:00
Kubernetes Prow Robot
0f8107c736 Merge pull request #134211 from aaron-prindle/resourceclaim_maxitems
Add declarative validation +k8s:maxItems tag to ResourceClaim
2025-10-01 15:22:56 -07:00
yongruilin
46c15a1844 fix typo in comment for namespace validation to appease verify-spelling 2025-10-01 22:04:12 +00:00
yongruilin
2fd76c8ed1 fix: Comment out ipSloppyValidator
It is currently not supported.
2025-10-01 21:38:57 +00:00
yongruilin
51f02aa58a fix: Update error origin in ValidateDNS1123Label to use k8s-short-name format 2025-10-01 21:10:07 +00:00
yongruilin
6b11e6433c run update-codegen to for ReplicationController 2025-10-01 20:42:23 +00:00
Kubernetes Prow Robot
5e0707e820 Merge pull request #134278 from raywainman/patch-4
Update SIG-Autoscaling Leads
2025-10-01 13:19:07 -07:00
Kubernetes Prow Robot
013ac7eaf6 Merge pull request #134257 from mayank-agrwl/debugsocket-contextual-logs
Add RunWithContext method for debugsocket
2025-10-01 13:18:59 -07:00
Tim Hockin
0a26ff5cb4 Update CSR DV test to match RC style
Once we go broad, people will copy these.  Let's make them easy to debug
:)
2025-10-01 19:45:37 +00:00
Tim Hockin
2d48dae391 Eliminate public ValidateReplicationControllerName
Everyone who referenced it now uses the underlying function.  Clearer
and frees me up to change objectMeta validation without impacting anyone
else.
2025-10-01 19:45:37 +00:00
Tim Hockin
229c6b13ca Validate ReplicationController.metadata.name
This relies on `+k8s:subfield` and validation cohorts.  The
`k8s:optional` ensures that we don't run the name validation if name is
empty, because core apimachinery will already flag it as Required().

This demonstrates some of the DV value - docs and clients are now (in
theory) able to see what RC's name format is.

Co-Authored-by: Yongrui Lin <yongrlin@outlook.com>
2025-10-01 19:45:37 +00:00
Tim Hockin
7cf9989222 Add ValidateObjectMetaWithOpts() to apimachinery
This new function does 1 main thing (changes how name validation works),
and the rest is future-proofing.  Specifically this changes the
signature of the name validation function.

Before: Name validation functions return `[]string` and apimachinery
logic wraps those in `field.Invalid()`.

Problem: This makes it hard to incrementally add declarative validation,
which needs access to potential name and generateName errors to set
origins properly.

After: New name validation functions return `field.ErrorList`, which can
be wrapped in trivial functions to do things like "mark as covered by
declarative" in just one place rather than for all types.

The "WithOpts" part of this gives us a new function name which isn't
horrible and is plausibly useful in the future.

Another notable change is that this no longer directly validates the
`generateName` field (but only on the new path -- existing code still
behaves the same).  From the code:

```
+   // generateName is not directly validated here. Types can have
+   // different rules for name generation, and the nameFn is for validating
+   // the post-generation data, not the input. In the past we assumed that
+   // name generation was always "append 5 random characters", but that's not
+   // NECESSARILY true. Also, the nameFn should always be considering the max
+   // length of the name, and it doesn't know enough about the name generation
+   // to do that. Also, given a bad generateName, the user will get errors
+   // for both the generateName and name fields. We will focus validation on
+   // the name field, which should give a better UX overall.
```

This also beefs up tests a bit.
2025-10-01 19:45:37 +00:00
Tim Hockin
b00e0f3020 Add cohort support to +k8s:item
Given:

```
   // +k8s:item(stringKey: "target", intKey: 42, boolKey: true)=+k8s:validateFalse="item Items[stringKey=target,intKey=42,boolKey=true] 1"
   // +k8s:item(stringKey: "target", intKey: 42, boolKey: true)=+k8s:validateFalse="item Items[stringKey=target,intKey=42,boolKey=true] 2"
   Items []Item `json:"items"`
```

...we get:

```
   func() { // cohort {"stringKey": "target", "intKey": 42, "boolKey": true}
       errs = append(errs, validate.SliceItem(ctx, op, fldPath, obj, oldObj, func(item *Item) bool { return item.StringKey == "target" && item.IntKey == 42 && item.BoolKey == true }, validate.DirectEqual, func(ctx context.Context, op operation.Operation, fldPath *field.Path, obj, oldObj *Item) field.ErrorList {
           return validate.FixedResult(ctx, op, fldPath, obj, oldObj, false, "item Items[stringKey=target,intKey=42,boolKey=true] 1")
       })...)
       errs = append(errs, validate.SliceItem(ctx, op, fldPath, obj, oldObj, func(item *Item) bool { return item.StringKey == "target" && item.IntKey == 42 && item.BoolKey == true }, validate.DirectEqual, func(ctx context.Context, op operation.Operation, fldPath *field.Path, obj, oldObj *Item) field.ErrorList {
           return validate.FixedResult(ctx, op, fldPath, obj, oldObj, false, "item Items[stringKey=target,intKey=42,boolKey=true] 2")
       })...)
   }()
```
2025-10-01 19:45:37 +00:00
Tim Hockin
975df59fcd Add cohort support to +k8s:subfield
Given:

```
    // +k8s:subfield(name)=+k8s:optional
    // +k8s:subfield(name)=+k8s:format=dns-label
    // +k8s:subfield(generateName)=+k8s:optional
    // +k8s:subfield(generateName)=+k8s:format=dns-label
    metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
```

...we get:

```
  errs = append(errs,
    func(fldPath *field.Path, obj, oldObj *metav1.ObjectMeta) (errs field.ErrorList) {
      func() { // cohort name
        if e := validate.Subfield(ctx, op, fldPath, obj, oldObj, "name", func(o *metav1.ObjectMeta) *string { return &o.Name }, validate.OptionalValue); len (e) != 0 {
          return // do not proceed
        }
        errs = append(errs, validate.Subfield(ctx, op, fldPath, obj, oldObj, "name", func(o *metav1.ObjectMeta) *string { return &o.Name }, validate.DNSLabel)...)
      }()
      func() { // cohort generateName
        if e := validate.Subfield(ctx, op, fldPath, obj, oldObj, "generateName", func(o *metav1.ObjectMeta) *string { return &o.GenerateName }, validate.OptionalValue); len(e) != 0
 {
          return // do not proceed
        }
        errs = append(errs, validate.Subfield(ctx, op, fldPath, obj, oldObj, "generateName", func(o *metav1.ObjectMeta) *string { return &o.GenerateName }, validate.DNSLabel)...)
      }()
      return
    }(fldPath.Child("metadata"), &obj.ObjectMeta, safe.Field(oldObj, func(oldObj *corev1.ReplicationController) *metav1.ObjectMeta { return &oldObj.ObjectMeta }))...)
```

It is worth noting that this only works one level deep:

```
    // +k8s:subfield(foo)=+k8s:subfield(bar)=+k8s:optional
    // +k8s:subfield(foo)=+k8s:subfield(bar)=+k8s:format=dns-label
    Field StructType
```

...will generate one cohort ("foo") with two distinct calls to Subfield,
so the optional will not short-circuit format.  If we need deeper
cohorting we need to either make subfield take multiple field names
(e.g. `subfield(foo.bar)` or `subbfield(foo, bar)`) or we need to
accumulate "structure" in addition to validator calls.  This is similar
to how we handle multiple `eachVal` tags - each one iterates the list.
2025-10-01 19:45:37 +00:00
Tim Hockin
efe4d17d15 Add support for validation cohorts
On a given field or type, there may be multiple "cohorts" of validation
which need to be processed together.  For example, a short-circuit
validation and a non-short-circuit for the same subfield.

The unnamed cohort (aka the default cohort) is first, followed by named
cohorts in order they are created.  Named cohorts are emitted as inline
functions, so early-return can be used.

This allows tags like k8s:subfield or k8s:item to generate cohorts
(named after the field's JSON name or the selector string,
respectively).

Subsequent commits will add support to those tags.

Co-Authored-by: Yongrui Lin <yongrlin@outlook.com>
2025-10-01 19:45:21 +00:00
yongruilin
8105dbe5bc Revert "Omit type names of emitted slice elements to appease gofmt"
This reverts commit 243f47f3b3.

Not needed anymore, now that gengo calls 'gofmt -s'
2025-10-01 19:30:27 +00:00
Tim Hockin
5d067af5e1 Prefactor: Fix some bad tests 2025-10-01 19:00:30 +00:00
Tim Hockin
7b93851395 Fix ReplicationControl double validation 2025-10-01 18:37:13 +00:00
yongruilin
04d632dd05 fix: Adjust validation for pool names to ensure proper coverage in device requests 2025-10-01 18:35:23 +00:00
Kubernetes Prow Robot
93e18b57f3 Merge pull request #134352 from AwesomePatrol/move-metrics-to-get-list
Move metrics calculations to getList
2025-10-01 11:29:04 -07:00
Kubernetes Prow Robot
fdb04f9c3b Merge pull request #134340 from pohly/dra-resourceslice-cleanup
DRA: ResourceSlice tracker cleanup
2025-10-01 11:28:57 -07:00
Kubernetes Prow Robot
034079b26e Merge pull request #134355 from liggitt/fix-rv-call
Fix passing runtime.Object to HaveValidResourceVersion check
2025-10-01 10:12:17 -07:00
Patrick Ohly
c36c927d18 DRA ResourceSlice: nicer log output
UniqueString rendered as {} in JSON/YAML, which isn't useful... Providing a
MarshalJSON which dumps the string is better.

This enables full object dumps in the ResourceSlice tracker. While at it:
- Consistently log the object content at level 6.
- Use past tense in log messages (recommended style).
- Rename "patch" -> "rule".
2025-10-01 16:40:19 +02:00
Kubernetes Prow Robot
ef95e1fd7e Merge pull request #134318 from xigang/disruption
disruption: remove unused pdb parameter from getExpectedScale method
2025-10-01 07:38:27 -07:00
Kubernetes Prow Robot
41660cec2e Merge pull request #134139 from aojea/better_error_httpstream_handshae
improve httpstream handshake error logging
2025-10-01 07:38:20 -07:00
Jordan Liggitt
af9facf7ba Fix passing runtime.Object to HaveValidResourceVersion check 2025-10-01 10:00:54 -04:00
Kubernetes Prow Robot
6bb0bd55a3 Merge pull request #134295 from omerap12/hpa-desiredReplicasCount-metric
Add desired_replicas gauge metric to HPA controller
2025-10-01 05:16:17 -07:00
Aleksander Mistewicz
0cb916d4dc Move metrics calculations to getList
Signed-off-by: Aleksander Mistewicz <amistewicz@google.com>
2025-10-01 13:59:26 +02:00
Kubernetes Prow Robot
bded66365e Merge pull request #134258 from mayank-agrwl/apiserver-lease-gc
Make APIServerLeaseGC controller context-aware
2025-10-01 03:34:17 -07:00
Antonio Ojea
fc19fcfb73 improve httpstream handshake error logging
Some tests are flaking in this function, having a better logged
error will help to understand the cause.

Also modify the Handshake function to always write an http error,
otherwise we have inconsistencies in the codebase that is using the
function and since we are already passing the http writer it makes sense
to not just return an error and delegate the response to the caller.
2025-10-01 09:17:00 +00:00
Kubernetes Prow Robot
1a54b78999 Merge pull request #134259 from mayank-agrwl/legacy-token-tracking-controller
Make legacytokentracking controller context aware
2025-10-01 02:04:18 -07:00
Tim Hockin
89b975c6d3 Add comments 2025-10-01 06:42:41 +00:00
Tim Hockin
199c9ac77a Remove ExpectInvalid()
All use cases are converted.

Co-Authored-by: Yongrui Lin <yongrlin@outlook.com>
2025-10-01 06:42:41 +00:00
Tim Hockin
8b08c8e59c Remove ExpectRegexpsByPath()
All use cases are converted.

Co-Authored-by: Yongrui Lin <yongrlin@outlook.com>
2025-10-01 06:42:39 +00:00
Tim Hockin
b922fd9db4 Make ErrorMatcher more strict about multi-match
As discussed in a proposed PR, multi-match makes sense when origin is
specified and matched, but otherwise it feels "loose" to multi-match.
And in fact it was hiding bugs in declarative validation tests and real
bugs (in subsequent commits) in implementation.

Now we allow multi-match if and only if:
  1) ErrorMatcher.ByOrigin() was specified
  2) The origin string is not empty
  3) The multiple "got" errors are not exactly identical

This last part is key -- if some change to DV codegens logic which
(errantly) calls the same function twice, we want to know about it.
2025-10-01 06:26:26 +00:00
yongruilin
a51fb72c7f Simplify tests wrt ratcheting
Co-Authored-by: Tim Hockin <thockin@google.com>
2025-10-01 06:24:40 +00:00
Tim Hockin
054ab36c91 Fix field path for embedded fields in root types
Given the following:

```
type Struct type {
    TypeMeta int

    // +k8s:validateFalse="embedded"
    OtherStruct
}
```

What should the field-path be for the error?

or:

```
type Struct type {
    TypeMeta int

    OtherStruct // embedded
}

// +k8s:validateFalse="otherstruct"
type OtherStruct {
  I int
}
```

Conclusion: If we find an embedded field, we look for a nil fldPath, and
if so we set it to the type name.  Embedded values in root types (e.g.
above `spec`) should not be a things we actually do.

Implementation: Add `safe.Value(*T, func() *T)`
2025-10-01 06:22:06 +00:00
Kubernetes Prow Robot
c0af084da0 Merge pull request #134308 from chizhang21/cordon_state_enhance
fix(cordonhelper): Avoid mutating local node before API call
2025-09-30 22:56:16 -07:00
Kubernetes Prow Robot
81d7612a53 Merge pull request #134330 from michaelasp/rvCmp
Add resource version comparison function in client-go along with conformance
2025-09-30 20:58:16 -07:00