-
Notifications
You must be signed in to change notification settings - Fork 5
Feat: allow passing cronjob specific settings #12
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
base: master
Are you sure you want to change the base?
Conversation
| source "https://rubygems.org" | ||
|
|
||
| gem "kubeclient", "4.0.0" | ||
| gem "kubeclient", "4.12.0" |
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.
Bumped to latest due to vulnerability note:
https://github.com/ManageIQ/kubeclient?tab=readme-ov-file#vulnerability-in--v492
sdhull
left a comment
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.
Looking at this PR, it seems like there are a ton of aesthetic/rubocop-y type changes that are insubstantial as far as the primary aim of the PR goes.
PRs are much easier to review and discuss if you separate aesthetic changes into a different PR that has no functional changes. That way contributors can discuss aesthetics/style without holding up valuable functional changes, which I think this PR probably has.
Also, I'd love to see new test cases that prove the new functionality that was added works as intended
|
|
||
| gemspec | ||
|
|
||
| group :development, :test do |
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.
Is there some reason you moved these out of the gemspec? I seem to recall that keeping dev dependencies in the gemspec is more standard / better practice
| spec.homepage = "https://github.com/keylimetoolbox/cron-kubernetes" | ||
| spec.license = "MIT" | ||
| spec.required_ruby_version = ">= 3.2" | ||
| spec.required_ruby_version = "~> 3.4" |
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.
Unless it's absolutely required to accomplish the goals in this PR, I'd recommend separating out ruby version changes
| # Requires supporting ruby files with custom matchers and macros, etc, | ||
| # in spec/support/ and its subdirectories. | ||
| Dir[File.expand_path("support/**/*.rb", __dir__)].sort.each { |f| require f } | ||
| Dir[File.expand_path("support/**/*.rb", __dir__)].each { |f| require f } |
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.
Sorting files in the support directory is fairly standard practice and can help manage order dependencies in these files. Why was this removed?
| context "when RAILS_ENV is defined" do | ||
| before do | ||
| @rails_env = ENV["RAILS_ENV"] | ||
| @rails_env = ENV.fetch("RAILS_ENV", nil) |
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.
Changing from bracket to fetch("KEY", nil) seems unnecessary and additional characters for no additional benefit. What's the reasoning here?
jeremywadsack
left a comment
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.
@maokomioko Thanks for the submission. Sorry for the delay in responding.
Some comments on the code below.
Overall, I'm open to adding more configurability for the cron job. I understand the need for that. There seems to be a number of changes here that are out of scope of that update as reflected in my comments and sdhull's.
Please add test cases that exercise the cron_job_settings code and confirm it works as expected.
As you have added a new parameter to the public interface for the gem, please update the README needs to be update to reflect that and include examples for why you would use that.
|
|
||
| def google_application_default_credentials | ||
| return unless defined?(Google) && defined?(Google::Auth) | ||
| return unless defined?(Google::Auth) |
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.
With your change, it seems this could fail if you don't have Google defined in your environment. I'm not sure why you altered this.
| @identifier = identifier | ||
| attr_accessor :schedule, :command, :job_manifest, :name, :identifier, :cron_job_settings | ||
|
|
||
| def initialize(options = {}) |
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.
I realize that Rubocop doesn't like lots of options on method names, but this makes the method a lot less self-documenting.
| def build_cron_job_spec | ||
| default_spec = { | ||
| "schedule" => schedule, | ||
| "concurrencyPolicy" => "Forbid", |
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.
Hard-coding this into the spec seems is a bad idea, especially as the default value is "allow". This change would lead to unexpected behavior for those expecting the default behavior out of the box.
|
|
||
| def rails_env | ||
| ENV["RAILS_ENV"] | ||
| ENV.fetch("RAILS_ENV", nil) |
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.
I don't understand how this behavior is different than the code that was there.
| # Define Struct classes to replace OpenStruct | ||
| KubeConfigContext = Struct.new(:api_endpoint, :api_version, :namespace, :auth_options, :ssl_options) | ||
| KubeConfig = Struct.new(:context) |
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.
Thank you for making this update
| EnforcedHashRocketStyle: key | ||
| EnforcedColonStyle: key |
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.
I personally find table layout more readable than key. In any case, I'm not sure why you are suggesting a change to the style of this gem.
|
Hi guys, |
This originated, because we needed to control these options:
Specifically the concurrency policy to avoid export or import jobs to be run in parallel (when new jobs kicks in before the old one is finished).