Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CF set-env without restage

Let's say I would have one app with two instances. I would change an environment variable (cf set-env) and not perform a cf restage. Eventually one of the two instances would crash and restart. Would it take the new environment variable or the old?

like image 571
El Gohr Avatar asked Jul 30 '26 22:07

El Gohr


2 Answers

In general if an instance crashes (say the app runs out of memory) and is restarted by Diego (the runtime that's actually running the container instances), the restarted instance will still have the environment variables it was originally "desired" (created) with.

If you explicitly cf restart or cf stop && cf start the app it will pickup the new environment variables which out needing to be restaged.

As user152468 said above, if the environment variables are used during the staging process you will need to cf restage the app for them to functionally take effect.

Edge Case Scenario

If the Diego runtime goes away/loses data for some catastrophic reason, the Cloud Controller will re-sync it and recreate the apps that are meant to be running. In this event the behavior is similar to a cf restart and the app will pick up the new environment variables. This is definitely uncommon, but would also count as a "crash" scenario.

like image 110
tcdowney Avatar answered Aug 01 '26 19:08

tcdowney


EDIT:

After reading tcdowney's answer below, I tried it out. And tcdowney is right. When the app is restarted due to a crash, it will not pick up the new environment variable, so both of your app instances will share the same environment.

In contrast when you do a cf restart my-app then it will pick it up. Sorry for the confusion!

========================================================

It would take the new value of the environment variable. See here: https://docs.run.pivotal.io/devguide/deploy-apps/start-restart-restage.html

Only if the variable is relevant for the buildpack, you will need to restage.

like image 39
user152468 Avatar answered Aug 01 '26 18:08

user152468



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!