Repository navigation
test(otel): model the otelFilters label rules and namespace filter in the label tests - #803
Open
petruanica wants to merge 1 commit into
Open
petruanica wants to merge 1 commit into
petruanica wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the issue
The label tests know only the attribute denylist. The
otelFilterslabel include lists and namespace filter remove data in other processors. An include entry that names a label inside a built-in prefix also makes the chart remove the rest of that prefix in a transform processor. On a cluster that uses these filters, the label tests report false failures. A customer can also choose to remove a protected label with an exclude, and the denylist test then fails.Description of changes
k8sattributeslabel rules and the namespace filter conditions from each agent's ConfigMap (label_extraction.go,namespace_filter.go). A label that no rule extracts must be absent. A pod in a namespace that the filter drops needs no series.ParseAttributeDenylistalso reads the label exception transform (label_exception.go), by its statement shape. If anotelFiltersinclude entry names a label or a longer prefix inside a built-in prefix, the chart renders this transform. It removes the labels under that prefix except the named entries, and the denylist still removes an exclude entry after it.NeverDeniedViolationsalso reports a never-denied attribute that the transform removes. The model cannot read every filter shape, for example a transform that removes or writes label attributes in another way. For such a shape, the subtest skips and names the processor and the reason (ErrFilterNotModeled). The tests read the rendered collector configuration, not the Helm values.ReconcileLabelsandReconcileObjectstake aLabelExtractionin place of the label prefix.TestDenylistSparesNeverDeniedAttributesstays strict by default.OTEL_POD_LABEL_EXCLUDESandOTEL_NODE_LABEL_EXCLUDES(util/otelmetrics/host_types.go) declare theotelFilters.podLabels.excludeandotelFilters.nodeLabels.excludepatterns that a cluster was deployed with. The standard suite'sTestMainprints them. The test logs the denylist entries that those patterns render to. It fails for every other entry that removes a never-denied attribute.This is PR 4 of 4. It builds on PR 3.
License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
The unit tests in
util/otelmetricsrun without a cluster and pass with-race. They cover these areas:helm templaterendered from aws-observability/helm-charts withotelFiltersvalues (testdata/label_filters). The cases are a label and a longer prefix inside a built-in prefix, an exclude entry that removes a kept label, the default values without a transform, and changed transform shapes.go vet -tags integrationpasses onutil/otelmetricsand on every package undertest/otel.gofmtreports nothing, andmake compilepasses.The label tests ran against an EKS test cluster on this commit, with the chart from aws-observability/helm-charts main.
otelFilters.nodeLabels.include: ["*", "beta.kubernetes.io/arch"], the chart renderstransform/cw_k8s_ci_v0_metrics_labels.TestNodeLabelsReachMetricsreads that transform from both agent configurations, expectsbeta.kubernetes.io/archand no otherbeta.kubernetes.io/label on each node, and passes on both paths.TestDenylistSparesNeverDeniedAttributesalso passes.PR Checklist
makepasses locally (build, unit tests, lint):make compileandmake simple-lint, the targets that the build-check workflow runs, pass on this commit, and so do theutil/otelmetricsunit tests with-race.otelFiltersrendering of feat(chart): Add namespace filters for OTel Container Insights aws-observability/helm-charts#393, Integration Test - Implement the validation for metric value availability and duplicate EMF logs #394 and add macOS sonoma #395 (merged).