From 2a53c4e792e198ba3614fcf65956e770ea71b72a Mon Sep 17 00:00:00 2001 From: David Haja Date: Thu, 12 Sep 2024 18:38:29 +0200 Subject: [PATCH] Deprecate label flag and Align label filter flag with attribute filter flag name (#3232) * Deprecating label flag and introducing labels-filter flag Signed-off-by: root * Add changelog for labels-filter flag alignment * change_type modified to deprecation, mention deprecated and new flags in changelog and follow-up issue * Fix label filtering flag in e2e tests --------- Signed-off-by: root --- .chloggen/3218-align-label-filter-flag.yaml | 16 ++++++++++++++++ .github/workflows/e2e.yaml | 2 +- main.go | 7 ++++++- 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 .chloggen/3218-align-label-filter-flag.yaml diff --git a/.chloggen/3218-align-label-filter-flag.yaml b/.chloggen/3218-align-label-filter-flag.yaml new file mode 100755 index 0000000000..3daf4a7cf1 --- /dev/null +++ b/.chloggen/3218-align-label-filter-flag.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: deprecation + +# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action) +component: operator + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "Deprecated `label` flag and introduced `labels-filter` flag to align the label filtering with the attribute filtering flag name. The `label` flag will be removed when #3236 issue is resolved." + +# One or more tracking issues related to the change +issues: [3218] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 40ac159045..08e6da0b83 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -40,7 +40,7 @@ jobs: - group: e2e-multi-instrumentation setup: "add-multi-instrumentation-params prepare-e2e" - group: e2e-metadata-filters - setup: "add-operator-arg OPERATOR_ARG='--annotations-filter=.*filter.out --annotations-filter=config.*.gke.io.* --labels=.*filter.out' prepare-e2e" + setup: "add-operator-arg OPERATOR_ARG='--annotations-filter=.*filter.out --annotations-filter=config.*.gke.io.* --labels-filter=.*filter.out' prepare-e2e" - group: e2e-automatic-rbac setup: "add-rbac-permissions-to-operator prepare-e2e" steps: diff --git a/main.go b/main.go index 25913cd28f..951ba2ee1a 100644 --- a/main.go +++ b/main.go @@ -133,6 +133,7 @@ func main() { autoInstrumentationNginx string autoInstrumentationGo string labelsFilter []string + tmplabelsFilter []string annotationsFilter []string webhookPort int tlsOpt tlsConfig @@ -170,7 +171,8 @@ func main() { stringFlagOrEnv(&autoInstrumentationGo, "auto-instrumentation-go-image", "RELATED_IMAGE_AUTO_INSTRUMENTATION_GO", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-go-instrumentation/autoinstrumentation-go:%s", v.AutoInstrumentationGo), "The default OpenTelemetry Go instrumentation image. This image is used when no image is specified in the CustomResource.") stringFlagOrEnv(&autoInstrumentationApacheHttpd, "auto-instrumentation-apache-httpd-image", "RELATED_IMAGE_AUTO_INSTRUMENTATION_APACHE_HTTPD", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-apache-httpd:%s", v.AutoInstrumentationApacheHttpd), "The default OpenTelemetry Apache HTTPD instrumentation image. This image is used when no image is specified in the CustomResource.") stringFlagOrEnv(&autoInstrumentationNginx, "auto-instrumentation-nginx-image", "RELATED_IMAGE_AUTO_INSTRUMENTATION_NGINX", fmt.Sprintf("ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-apache-httpd:%s", v.AutoInstrumentationNginx), "The default OpenTelemetry Nginx instrumentation image. This image is used when no image is specified in the CustomResource.") - pflag.StringArrayVar(&labelsFilter, "label", []string{}, "Labels to filter away from propagating onto deploys. It should be a string array containing patterns, which are literal strings optionally containing a * wildcard character. Example: --label=.*filter.out will filter out labels that looks like: label.filter.out: true") + pflag.StringArrayVar(&labelsFilter, "labels-filter", []string{}, "Labels to filter away from propagating onto deploys. It should be a string array containing patterns, which are literal strings optionally containing a * wildcard character. Example: --labels-filter=.*filter.out will filter out labels that looks like: label.filter.out: true") + pflag.StringArrayVar(&tmplabelsFilter, "label", []string{}, "(Deprecated, please use the labels-filter flag) Labels to filter away from propagating onto deploys. It should be a string array containing patterns, which are literal strings optionally containing a * wildcard character. Example: --label=.*filter.out will filter out labels that looks like: label.filter.out: true") pflag.StringArrayVar(&annotationsFilter, "annotations-filter", []string{}, "Annotations to filter away from propagating onto deploys. It should be a string array containing patterns, which are literal strings optionally containing a * wildcard character. Example: --annotations-filter=.*filter.out will filter out annotations that looks like: annotation.filter.out: true") pflag.StringVar(&tlsOpt.minVersion, "tls-min-version", "VersionTLS12", "Minimum TLS version supported. Value must match version names from https://golang.org/pkg/crypto/tls/#pkg-constants.") pflag.StringSliceVar(&tlsOpt.cipherSuites, "tls-cipher-suites", nil, "Comma-separated list of cipher suites for the server. Values are from tls package constants (https://golang.org/pkg/crypto/tls/#pkg-constants). If omitted, the default Go cipher suites will be used") @@ -181,6 +183,9 @@ func main() { pflag.IntVar(&webhookPort, "webhook-port", 9443, "The port the webhook endpoint binds to.") pflag.Parse() + // Using labelfilters both from label and labels-filter flags, until label flag is removed + labelsFilter = append(labelsFilter, tmplabelsFilter...) + opts.EncoderConfigOptions = append(opts.EncoderConfigOptions, func(ec *zapcore.EncoderConfig) { ec.MessageKey = encodeMessageKey ec.LevelKey = encodeLevelKey