Tags: Cloudzero/cloudzero-agent
Tags
CP-32045: replace hostname-based InPod function with more robust alte… …rnative (#412) The previous `common.InPod()` function was using fragile hostname pattern matching to detect if the code was running inside a Kubernetes cluster. This approach was unreliable because it would fail on build bots running in clusters with non-CloudZero hostnames, and could give false positives for local development machines with "cz-" or "cloudzero-" in their hostnames. This brittle detection mechanism caused issues in CI/CD environments and made the codebase less robust. This change replaces the fragile hostname detection with a direct call to `rest.InClusterConfig()`, which is the standard and reliable way to detect if code is running inside a Kubernetes cluster. The function will either succeed (returning a valid config) or fail with the specific `rest.ErrNotInCluster` error, eliminating both false positives and false negatives. This approach is significantly more robust and follows Kubernetes best practices.
CP-30258: additional validation of PDBs (#336) * CP-30258: rework validation of PDBs `minAvailable` and `maxUnavailable` cannot both be set; Kubernetes will error if they are. Since we set `minAvailable` to 1 by default, if a user sets `maxUnavailable` without explicitly setting `minAvailable` to null, it will result in an invalid chart, which can be counter-intuitive. This adds some extra validation to the generatePodDisruptionBudget helper function which detects cases where both are set, and emits an error explaining not just that both cannot be set, but that due to the default value if you use `maxUnavailable` you need to explicitly set `minAvailable` to null. It also changes how we handle overriding PDBs an the component level; instead of merging the specs at the propertly level like we do for other properties, we look to see if either property (`minAvailable` or `maxUnavailable`) is set and, if so, completely override the default configuration. This removes the need for the user to explicitly set `maxAvailable` to `null` when specifying `minUnavailable` in an override. * Add Helm unittest framework Helm unittest allows us to validate things like checking that if foo.bar is set to 1729 in your values (or overrides), then some.arbitrary.property == 1729 in the output of some template. This also adds a few tests to validate the PDB handling, but there are many more to write.
PreviousNext