Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added functionality to dynamically determine date relative to current date #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

linjmeyer
Copy link

If DATE value is not set or passed in, DATE_MINUS_DAYS can be a valid
integer which is subtracted from the current day to determine which
index should be used for creating dependency links.

Signed-off-by: Lin Meyer lin@linmeyer.net

Which problem is this PR solving?

  • It is not possible to set the index date dynamically at runtime when using a Kubernetes CronJob

Short description of the changes

  • Optional environment variable DATE_MINUS_DAYS can be set, which is subtracted from the current date. For example, DATE_MINUS_DAYS=5; Then at runtime: date = today - 5days;

If DATE value is not set or passed in, DATE_MINUS_DAYS can be a valid
integer which is subtracted from the current day to determine which
index should be used for creating dependency links.

Signed-off-by: Lin Meyer <lin@linmeyer.net>
@linjmeyer
Copy link
Author

This partially resolves Jaeger Operator Issue #1068. I was unable to solve this completely in the Jaeger Operator as you cannot set an environment variable like Date: $(echo date -u -d '1 day ago' +%F) in Kubernetes. This will cause a runtime exception as Java gets the string value $(echo date -u -d '1 day ago' +%F) rather than the result of the subscript. I also tried Kubernetes args to pass in the date but this overrides the Dockerfile's entrypoint and cmds.

If this is merged, the environment variable can be added to the Jaeger Operator. If I need to open an Issue in this repo as well just let me know!

@pavolloffay
Copy link
Member

@linjmeyer thanks for putting the PR together!

It's unfortunate that the env vars are not evaluated in k8s. However this post https://stackoverflow.com/a/58192064/4158442 shows that it should work?

@linjmeyer
Copy link
Author

Hi @pavolloffay, the post is a bit misleading. I tried in the spark dependency job and get:

jaeger-production-spark-dependencies Exception in thread "main" java.time.format.DateTimeParseException: Text '$(date -u -d '1 day ago' +%F)' could not be parsed at index 0                                                               
jaeger-production-spark-dependencies     at java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:1949)                                                                                                                 
jaeger-production-spark-dependencies     at java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1851)                                                                                                                          
jaeger-production-spark-dependencies     at java.time.LocalDate.parse(LocalDate.java:400)                                                                                                                                                  
jaeger-production-spark-dependencies     at java.time.LocalDate.parse(LocalDate.java:385)                                                                                                                                                  
jaeger-production-spark-dependencies     at io.jaegertracing.spark.dependencies.DependenciesSparkJob.parseZonedDateTime(DependenciesSparkJob.java:72)                                                                                      
jaeger-production-spark-dependencies     at io.jaegertracing.spark.dependencies.DependenciesSparkJob.main(DependenciesSparkJob.java:37)

If I override the args to echo $DATE I get:

spark-dependency-lin-rxft9:jaeger-production-spark-dependencies $(date -u -d '1 day ago' +%F)

It seems what makes the env variables work in the post is that the variable is being called in a subshell, like echo $(DATE) but since this repo is a Java app reading the env var that trick isn't possible. An alternative option could be something like DATE=$(DATE) in entrypoint.sh though.

@pavolloffay
Copy link
Member

An alternative option could be something like DATE=$(DATE) in entrypoint.sh though.

Could we try this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants