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

Allow specification of timezones in Periodic Jobs #2321

Merged
merged 3 commits into from
Feb 17, 2017
Merged

Allow specification of timezones in Periodic Jobs #2321

merged 3 commits into from
Feb 17, 2017

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Feb 15, 2017

This PR allows specification of time zones in periodic jobs.

Fixes #2276

// Load the location
l, err := time.LoadLocation(p.TimeZone)
if err != nil {
panic(fmt.Sprintf("Bad location %q: %v", p.TimeZone, err))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why panic? This panic should at least be mentioned in a doc comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another place where documenting the panic seems relevant

func (j *Job) Canonicalize() {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@briansorahan The panic acts as an assertion. If it is hit there is a bug in implementation. The reason it is okay is Validate should check for a valid timezone: https://github.com/hashicorp/nomad/pull/2321/files/f4cc46948f1893c3b4afc090c76f41abecefeb24#diff-396d9428285e4245041a3d0b15546d5dR1581

So the system should never even canonicalize an invalid spec.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying that Validate guards against an invalid timezone when a periodic job is created with the CLI and HTTP?
If so then maybe my concern goes away.
I'm not very familiar with the nomad source code, but I get worried when I see a panic in code that could be part of a long-running process.

@nugend
Copy link

nugend commented Feb 16, 2017

Thanks! The capability looks like it will do just what I was hoping for. Can't comment on implementation details though.

@dadgar dadgar merged commit fb4b6bd into master Feb 17, 2017
@dadgar dadgar deleted the f-timezone branch February 17, 2017 19:32
@nugend
Copy link

nugend commented Feb 17, 2017

Shouldn't this log something if it's defaulting to UTC? I don't know exactly how a bad location would get in there, and I think defaulting is sensible, but that's gonna be a heck of a confusing bug if it ever does happen.

@github-actions
Copy link

github-actions bot commented Apr 5, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants