You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix: improve operator robustness, performance and code quality (#39)
* fix: prevent nil pointer dereference and silent error handling in overcommit logic
- Return safe no-op values (1.0, 1.0) when errors occur instead of
continuing with zero values or crashing on nil pointer dereference
- Remove unused getNamespaceYAML function and YAML roundtrip
- Properly handle all error paths in getNamespaceOvercommit and
checkOvercommitType to avoid mutating pods with incorrect values
- Use direct client.Get for namespace instead of YAML marshal/unmarshal
* fix: add idempotency guard to prevent double overcommit mutation
- Add annotation 'overcommit.inditex.dev/applied' to track if a pod
has already been mutated by the webhook
- Skip mutation on reinvocation (reinvocationPolicy=IfNeeded) if pod
was already processed by the same overcommit class
- Store applied CPU/memory ratios in annotations for observability
- Resize operations always re-apply since limits may have changed
* perf: remove unnecessary 10s periodic requeue from controllers
- Remove RequeueAfter=10s from both Overcommit and OvercommitClass
reconcilers to reduce unnecessary API server load
- Rely on event-driven reconciliation (watches) which is the standard
controller-runtime pattern for reacting to resource changes
* refactor: propagate context instead of using context.Background/TODO
- Accept context parameter in Overcommit and OvercommitOnResize
functions, propagated from the webhook admission handler
- Accept context in GetDefaultSpec and GetPodServiceAccount instead
of creating context.Background()/context.TODO() internally
- Enables proper cancellation, timeouts, and distributed tracing
through the full call chain
* refactor: remove redundant delegate methods from OvercommitClass
- Remove ~30 getter/setter methods that simply forwarded to the
embedded metav1.ObjectMeta, which already implements the v1.Object
interface via Go struct embedding
- Remove unused 'k8s.io/apimachinery/pkg/types' import
- Reduces ~140 lines of dead code improving maintainability
* fix: add ReDoS protection for excludedNamespaces regex validation
- Limit regex length to 512 characters to mitigate catastrophic
backtracking (ReDoS) attacks via overly complex patterns
- Improve error message to include the actual regexp compilation error
for better debugging
* fix: reduce TLS certificate duration from 10 years to 1 year
- Change certificate duration from 87600h (10y) to 8760h (1y)
- Shorter-lived certificates reduce the attack surface if a private
key is compromised, following security best practices
- cert-manager will still auto-renew 30 days before expiry
* refactor: pass context to Overcommit function in tests
* chore: run go mod tidy
* docs: translate Spanish comments to English
* fix: correct certificate duration from 10 years to 1 year in generateResources tests
0 commit comments