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
#!/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
@aaron-prindle
aaron-prindle / rc_declarative_validation.yaml
Created March 14, 2025 17:16
rc_declarative_validation.yaml
# Test Case: valid replicas (1), feature gate enabled
# Expected: Success
apiVersion: v1
kind: ReplicationController
metadata:
name: rc-validation-1
namespace: default
spec:
replicas: 1
selector:
@aaron-prindle
aaron-prindle / gist:987095fed89996ac8a93496ce7c21b78
Created March 14, 2025 17:04
test/integration/apiserver/declarative_validation_metrics_test.go test passing @ k/k HEAD
/*
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