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

Sanitize empty slices/maps in Jobs #1434

Merged
merged 3 commits into from
Jul 21, 2016
Merged

Sanitize empty slices/maps in Jobs #1434

merged 3 commits into from
Jul 21, 2016

Conversation

dadgar
Copy link
Contributor

@dadgar dadgar commented Jul 18, 2016

This PR sanitizes empty slices/maps in jobs to be treated as nil internally. This avoids the problem of a user submitting a job once with env: {} and once with env: null and having a destructive update take place.

func (n *NetworkResource) InitFields() {
// Ensure that an empty and nil slices are treated the same to avoid scheduling
// problems since we use reflect DeepEquals.
if len(n.ReservedPorts) == 0 && n.ReservedPorts != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

len(n.ReserverPorts) == 0 should suffice since len of empty and nil slice is 0

@armon
Copy link
Member

armon commented Jul 19, 2016

LGTM, but I don't see a reason to remove the call to Init after 0.5, may as well leave it as a sanity guard. I would also prefer Canonicalize to Init since that is what we are doing

@dadgar dadgar merged commit 33df984 into master Jul 21, 2016
@dadgar dadgar deleted the b-nil-empty branch July 21, 2016 00:14
@github-actions
Copy link

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 21, 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