Re: cf restart-app-instance and environment variables #cf


Daniel Mikusa
 



On Tue, Jun 19, 2018 at 12:45 AM, Preetam Palwe <preetam.palwe@...> wrote:

[Edited Message Follows]
[Reason: extra observation and information]

Hello everyone !

I am observing that the new environment variable set to my application using cf set-env is not getting reflected in the container even after cf restart-app-instance is done. Why is it so?

To give a brief context - I have an Java Spring Boot application which is deployed on PCF. I am setting a new env var using cf set-env. In order to reflect the env var in the application I understand that application restart is essential. (I don't need restage as my env var is not getting used in the buildpack.)
But cf restart as per documentation create downtime. Hence I decided to scale my application to minimum 2 instances and then used cf restart-app-instance one by one for the 2 instances. (It's kind of rolling restart)
I was expecting that the env var will get reflected in each instance but it has not happened. I checked this by both means - printing env vars in my application and doing cf ssh -i on each instance. In both cases I was not able to see the new env var.

What could be wrong or am I missing something here?

Versions I am using are 
CLI version 6.32.0+0191c33d9.2017-09-26
PCF version 1.12
Note - I did observed that cf restart reflected the env variables as expected. (only cf restart-app-instance failed to do that - why?)

I'd guess that it's because you don't ever want to have an inconsistent state across your app instances.  If you were able to use `cf restart-app-instance` and see this change then you'd have one app instance which could see it and possibly other app instances that cannot (at least until they're all restarted this way).  Conversely, `cf restart` will restart all of your app instances so they'll all see the new variable and everything will be consistent.  Inconsistency is bad, the platform is trying to protect you.

Dan

 

Appreciate any help on this - Many Thanks !
~Preetam


Join {cf-dev@lists.cloudfoundry.org to automatically receive all group messages.