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

Update to the chef_client_scheduled_task resource frequency_modify default functionality #9920

Merged
merged 7 commits into from Jun 5, 2020
Merged

Conversation

chef-davin
Copy link
Contributor

@chef-davin chef-davin commented May 27, 2020

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

… to 1 for frequencies that are not "minute"

Signed-off-by: Davin Taddeo <davin@chef.io>
@chef-davin chef-davin requested review from a team as code owners May 27, 2020 16:57
…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>
@chef-davin
Copy link
Contributor Author

chef-davin commented Jun 3, 2020

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)

@chef-davin chef-davin changed the title [WIP] Update to the chef_client_scheduled_task resource frequency_modify default functionality Update to the chef_client_scheduled_task resource frequency_modify default functionality Jun 3, 2020
Copy link
Contributor

@phiggins phiggins left a 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")
Copy link
Contributor

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.

Copy link
Contributor Author

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).

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants