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
Update to the chef_client_scheduled_task resource frequency_modify default functionality #9920
Conversation
… to 1 for frequencies that are not "minute" Signed-off-by: Davin Taddeo <davin@chef.io>
Signed-off-by: Davin Taddeo <davin@chef.io>
…rather than in the code for the action. Signed-off-by: Davin Taddeo <davin@chef.io>
Signed-off-by: Davin Taddeo <davin@chef.io>
…the Linux unit tests... Signed-off-by: Davin Taddeo <davin@chef.io>
Okay, so I fixed all the failing Windows unit tests for this resource, and I also put in unit tests that would validate that the frequency_modifier defaults to 1 unless the frequency is "minute", in which case it defaults to 30. So I feel like this is pretty solid. Going to take this off of [WIP] and hopefully it can get pulled into the next update. I checked off that all new and existing tests passed, mostly because the test failures I've seen are either issues with AppBundler, other unit tests, or a version conflict with chef-cli (for all the ruby 2.6 tests) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thank you! 👍
end | ||
|
||
it "uses daemon_options if set" do | ||
resource.daemon_options ["--foo 1", "--bar 2"] | ||
expect(provider.client_cmd).to eql("C:/opscode/chef/bin/chef-client -L /etc/chef/log/client.log -c /etc/chef/client.rb --foo 1 --bar 2") | ||
expect(provider.client_cmd).to eql("C:/opscode/chef/bin/chef-client -L /etc/chef/log/client.log -c /etc/chef/client.rb --foo 1 --bar 2") | eql("C:/opscode/chef/bin/chef-client -L C:\\chef/log/client.log -c C:\\chef/client.rb --foo 1 --bar 2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long term we need a better solution for cross platform specs, but this will do for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tas50 could we do some regex with it instead?
(I don't know if this is correct ruby regex syntax, I'm probably conflating with *nix syntax)
expect(provider.client_cmd).to match(/opscode\/chef\/bin\/chef-client -L .*chef\/log\/client.log -c .*chef\/client.rb --foo 1 --bar 2/)
It's not exactly pretty, but it's still feels better than the or statement (at least to me).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Historically we've had a lot of really subtle issues building these commands which makes me nervious to use a regex. I think we may just have to per platform set expects here so it's more obvious what we're trying to achieve.
Signed-off-by: Davin Taddeo davin@chef.io
Updates resource so that the frequency_modifier only defaults to 30 if the frequency is "minutes" and will otherwise default to 1
Description
This update adds some logic into the pull request so that the frequency_modifier will be set to 1 if the frequency is set to hours, days, weeks, or months. So that you don't end up scheduling a task to run once every 30 months by accident.
This could probably be more elegantly done, so if someone has improvements to make, I'd be very happy to get the input.
Related Issue
#9918
Types of changes
Checklist: