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 sysctl_param resource from the sysctl cookbook #7022

Merged
merged 5 commits into from
Mar 22, 2018
Merged

Add sysctl_param resource from the sysctl cookbook #7022

merged 5 commits into from
Mar 22, 2018

Conversation

tas50
Copy link
Contributor

@tas50 tas50 commented Mar 21, 2018

Copied from the cookbook with modifications made there

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

Copied from the cookbook with modifications made there

Signed-off-by: Tim Smith <[email protected]>
@tas50 tas50 requested a review from a team March 21, 2018 18:54
@tas50 tas50 changed the title Add sysctl_param resource from the sysctl cookbook WIP: Add sysctl_param resource from the sysctl cookbook Mar 21, 2018
value get_sysctl_value(key)
if node.normal["sysctl"]["backup"][key].empty?
node.normal["sysctl"]["backup"][key] = value
end
Copy link
Contributor

Choose a reason for hiding this comment

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

i still think this is the weirdest feature ever.

this key could be saved on the node for three years and then :removed, and who the hell knows what is going to happen...

action :remove as a concept feels like "you're doing config management wrong".

Copy link
Contributor

Choose a reason for hiding this comment

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

I think action :remove is fine to clean up the underlying files but I too am unsure why we are storing this stuff into node attributes. What problem does this solve?

class Resource
class SysctlParam < Chef::Resource
resource_name :sysctl_param
provides :sysctl_param
Copy link
Contributor

Choose a reason for hiding this comment

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

I sort of think this should be:

resource_name :sysctl
provides :sysctl
provides :sysctl_param  # back compat with the cookbook

Copy link
Contributor

Choose a reason for hiding this comment

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

Also even if we don't want to have two names, still don't need both resource_name and provides for the same sym.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed a rename commit


def get_sysctl_value(key)
o = shell_out("sysctl -n -e #{key}")
raise "Unknown sysctl key!" if o.error!
Copy link
Contributor

Choose a reason for hiding this comment

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

Should include the key name in the error message so it is clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

value get_sysctl_value(key)
if node.normal["sysctl"]["backup"][key].empty?
node.normal["sysctl"]["backup"][key] = value
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I think action :remove is fine to clean up the underlying files but I too am unsure why we are storing this stuff into node attributes. What problem does this solve?

class Resource
class SysctlParam < Chef::Resource
resource_name :sysctl_param
provides :sysctl_param
Copy link
Contributor

Choose a reason for hiding this comment

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

Also even if we don't want to have two names, still don't need both resource_name and provides for the same sym.

end

execute "sysctl -p" do
command "sysctl -p"
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundant command and action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

tas50 added 2 commits March 21, 2018 13:45
Signed-off-by: Tim Smith <[email protected]>
end

execute "sysctl -p" do
command "sysctl -p"
Copy link
Contributor

Choose a reason for hiding this comment

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

Still redundant. Doesn't hurt anything but easy to DRY.


def get_sysctl_value(key)
o = shell_out("sysctl -n -e #{key}")
raise "Unknown sysctl key #{key}!" if o.error!
Copy link
Collaborator

Choose a reason for hiding this comment

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

error! raises. so this is ... a bit meaningless :) did you mean error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh nice that never worked in the cookbook either. I'll get that fixed


load_current_value do
value get_sysctl_value(key)
if node.normal["sysctl"]["backup"][key].empty?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't we discourage normal ?

Still needs a bit of testing to see if there's a better way to do the
reload, but here goes nothing

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.

Other than Phil's suggestion this sounds good to me :)

@tas50 tas50 changed the title WIP: Add sysctl_param resource from the sysctl cookbook Add sysctl_param resource from the sysctl cookbook Mar 22, 2018
@tas50 tas50 merged commit 90fee1f into master Mar 22, 2018
@tas50 tas50 deleted the sysctl branch March 22, 2018 17:41
@lock
Copy link

lock bot commented May 21, 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 21, 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.

4 participants