Skip to content

expose Enable_Chunk_Trace in the crd, enabling TAP debuging #1588

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

Merged
merged 2 commits into from
Apr 27, 2025

Conversation

danielpodwysocki
Copy link
Contributor

implements #1586 closes #1586

This enables the users to turn debug traces on/off, as per https://docs.fluentbit.io/manual/administration/troubleshooting

I validate that I can spin up the operator and:

  • enable/disable the option, it respects the SIGHUP&hot reload correcty
  • see the expected result - I can now switch to a debug image and use the curl API to enable tracing

In my testing I used the following spec:

apiVersion: fluentbit.fluent.io/v1alpha2
kind: FluentBit
metadata:
  name: fluent-bit
  namespace: fluent
  labels:
    app.kubernetes.io/name: fluent-bit
spec:
  # renovate: datasource=docker depName=ghcr.io/fluent/fluent-operator/fluent-bit
  image: ghcr.io/fluent/fluent-operator/fluent-bit:4.0-debug
  fluentBitConfigName: fluent-bit-config

---
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterFluentBitConfig
metadata:
  name: fluent-bit-config
  namespace: fluent
  labels:
    app.kubernetes.io/name: fluent-bit
spec:
  service:
    enableChunkTrace: true
    httpServer: true
    httpListen: "127.0.0.1"
  inputSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"
  outputSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"

---
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterInput
metadata:
  name: dummy
  labels:
    fluentbit.fluent.io/enabled: "true"
spec:
  alias: dummy
  dummy:
    tag: my_dummy

---
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterOutput
metadata:
  name: stdout
  labels:
    fluentbit.fluent.io/enabled: "true"
spec:
  alias: stdout
  match: "*"
  stdout: {}

I could exec into the container and enable tracing with:

curl 127.0.0.1:2020/api/v1/trace/dummy

To disable it, I ran:

curl -X DELETE 127.0.0.1:2020/api/v1/trace/dummy

I saw the correct output reflected on fluentbit container log.

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduced a user-facing change?


Additional documentation, usage docs, etc.:


implements fluent#1586 closes fluent#1586

This enables the users to turn debug traces on/off, as per https://docs.fluentbit.io/manual/administration/troubleshooting

I validate that I can spin up the operator and:
- enable/disable the option, it respects the SIGHUP&hot reload correcty
- see the expected result - I can now switch to a debug image and use
  the  curl API to enable tracing

In my testing I used the following spec:

```
apiVersion: fluentbit.fluent.io/v1alpha2
kind: FluentBit
metadata:
  name: fluent-bit
  namespace: fluent
  labels:
    app.kubernetes.io/name: fluent-bit
spec:
  # renovate: datasource=docker depName=ghcr.io/fluent/fluent-operator/fluent-bit
  image: ghcr.io/fluent/fluent-operator/fluent-bit:4.0-debug
  fluentBitConfigName: fluent-bit-config

---
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterFluentBitConfig
metadata:
  name: fluent-bit-config
  namespace: fluent
  labels:
    app.kubernetes.io/name: fluent-bit
spec:
  service:
    enableChunkTrace: true
    httpServer: true
    httpListen: "127.0.0.1"
  inputSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"
  outputSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"

---
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterInput
metadata:
  name: dummy
  labels:
    fluentbit.fluent.io/enabled: "true"
spec:
  alias: dummy
  dummy:
    tag: my_dummy

---
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterOutput
metadata:
  name: stdout
  labels:
    fluentbit.fluent.io/enabled: "true"
spec:
  alias: stdout
  match: "*"
  stdout: {}

```

I could exec into the container and enable tracing with:

```
curl 127.0.0.1:2020/api/v1/trace/dummy

```

To disable it, I ran:

```
curl -X DELETE 127.0.0.1:2020/api/v1/trace/dummy
```

I saw the correct output reflected on fluentbit container log.

Signed-off-by: Daniel Podwysocki <[email protected]>
@@ -153,6 +155,9 @@ func (s *Service) Params() *params.KVs {
if s.Daemon != nil {
m.Insert("Daemon", fmt.Sprint(*s.Daemon))
}
if s.EnableChunkTrace != nil {
m.Insert("Enable_Chunk_Trace", fmt.Sprint(*s.EnableChunkTrace))
Copy link
Collaborator

Choose a reason for hiding this comment

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

@cw-Guo cw-Guo merged commit b71a2d2 into fluent:master Apr 27, 2025
9 of 10 checks passed
@cw-Guo
Copy link
Collaborator

cw-Guo commented Apr 27, 2025

Thanks for the contribution! This is very helpful.

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.

Expose the Enable_Chunk_Trace option in the CRD or allow the fluent-watcher to pass arbitrary args
2 participants