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

Use server local time for everything, not UTC #69

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dagobah/backend/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def is_object_id(o):

def commit_dagobah(self, dagobah_json):
dagobah_json['_id'] = dagobah_json['dagobah_id']
append = {'save_date': datetime.utcnow()}
append = {'save_date': datetime.now()}
self.dagobah_coll.save(dict(dagobah_json.items() + append.items()))

def delete_dagobah(self, dagobah_id):
Expand All @@ -102,7 +102,7 @@ def delete_dagobah(self, dagobah_id):

def commit_job(self, job_json):
job_json['_id'] = job_json['job_id']
append = {'save_date': datetime.utcnow()}
append = {'save_date': datetime.now()}
self.job_coll.save(dict(job_json.items() + append.items()))

def delete_job(self, job_id):
Expand All @@ -117,7 +117,7 @@ def commit_log(self, log_json):
"""

log_json['_id'] = log_json['log_id']
append = {'save_date': datetime.utcnow()}
append = {'save_date': datetime.now()}

for task_name, values in log_json.get('tasks', {}).items():
for key, size in TRUNCATE_LOG_SIZES_CHAR.iteritems():
Expand Down
8 changes: 4 additions & 4 deletions dagobah/backend/sqlite_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class DagobahLog(Base):
tasks = relationship('DagobahLogTask', backref='log')

def __init__(self):
self.save_date = datetime.utcnow()
self.save_date = datetime.now()

def __repr__(self):
return "<SQLite:DagobahLog (%d)>" % self.id
Expand All @@ -172,7 +172,7 @@ def update_from_dict(self, data):
for key in ['job_id', 'start_time', 'last_retry_time']:
if key in data:
setattr(self, key, data[key])
self.save_date = datetime.utcnow()
self.save_date = datetime.now()


class DagobahLogTask(Base):
Expand All @@ -191,7 +191,7 @@ class DagobahLogTask(Base):

def __init__(self, name):
self.name = name
self.save_date = datetime.utcnow()
self.save_date = datetime.now()

def __repr__(self):
return "<SQLite:DagobahLogTask (%d)>" % self.id
Expand All @@ -210,4 +210,4 @@ def update_from_dict(self, data):
'stderr']:
if key in data:
setattr(self, key, data[key])
self.save_date = datetime.utcnow()
self.save_date = datetime.now()
6 changes: 3 additions & 3 deletions dagobah/core/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, parent_dagobah):
self.parent = parent_dagobah
self.stopped = False

self.last_check = datetime.utcnow()
self.last_check = datetime.now()


def __repr__(self):
Expand All @@ -98,14 +98,14 @@ def stop(self):

def restart(self):
""" Restart the monitoring loop. """
self.last_check = datetime.utcnow()
self.last_check = datetime.now()
self.stopped = False


def run(self):
""" Continually monitors Jobs of the parent Dagobah. """
while not self.stopped:
now = datetime.utcnow()
now = datetime.now()
for job in self.parent.jobs:
if not job.next_run:
continue
Expand Down
21 changes: 10 additions & 11 deletions dagobah/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def _add_job_from_spec(self, job_json, use_job_id=True):
job.add_dependency(from_node, to_node)



def commit(self, cascade=False):
""" Commit this Dagobah instance to the backend.

Expand Down Expand Up @@ -319,7 +318,7 @@ def schedule(self, cron_schedule, base_datetime=None):

else:
if base_datetime is None:
base_datetime = datetime.utcnow()
base_datetime = datetime.now()
self.cron_schedule = cron_schedule
self.cron_iter = croniter(cron_schedule, base_datetime)
self.next_run = self.cron_iter.get_next(datetime)
Expand All @@ -339,14 +338,14 @@ def start(self):
raise DagobahError(reason)

# don't increment if the job was run manually
if self.cron_iter and datetime.utcnow() > self.next_run:
if self.cron_iter and datetime.now() > self.next_run:
self.next_run = self.cron_iter.get_next(datetime)

self.run_log = {'job_id': self.job_id,
'name': self.name,
'parent_id': self.parent.dagobah_id,
'log_id': self.backend.get_new_log_id(),
'start_time': datetime.utcnow(),
'start_time': datetime.now(),
'tasks': {}}
self._set_status('running')

Expand All @@ -372,7 +371,7 @@ def retry(self):
raise DagobahError('no failed tasks to retry')

self._set_status('running')
self.run_log['last_retry_time'] = datetime.utcnow()
self.run_log['last_retry_time'] = datetime.now()

for task_name in failed_task_names:
self._put_task_in_run_log(task_name)
Expand Down Expand Up @@ -488,7 +487,7 @@ def _complete_task(self, task_name, **kwargs):

def _put_task_in_run_log(self, task_name):
""" Initializes the run log task entry for this task. """
data = {'start_time': datetime.utcnow(),
data = {'start_time': datetime.now(),
'command': self.tasks[task_name].command}
self.run_log['tasks'][task_name] = data

Expand Down Expand Up @@ -661,7 +660,7 @@ def start(self):
shell=True,
stdout=self.stdout_file,
stderr=self.stderr_file)
self.started_at = datetime.utcnow()
self.started_at = datetime.now()
self._start_check_timer()


Expand All @@ -672,12 +671,12 @@ def check_complete(self):

# timeout check
if (self.soft_timeout != 0 and
(datetime.utcnow() - self.started_at).seconds >= self.soft_timeout and
(datetime.now() - self.started_at).seconds >= self.soft_timeout and
not self.terminate_sent):
self.terminate()

if (self.hard_timeout != 0 and
(datetime.utcnow() - self.started_at).seconds >= self.hard_timeout and
(datetime.now() - self.started_at).seconds >= self.hard_timeout and
not self.kill_sent):
self.kill()

Expand All @@ -701,7 +700,7 @@ def check_complete(self):
return_code=self.process.returncode,
stdout = self.stdout,
stderr = self.stderr,
complete_time = datetime.utcnow())
complete_time = datetime.now())


def terminate(self):
Expand Down Expand Up @@ -834,7 +833,7 @@ def _tail_temp_file(self, temp_file, num_lines, seek_offset=10000):
def _task_complete(self, **kwargs):
""" Performs cleanup tasks and notifies Job that the Task finished. """
self.parent_job.completion_lock.acquire()
self.completed_at = datetime.utcnow()
self.completed_at = datetime.now()
self.successful = kwargs.get('success', None)
self.parent_job._complete_task(self.name, **kwargs)

Expand Down
4 changes: 2 additions & 2 deletions dagobah/daemon/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def login():
def do_login():
""" Attempt to auth using single login. Rate limited at the site level. """

dt_filter = lambda x: x >= datetime.utcnow() - timedelta(seconds=60)
dt_filter = lambda x: x >= datetime.now() - timedelta(seconds=60)
app.config['AUTH_ATTEMPTS'] = filter(dt_filter, app.config['AUTH_ATTEMPTS'])

if len(app.config['AUTH_ATTEMPTS']) > app.config['AUTH_RATE_LIMIT']:
Expand All @@ -39,7 +39,7 @@ def do_login():
login_user(SingleAuthUser)
return redirect('/')

app.config['AUTH_ATTEMPTS'].append(datetime.utcnow())
app.config['AUTH_ATTEMPTS'].append(datetime.now())
return redirect(url_for('login', alert="Incorrect password."))


Expand Down
2 changes: 1 addition & 1 deletion dagobah/daemon/static/js/job_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ function updateJobNextRun() {
if (job.next_run === null) {
$('#next-run').val('Not scheduled');
} else {
$('#next-run').val(moment.utc(job.next_run).local().format('LLL'));
$('#next-run').val(moment(job.next_run).local().format('LLL'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion dagobah/daemon/static/js/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function applyTransformation(target, value, transformation) {

if (transformation === 'datetime') {
if (value !== null) {
$(target).text(moment.utc(value).local().format('lll'));
$(target).text(moment(value).local().format('lll'));
}
} else if (transformation === 'class') {
if (value !== null) {
Expand Down
5 changes: 2 additions & 3 deletions dagobah/daemon/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@
{% block content %}{% endblock content %}
</div>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="/static/lib/Kickstrap1.3.0/Kickstrap/js/jquery-1.8.2.min.js"><\/script>');</script>
<script id="appList" src="//netdna.getkickstrap.com/1.3/Kickstrap/js/kickstrap.min.js"></script>
<script src="/static/lib/Kickstrap1.3.2/Kickstrap/js/jquery-1.8.3.min.js"></script>
<script id="appList" src="/static/lib/Kickstrap1.3.2/Kickstrap/js/kickstrap.js"></script>
<script>window.consoleLog || document.write('<script id="appList" src="/static/lib/Kickstrap1.3.2/Kickstrap/js/kickstrap.min.js"><\/script>')</script>
<script src="/static/lib/d3.v3.min.js"></script>
<script src="/static/lib/handlebars.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion dagobah/daemon/templates/job_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ <h3>Job Scheduling</h3>
</div>

<div class='control-group'>
<label class='control-label' for='next-run'>Next Scheduled Run<br />(local time)</label>
<label class='control-label' for='next-run'>Next Scheduled Run<br />(server time)</label>
<div class='controls'>
<input id='next-run' type='text' class='input' disabled></input>
</div>
Expand Down
2 changes: 1 addition & 1 deletion dagobah/email/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ def _merge_templates(self, html, css):
def _format_date(self, in_date):
if (not in_date) or (not isinstance(in_date, datetime)):
return in_date
return in_date.strftime('%Y-%m-%d %H:%M:%S UTC')
return in_date.strftime('%Y-%m-%d %H:%M:%S')
2 changes: 1 addition & 1 deletion dagobah/email/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ def _job_to_text(self, job):
def _format_date(self, in_date):
if (not in_date) or (not isinstance(in_date, datetime)):
return in_date
return in_date.strftime('%Y-%m-%d %H:%M:%S UTC')
return in_date.strftime('%Y-%m-%d %H:%M:%S')