0
votes

I have a Spring Batch/Spring Cloud Task which I deploy to PCF using Spring Cloud Dataflow. I am trying to define the timezone (JAVA_OPTS:'-Duser.timezone=America/New_York') somewhere in Dataflow so that any Task deployed to it, inherits the timezone.

So far I was able to define it as a user-provided env variable for Dataflow in PCF, and I see Dataflow logs show the correct timezone. However, when I deploy my Task using dataflow, the timezone in the Task logs remains at the default of UTC.

As mentioned here: CloudFoundry Timezone, I can define it the same way (as a user provided env var) directly on the task, and then the Task takes the correct timezone. But since I have over 30 of these Tasks, I need a way to define it at the Dataflow level, and have all the Tasks inherit it.

I've also tried defining it at the Task Definition level with no luck.

How can I define the -Duser.timezone property at the Dataflow level for all Tasks to inherit? Or if not possible, where is the correct place to define it externally?

Thanks.

1
What is the need to define the default timezone? It's generally recommended to use UTC for everything, except where times are being directly displayed to end users, like a web page or report. Then you'd still use UTC time, but you'd take the UTC time and convert it to the user's respective time as it's being displayed to the user (i.e. never store it in anything but UTC). - Daniel Mikusa
For what it's worth, you can use a Cloud Foundry running environment variable to apply an environment variable to all applications. You could do this for JAVA_OPTS to set the timezone. I don't recommend it though. It requires operator/admin access to the platform. It'll apply to all apps on the platform, which is probably not what you want, plus if an app sets JAVA_OPTS for something else they could override the running environment setting and miss inheriting this value. - Daniel Mikusa

1 Answers

0
votes

There's no direct mechanism to "globally" override and influence JAVA_OPTS at each stream/task app while orchestrating it via SCDF on PCF. Tasks accept command-line-args, but it still cannot amend to JAVA_OPTS.

I've created spring-cloud/spring-cloud-deployer-cloudfoundry#242 to track this requirement - feel free to share any other thoughts.

Apart from the foundation level setting, you could also supplement JAVA_OPTS in your offline buildpack. Again, it'd be applied to all the Apps when using that buildpack.