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

Add swap_file resource from the swap cookbook #6990

Merged
merged 3 commits into from
Mar 24, 2018
Merged

Add swap_file resource from the swap cookbook #6990

merged 3 commits into from
Mar 24, 2018

Conversation

tas50
Copy link
Contributor

@tas50 tas50 commented Mar 15, 2018

This is copied as-is from the swap cookbook and included here with permission of Vargo

Signed-off-by: Tim Smith [email protected]

@tas50 tas50 requested a review from a team March 15, 2018 18:41
@tas50 tas50 changed the title Add swap_file resource form the swap cookbook WIP: Add swap_file resource form the swap cookbook (blocked on sysctl) Mar 16, 2018
@tas50 tas50 changed the title WIP: Add swap_file resource form the swap cookbook (blocked on sysctl) WIP: Add swap_file resource from the swap cookbook (blocked on sysctl) Mar 17, 2018
@tas50 tas50 changed the title WIP: Add swap_file resource from the swap cookbook (blocked on sysctl) Add swap_file resource from the swap cookbook Mar 22, 2018
Copy link
Contributor

@coderanger coderanger left a comment

Choose a reason for hiding this comment

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

Seems good overall, though I think if you change the size on an existing file, this code won't detect that as a change?

if new_resource.swappiness
include_recipe "sysctl::default"

sysctl_param "vm.swappiness" do
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use sysctl as the new primary name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and the include is gone too

do_create(dd_command)
end
end
if new_resource.swappiness
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm mixed on this feature. Notably if you have more than one swap, they would compete? But that's pretty rare.

Copy link
Contributor

Choose a reason for hiding this comment

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

Separation of concerns suggests that this option shouldn't be here. And it creates a really weird API where this is just a facade over calling the sysctl resource to set the swappiness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two fold answer:

First part: It's an optional feature and it's off by default. It makes a lot of sense to manage your swapiness when you configure your swap file. For users that want to just get swap going they can set a value and it'll just work. If they don't turn it on, then they won't get it, which seems to follow "the chef way".

Second part: I think the scenario where we have multiple swap files and the users specify different swapiness values it super edge case. You could have multiple swap files and even set the swapiness on both without issue. You could specify it on one and it would work. You just can't have 2 different values and I think it should be pretty clear to anyone who would want swapiness set why that isn't possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3rd part: Users of the cookbook are utilizing this property so removing it breaks that API in a sad way

compatible_filesystems.any? { |fs| result.include? fs }
end

# we can remove this when we only support Chef 13
Copy link
Contributor

Choose a reason for hiding this comment

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

you only need to support Chef 14 now

tas50 added 3 commits March 23, 2018 12:24
Copied as-is from the cookbook

Signed-off-by: Tim Smith <[email protected]>
Signed-off-by: Tim Smith <[email protected]>
Copy link
Contributor

@coderanger coderanger left a comment

Choose a reason for hiding this comment

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

With the include_recipe gone, I'm less worried about the swappiness feature, still don't think people should use it, but it harms very little and shouldn't cause us future heartache :D

@tas50 tas50 merged commit bec4db4 into master Mar 24, 2018
@tas50
Copy link
Contributor Author

tas50 commented Mar 24, 2018

Yep the recipe was a leftover from the pre-1.0 cookbook that was very much attribute driven still.

@tas50 tas50 deleted the swap branch March 24, 2018 04:27
@lock
Copy link

lock bot commented May 23, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 23, 2018
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.

3 participants