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

ConfigMap cannot overwrite wavefront freemium account creation #68

Closed
mhoshi-vm opened this issue Jul 10, 2020 · 5 comments
Closed

ConfigMap cannot overwrite wavefront freemium account creation #68

mhoshi-vm opened this issue Jul 10, 2020 · 5 comments

Comments

@mhoshi-vm
Copy link

mhoshi-vm commented Jul 10, 2020

I developed a spring boot application on my local laptop with the following application.properties

wavefront.application.name=demo
wavefront.application.service=HelloRest

As a natural use case, when I move to kubernetes env, i want to use configmap to override the auto freemium config.
So i created the following config map.

kind: ConfigMap
apiVersion: v1
metadata:
  name: hellorest
  namespace: demo8
data:
  wavefront.tracing.enabled: "false"
  wavefront.freemium-account: "false"
  management.metrics.export.wavefront.enabled: "false"
  spring.sleuth.enabled: "false"

However I still see the freemium account being configured.
When enabling debug log, i see that the configmap is getting loaded properly during start up

2020-07-10 01:44:33.302 DEBUG [hellorest,,,] 1 --- [           main] o.s.c.e.PropertySourcesPropertyResolver  : Found key 'management.metrics.export.wavefront.enabled' in PropertySource 'bootstrapProperties-configmap.hellorest.demo8' with value of type String
2020-07-10 01:44:33.330 DEBUG [hellorest,,,] 1 --- [           main] o.s.c.e.PropertySourcesPropertyResolver  : Found key 'wavefront.tracing.enabled' in PropertySource 'bootstrapProperties-configmap.hellorest.demo8' with value of type String

However the i don't see any wavefront.freemium-account being loaded.

root@ubuntu18:~/wavefront-demos/demo8/kube-demo# kubectl logs helloworld-86bfb659b9-g6m52 -n demo8 | grep freemium
root@ubuntu18:~/wavefront-demos/demo8/kube-demo#

By the way, adding the above parameters directly in application properties to application.properties, i see that freemium account creation get's disabled.

@mhoshi-vm mhoshi-vm changed the title ConfigMap cannot overwrite wavefront values ConfigMap cannot overwrite wavefront freemium account creation Jul 10, 2020
@snicoll
Copy link
Collaborator

snicoll commented Jul 10, 2020

@mhoshi-vm thanks for reaching out and for the report.

Account negotiation happens very early on in the application lifecycle. The environment has been prepared and the application configuration has been read. I understand from the log (though I am note sure) you're using Spring Cloud and the bootstrap context. Unfortunately, the way this is designed at the moment does not respect Spring Boot's application lifecycle and such configuration is loaded too late for the account negotiation to know.

As a workaround for that problem, you could switch to an env variables or configuring your startup script to set a system property or a command-line switch. This will be applied. Or you could enable a profile and have a application-k8s.properties in your project.

Regarding the 4 properties above, it looks like you want to disable exporting metrics altogether. If that's what you want, management.metrics.export.wavefront.enabled:false is all that you need (post-RC1 we haven't released 2.0.0 yet) as account negotiation will back off if that property is set. If such property is disabled, no configuration of Wavefront will occur and tracing won't be enabled either.

Please give this a try and let us know how it goes.

@mhoshi-vm
Copy link
Author

@snicoll Thank you.

As a workaround for that problem, you could switch to an env variables

Yes this worked. The follow yaml file disabled the freemium account creation

apiVersion: apps/v1
kind: Deployment
metadata:
...
spec:
  replicas: 1
...
  template:
...
    spec:
...
      containers:
...
        env:
        - name: WAVEFRONT_FREEMIUM-ACCOUNT
          value: "false"

If that's what you want, management.metrics.export.wavefront.enabled:false is all that you need

I am using 2.0.0-SNAPSHOT but that parameter alone does not prevent the freemium account creation.
I still see the following during startup with just that.

A Wavefront account has been provisioned successfully and the API token has been saved to disk.

To share this account, make sure the following is added to your configuration:

        management.metrics.export.wavefront.api-token=xxxx
        management.metrics.export.wavefront.uri=https://wavefront.surf

Connect to your Wavefront dashboard using this one-time use link:
https://wavefront.surf/us/xxxx

@snicoll
Copy link
Collaborator

snicoll commented Jul 13, 2020

Thanks for the feedback and glad to hear that env works for you.

I am using 2.0.0-SNAPSHOT but that parameter alone does not prevent the freemium account creation.
I still see the following during startup with just that.

I can't reproduce the behaviour you've described. Perhaps you're using an older snapshot or something? Just to make sure that we're talking about the same thing, I've created a sample project with only that property and the account creation is disabled for me.

You can try it out as follows:

git clone https://github.com/snicoll-scratches/wavefront-disable-metrics.git
cd wavefront-disable-metrics
./mvnw spring-boot:run

@mhoshi-vm
Copy link
Author

@snicoll thanks for the sample code.

So here is what i see from your code.

  • Yes, management.metrics.export.wavefront.enabled=false stops freemium account creation if defined at application.properties.
  • The problem happens when combining with Spring Boot Kubernetes and overwrite with configmaps. The following will not prevent the freemium account creation. The solution that i found was to add WAVEFRONT_FREEMIUM-ACCOUNT: false to the env
kind: ConfigMap
apiVersion: v1
metadata:
  name: hellorest
  namespace: demo8
data:
  management.metrics.export.wavefront.enabled: "false"

BTW, In my scenario, I created my app on a non-k8s env, and i want to move it to kubernetes + istio, which i want to let istio handle the traces, not spring.

@snicoll
Copy link
Collaborator

snicoll commented Jul 13, 2020

Thanks for the feedback. If WAVEFRONT_FREEMIUMACCOUNT works, there is no reason why MANAGEMENT_METRICS_EXPORT_WAVEFRONT_ENABLED wouldn't. I am still quite confused as what you're trying to do. If you disable the freemium account (and only that) the application won't start as metrics are not disabled and a token is mandatory.

In any case, it looks like this issue has run its course. We also have a slack channel if you want to chat with the community.

@snicoll snicoll closed this as completed Jul 13, 2020
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

No branches or pull requests

2 participants