Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created annotations filter #2692

Merged
merged 15 commits into from
Mar 7, 2024

Conversation

yuriolisa
Copy link
Contributor

Description:

Created ability to filter out Annotations
Link to tracking Issue(s):

Testing:
Unit tests have been modified accordingly.

Documentation:

@yuriolisa yuriolisa requested a review from a team February 29, 2024 14:45
Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few small things, also can you augment or create an e2e test for this? do we have one for the label filter that we could tack this on to?

const configMapHashAnnotationKey = "opentelemetry-opampbridge-config/hash"

// Annotations returns the annotations for the OPAmpBridge Pod.
func Annotations(instance v1alpha1.OpAMPBridge, configMap *v1.ConfigMap, filterAnnotations []string) map[string]string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder if we should also move annotations.go and labels.go to a shared thing in manifestutils?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I've tried to do that, but I faced an import cycle issue. I believe we could dig into that in the future, moving the annotations to the manifestutils. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense, want to open an issue about that?

@yuriolisa
Copy link
Contributor Author

a few small things, also can you augment or create an e2e test for this? do we have one for the label filter that we could tack this on to?

Added some e2e for Labels and Annotations filters.

Do you think we should change the parameter from labels to labels-filter? I know it's a breaking change, however, this name makes more sense for that purpose.

@jaronoff97
Copy link
Contributor

@yuriolisa i think if we make that change (renaming labels) we should do it in a follow up

@jaronoff97
Copy link
Contributor

also, looks like the e2e tests are failing on make:
make: unrecognized option '--annotations=*filter.out'

@yuriolisa
Copy link
Contributor Author

@yuriolisa i think if we make that change (renaming labels) we should do it in a follow-up

So, if we intend to do a follow-up, I decided to set the annotations parameters as annotations-filter.

@yuriolisa
Copy link
Contributor Author

also, looks like the e2e tests are failing on make: make: unrecognized option '--annotations=*filter.out'

Thanks for catching-up on that, it should be labels instead, once we don't have any e2e labels filter yet.

Copy link
Contributor

@jaronoff97 jaronoff97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one small nit, otherwise this LGTM. given the size of this, I'm going to wait to merge on another approver to give it a ✅

@jaronoff97 jaronoff97 requested a review from a team March 4, 2024 18:29
Copy link
Contributor

@swiatekm swiatekm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this looks good to me, although I think we ended up putting way too many changes into this PR. For example, the config hash annotation for opamp bridge definitely should've been a separate PR. I'm fine with merging as-is, though I wouldn't mind splitting it either.

The main thing that's actually unclear to me, is what the format of the --annotations-filter value is supposed to be. It looks like a glob, but then we parse it into a regex in a weird way. I'd like us to document it better, even if it's just a description of the flag.

Signed-off-by: Yuri Sa <[email protected]>
@yuriolisa
Copy link
Contributor Author

All of this looks good to me, although I think we ended up putting way too many changes into this PR. For example, the config hash annotation for opamp bridge definitely should've been a separate PR. I'm fine with merging as-is, though I wouldn't mind splitting it either.

The main thing that's actually unclear to me, is what the format of the --annotations-filter value is supposed to be. It looks like a glob, but then we parse it into a regex in a weird way. I'd like us to document it better, even if it's just a description of the flag.

@swiatekm-sumo, thank you for pointing out these topics. I will be aware next time to split into smaller parts. I've just sent an improvement to the parameter. Let me know wdyt.

@jaronoff97 jaronoff97 enabled auto-merge (squash) March 7, 2024 20:23
@jaronoff97 jaronoff97 merged commit 08b33a5 into open-telemetry:main Mar 7, 2024
31 checks passed
@ryanohnemus
Copy link

@yuriolisa Thank you for adding this!!

@yuriolisa
Copy link
Contributor Author

yuriolisa commented Mar 7, 2024

@yuriolisa Thank you for adding this!!

No problem, happy to contribute; I hope it's gonna helpful for your use case.

@ryanohnemus
Copy link

ryanohnemus commented Mar 18, 2024

I just tested this out using the latest v0.96.0 image and the annotations aren't being filtered out as I'd expect. I'm not sure what i'm missing.

I setup a kind cluster via:

kind create cluster --config kind-1.29.yaml
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.4/cert-manager.yaml

then I downloaded the latest install here:

curl -Lo otel-op.yaml https://github.com/open-telemetry/opentelemetry-operator/releases/latest/download/opentelemetry-operator.yaml

I then edited that to add the --annotations-filter arg below for the operator's Deployment:

kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: opentelemetry-operator
    control-plane: controller-manager
  name: opentelemetry-operator-controller-manager
  namespace: opentelemetry-operator-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: opentelemetry-operator
      control-plane: controller-manager
  template:
    metadata:
      labels:
        app.kubernetes.io/name: opentelemetry-operator
        control-plane: controller-manager
    spec:
      containers:
      - args:
        - --metrics-addr=127.0.0.1:8080
        - --enable-leader-election
        - --zap-log-level=info
        - --zap-time-encoding=rfc3339nano
        - --feature-gates=+operator.autoinstrumentation.go,+operator.autoinstrumentation.nginx
        - --annotations-filter="config.*.gke.io.*"
        image: ghcr.io/open-telemetry/opentelemetry-operator/opentelemetry-operator:0.96.0

Finally I added an OpenTelemetryCollector resource that has an annotation I was expecting filtered out:

apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
  name: simplest
  annotations:
    configmanagement.gke.io/token: "asdfasdf"
spec:
  config: |
    receivers:
      otlp:
        protocols:
          grpc:
          http:
    processors:
      memory_limiter:
        check_interval: 1s
        limit_percentage: 75
        spike_limit_percentage: 15
      batch:
        send_batch_size: 10000
        timeout: 10s

    exporters:
      debug:

    service:
      pipelines:
        traces:
          receivers: [otlp]
          processors: []
          exporters: [debug]

The configmanagement.gke.io/token: asdfasdf is still added to the template for the deployment of the collector and is still added to the pod.

Am I using the --annotations-filter option incorrectly?

ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
* Created annotations filter

Signed-off-by: Yuri Sa <[email protected]>

* Created annotations filters test

Signed-off-by: Yuri Sa <[email protected]>

* Adjusted linters

Signed-off-by: Yuri Sa <[email protected]>

* Added Annotations Filter for OpAMP and TA

Signed-off-by: Yuri Sa <[email protected]>

* Added e2e tests for Labels and Annotations

Signed-off-by: Yuri Sa <[email protected]>

* Added e2e tests for Labels and Annotations

Signed-off-by: Yuri Sa <[email protected]>

* Added e2e tests for Labels and Annotations

Signed-off-by: Yuri Sa <[email protected]>

* Added e2e tests for Labels and Annotations

Signed-off-by: Yuri Sa <[email protected]>

* Fixed tests

Signed-off-by: Yuri Sa <[email protected]>

* Reverting kustomization

Signed-off-by: Yuri Sa <[email protected]>

* Reverting kustomization

Signed-off-by: Yuri Sa <[email protected]>

* Improved annotations

Signed-off-by: Yuri Sa <[email protected]>

* Changed description

Signed-off-by: Yuri Sa <[email protected]>

---------

Signed-off-by: Yuri Sa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propagated annotations causes issues for Deployment, StatefulSet and DaemonSet
4 participants