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

feat: disable-reporting juju config option #471

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

MichaelThamm
Copy link
Contributor

Issue

Some users do not want to send anonymous usage statistics to stats.grafana.org. For example, in an air-gapped environment this may cause excess logs due to the endpoint being unreachable.

Solution

  1. Adding a config option
    Add a juju config option to the loki charm. By default the config will send usage statistics and will not write to the config file. Only if the reporting-enabled option is set to false, then we write to the analytics block with reporting_enabled=false

  2. Add and fix tests
    In an attempt to add scenario tests for testing this config option, the pin for ops=2.16 was removed and technical debt was removed to be compatible with the new ops.testing Scenario 7 syntax.

Context

Since we want to contribute to upstream open-source, we leave the default option as reporting enabled.

Testing Instructions

Note: Deploying --config reporting-enabled=true is functionally equivalent to not supplying a config.

  1. Pack the charm
    charmcraft pack

Deploy Loki default

  1. Deploy loki (reporting enabled by default)
juju deploy ./*.charm loki --resource loki-image=docker.io/ubuntu/loki:2-22.04 --resource node-exporter-image=docker.io/prom/node-exporter:v1.7.0 --trust
juju ssh --container loki loki/0 cat /etc/loki/loki-local-config.yaml | yq -r '.analytics'
-> null
  1. Toggle the reporting config
juju config loki reporting-enabled=false
juju ssh --container loki loki/0 cat /etc/loki/loki-local-config.yaml | yq -r '.analytics'
-> reporting_enabled: false
  1. Scale the application up
juju add-unit loki -n 1
jssh --container loki loki/1 cat /etc/loki/loki-local-config.yaml | yq -r '.analytics'
-> reporting_enabled: false
  1. Toggle the config
juju config loki reporting-enabled=true
jssh --container loki loki/1 cat /etc/loki/loki-local-config.yaml | yq -r '.analytics'
-> null

Deploy Loki with reporting disabled

  1. Deploy loki-off (reporting disabled)
juju deploy ./*.charm loki-off --resource loki-image=docker.io/ubuntu/loki:2-22.04 --resource node-exporter-image=docker.io/prom/node-exporter:v1.7.0 --config reporting-enabled=false --trust
juju ssh --container loki loki-off/0 cat /etc/loki/loki-local-config.yaml | yq -r '.analytics'
-> reporting_enabled: false
  1. Toggle the reporting config
juju config loki-off reporting-enabled=true
juju ssh --container loki loki-off/0 cat /etc/loki/loki-local-config.yaml | yq -r '.analytics'
-> null
  1. Scale the application up
juju add-unit loki-off -n 1
jssh --container loki loki-off/1 cat /etc/loki/loki-local-config.yaml | yq -r '.analytics'
-> null
  1. Toggle the config
juju config loki-off reporting-enabled=false
jssh --container loki loki-off/1 cat /etc/loki/loki-local-config.yaml | yq -r '.analytics'
-> reporting_enabled: false

Upgrade Notes

2. Add scenario tests
3. Remove ops pin=2.16
@MichaelThamm MichaelThamm requested a review from a team as a code owner November 15, 2024 19:02
Copy link
Contributor

@sed-i sed-i left a comment

Choose a reason for hiding this comment

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

Nice!

@MichaelThamm MichaelThamm merged commit cf6a25b into main Nov 16, 2024
13 checks passed
@MichaelThamm MichaelThamm deleted the feature/disable_reporting branch November 16, 2024 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants