[cf-dev] cf restart-app-instance and environment variables #cf

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[cf-dev] cf restart-app-instance and environment variables #cf

Preetam Palwe

[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?)

Appreciate any help on this - Many Thanks !
~Preetam

_._,_._,_

Links:

You receive all messages sent to this group.

View/Reply Online (#8075) | [hidden email] | [hidden email] | Mute This Topic | New Topic

Your Subscription | [hidden email] | Unsubscribe [[hidden email]]

_._,_._,_
Reply | Threaded
Open this post in threaded view
|

Re: [cf-dev] cf restart-app-instance and environment variables #cf

Daniel Mikusa


On Tue, Jun 19, 2018 at 12:45 AM, Preetam Palwe <[hidden email]> 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


_._,_._,_

Links:

You receive all messages sent to this group.

View/Reply Online (#8077) | [hidden email] | [hidden email] | Mute This Topic | New Topic
Mute #cf
Your Subscription | [hidden email] | Unsubscribe [[hidden email]]

_._,_._,_
Reply | Threaded
Open this post in threaded view
|

Re: [cf-dev] cf restart-app-instance and environment variables #cf

Preetam Palwe
Thanks Dan - It's a reasonable guess!

Following link has some explanation about why it has not worked on Diego - (The documentation of cf restart-app-instance should have this mentioned.)
https://github.com/cloudfoundry/cli/issues/777 

As per above link - Diego team has done some work to propogate env var changes during restart-app-instance. Does anyone here know more about it?
Is there any way to get env vars reflected using cf restart-app-instance or any other means without downtime?

On other hand I also thought about using copy-source but that command require the target app to exist. Can we clone the app?

Appreciate any help on this - Many Thanks !
~Preetam
_._,_._,_

Links:

You receive all messages sent to this group.

View/Reply Online (#8079) | [hidden email] | [hidden email] | Mute This Topic | New Topic
Mute #cf
Your Subscription | [hidden email] | Unsubscribe [[hidden email]]

_._,_._,_
Reply | Threaded
Open this post in threaded view
|

Re: [cf-dev] cf restart-app-instance and environment variables #cf

Zach Robinson
Hey Preetam

There's not any work to get 'cf restart-app-instance` to update env vars and there is not a way to clone an app.

The current canonical method for updating an app's config, is to perform a blue-green deployment https://docs.cloudfoundry.org/devguide/deploy-apps/blue-green.html

There is also work in flight to implement rolling updates of applications that will allow 'cf restart' to update environment variables for an app based on this proposal https://docs.google.com/document/d/116I_mOWjZcPeIbUvvsh-jAcwpoE_mGPD_SkCel5xXuU/edit#

-Zach
CAPI Project Lead


On Tue, Jun 19, 2018 at 6:54 AM Preetam Palwe <[hidden email]> wrote:
Thanks Dan - It's a reasonable guess!

Following link has some explanation about why it has not worked on Diego - (The documentation of cf restart-app-instance should have this mentioned.)
https://github.com/cloudfoundry/cli/issues/777 

As per above link - Diego team has done some work to propogate env var changes during restart-app-instance. Does anyone here know more about it?
Is there any way to get env vars reflected using cf restart-app-instance or any other means without downtime?

On other hand I also thought about using copy-source but that command require the target app to exist. Can we clone the app?

Appreciate any help on this - Many Thanks !
~Preetam

_._,_._,_

Links:

You receive all messages sent to this group.

View/Reply Online (#8082) | [hidden email] | [hidden email] | Mute This Topic | New Topic
Mute #cf
Your Subscription | [hidden email] | Unsubscribe [[hidden email]]

_._,_._,_
Reply | Threaded
Open this post in threaded view
|

Re: [cf-dev] cf restart-app-instance and environment variables #cf

Preetam Palwe

Thanks Zach for confirmation.

Fine - I think the only way to achieve what I want to achieve is to use B-G deployment. 

Lastly - It will be interesting when rolling update will be supported in cf restart with zero downtime as per your proposal. When will that gets released tentatively?

Thanks!

_._,_._,_

Links:

You receive all messages sent to this group.

View/Reply Online (#8084) | [hidden email] | [hidden email] | Mute This Topic | New Topic
Mute #cf
Your Subscription | [hidden email] | Unsubscribe [[hidden email]]

_._,_._,_