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

Ignore scheduling if DESTALINATOR_RUN_ONCE is used #156

Open
dshackith opened this issue Oct 11, 2017 · 11 comments
Open

Ignore scheduling if DESTALINATOR_RUN_ONCE is used #156

dshackith opened this issue Oct 11, 2017 · 11 comments
Labels

Comments

@dshackith
Copy link

Scheduler still cares about local timezone on container/server and will fail if not set, even if DESTALINATOR_RUN_ONCE is set. All scheduling should be ignored (and code not run) if DESTALINATOR_RUN_ONCE is set.

This is relevant when running Destalinator as a Kubernetes ChronJob that handles the scheduling.

@kmarekspartz
Copy link
Contributor

Relevant lines: https://github.com/randsleadershipslack/destalinator/blob/master/scheduler.py#L47

My guess is you updated settings.yml to remove schedule_hour?

@dshackith
Copy link
Author

I have DESTALINATOR_SCHEDULE_HOUR=5 set in the environment, and configuration.yaml still contains schedule_hour: 4. The code does not seem to allow for no schedule, if I am using scheduler.py, but that is the only place where RUN_ONCE is detected.

@kmarekspartz
Copy link
Contributor

Interesting... what is the error message you're getting?

@dshackith
Copy link
Author

Traceback (most recent call last):
File "scheduler.py", line 25, in
@sched.scheduled_job("cron", **schedule_kwargs)
File "/usr/local/lib/python3.6/site-packages/apscheduler/schedulers/base.py", line 371, in inner
next_run_time, jobstore, executor, True, **trigger_args)
File "/usr/local/lib/python3.6/site-packages/apscheduler/schedulers/base.py", line 330, in add_job
'trigger': self._create_trigger(trigger, trigger_args),
File "/usr/local/lib/python3.6/site-packages/apscheduler/schedulers/base.py", line 782, in _create_trigger
return self._create_plugin_instance('trigger', trigger, trigger_args)
File "/usr/local/lib/python3.6/site-packages/apscheduler/schedulers/base.py", line 768, in _create_plugin_instance
return plugin_cls(**constructor_kwargs)
File "/usr/local/lib/python3.6/site-packages/apscheduler/triggers/cron/init.py", line 48, in init
self.timezone = astimezone(timezone)
File "/usr/local/lib/python3.6/site-packages/apscheduler/util.py", line 80, in astimezone
raise ValueError('Unable to determine the name of the local timezone -- use an explicit timezone instead')
ValueError: Unable to determine the name of the local timezone -- use an explicit timezone instead

@kmarekspartz
Copy link
Contributor

Very weird. This is with something like docker run -it -e DESTALINATOR_RUN_ONCE=true destalinator ?

@dshackith
Copy link
Author

Exactly. But, there are a couple other differences:

  1. I am using python:alpine3.6 for the base
  2. I have added tini for zombie reaping (see https://github.com/krallin/tini)

@kmarekspartz
Copy link
Contributor

Looks related to agronholm/apscheduler#87. I don't think this bug has anything to do with RUN_ONCE, but we could skip the scheduler all together and avoid this with RUN_ONCE.

@dshackith
Copy link
Author

Also fixed by setting /etc/timezone in Dockerfile: https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes

@dshackith
Copy link
Author

But I still don't think the scheduler should care about timezone if no scheduling is being done.

@kmarekspartz
Copy link
Contributor

Agreed. Sending a MR shortly.

@kmarekspartz
Copy link
Contributor

MR: #157

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

No branches or pull requests

2 participants