0

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.

  • 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 Apr 04 '18 at 18:54
  • 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 Apr 04 '18 at 18:56

1 Answers1

0

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.

Sabby Anandan
  • 5,636
  • 2
  • 12
  • 21
  • Hi Sabby, thank you for replying. Yes since we currently have over 30 batch jobs (and growing), we need a global setting at the dataflow level to be able to define JAVA_OPTS for every task deployed through it. Additionally, some of our jobs are memory intensive, so it would also be very useful to be able to specify JAVA_OPTS (like heap size) for individual tasks in dataflow. – lframirez89 Apr 05 '18 at 16:13
  • We are working on it; please track the issue. I will leave an update once we have a fix for it. – Sabby Anandan Apr 05 '18 at 20:08
  • Thank you for opening an issue, I will keep track of it. – lframirez89 Apr 05 '18 at 20:40
  • Hi. Please see my comment on: [spring-cloud/spring-cloud-deployer-cloudfoundry#243#issuecomment-379273196](https://github.com/spring-cloud/spring-cloud-deployer-cloudfoundry/pull/243#issuecomment-379273196). You can set that individually or globally in SCDF, so all the Tasks would inherit it. Please try the PR and let us know if you have any questions or other feedback. :) – Sabby Anandan Apr 06 '18 at 14:39