Skip to content

Instantly share code, notes, and snippets.

View aaron-prindle's full-sized avatar
💭
📦

Aaron Prindle aaron-prindle

💭
📦
  • Google
  • San Francisco
View GitHub Profile
@aaron-prindle
aaron-prindle / gist:4a7aec96960154029a4730507682aa4c
Created October 20, 2025 20:26
KAL output before `batch` K8s API group optionalrequired updates
aprindle@aprindle-ssd-v2 ~/kubernetes [(HEAD detached at JoelSpeed/enable-kal-optionalorrequired-apiserver-internal)]./hack/verify-golangci-lint.sh ./staging/src/k8s.io/api/batch/...
installing golangci-lint, logcheck kube-api-linter and sorted plugins from hack/tools/golangci-lint into /usr/local/google/home/aprindle/kubernetes/_output/local/bin
running /usr/local/google/home/aprindle/kubernetes/_output/local/bin/golangci-lint run --color=always --config=/usr/local/google/home/aprindle/kubernetes/hack/golangci.yaml ./staging/src/k8s.io/api/batch/...
ERROR: level=warning msg="[linters_context] gocritic: no need to enable check \"deprecatedComment\": it's already enabled"
ERROR: staging/src/k8s.io/api/batch/v1/types.go:191:2: optionalorrequired: field Operator must be marked as optional or required (kubeapilinter)
ERROR: Operator PodFailurePolicyOnExitCodesOperator `json:"operator" protobuf:"bytes,2,req,name=operator"`
ERROR: ^
ERROR: staging/src/k8s.io/api/batch/v1/types.go:199:2: optionalorrequired: field
@aaron-prindle
aaron-prindle / gist:7dbe934092717d1b047d0e7aba5dc171
Last active September 27, 2025 00:29
declarative validation error matcher path translation feature - benchmark test code
import (
"fmt"
"regexp"
"testing"
)
// generateNormalizationRules is a helper function to create a slice of N pre-compiled normalization rules.
func generateNormalizationRules(n int) []NormalizationRule {
rules := make([]NormalizationRule, n)
for i := 0; i < n; i++ {
#!/bin/bash
# CSR Testing Script - All CREATE and UPDATE operations with output logging
# This script tests CSR operations on /, /status, and /approval endpoints
# Uses kubectl with proper raw API access for updates
# Also captures validation mismatch metrics after each operation
set -e
# Configuration
Running tool: /usr/bin/go test -timeout 30s -run ^(TestDeclarativeValidateForDeclarative|TestValidateUpdateForDeclarative)$ k8s.io/kubernetes/pkg/registry/certificates/certificates
E0718 23:44:35.730445 4187615 validate.go:187] "Unexpected difference between hand written validation and declarative validation error results, unmatched error(s) found {Type=\"Invalid value\", Field=\"status.conditions\", Origin=\"zeroOrOneOf\"}. This indicates an issue with declarative validation. Consider disabling the DeclarativeValidationTakeover feature gate to keep data persisted in etcd consistent with prior versions of Kubernetes."
E0718 23:44:35.730641 4187615 validate.go:187] "Unexpected difference between hand written validation and declarative validation error results, extra error(s) found {Type=\"Internal error\", Field=\"<nil>\", Origin=\"\"}. This indicates an issue with declarative validation. Consider disabling the DeclarativeValidationTakeover feature gate to keep data persisted in etcd consistent with prior ver
//go:build !ignore_autogenerated
// +build !ignore_autogenerated
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
/*
Copyright 2025 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"path/filepath"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
parts := strings.Split(rsName, "-")
if len(parts) < 2 {
t.Errorf("ReplicaSet name should contain at least one hyphen separator")
}
deploymentPortion := strings.Join(parts[:len(parts)-1], "-")
if len(test.deploymentName) <= 242 {
if deploymentPortion != test.deploymentName {
t.Errorf("Deployment name portion mismatch: got %q, want %q", deploymentPortion, test.deploymentName)
}
@aaron-prindle
aaron-prindle / gist:5a47f8b64a5ec8cff870b5bc12590216
Created May 22, 2025 23:47
add // +k8s:minimum=600 to certificates.k8s.io/v1/CertificateSigningRequest
aprindle@aprindle-ssd ~/validation-gen [my-validation-gen_enable-csr-view]git diff
diff --git a/pkg/apis/certificates/validation/validation_test.go b/pkg/apis/certificates/validation/validation_test.go
index a54aa9adf46..25fa6a7d367 100644
--- a/pkg/apis/certificates/validation/validation_test.go
+++ b/pkg/apis/certificates/validation/validation_test.go
@@ -274,7 +274,7 @@ func TestValidateCertificateSigningRequestCreate(t *testing.T) {
},
},
errs: field.ErrorList{
- field.Invalid(specPath.Child("expirationSeconds"), int32(-1), "may not specify a duration less than 600 seconds (10 minutes)"),
@aaron-prindle
aaron-prindle / doc.go
Created April 20, 2025 03:22
+k8s:unionMember only has "1-level-deep" union context example
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software