Skip to content

Conversation

@maokomioko
Copy link

This originated, because we needed to control these options:

   concurrencyPolicy: Forbid
   successfulJobsHistoryLimit: 1
   failedJobsHistoryLimit: 3

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

source "https://rubygems.org"

gem "kubeclient", "4.0.0"
gem "kubeclient", "4.12.0"
Copy link
Author

Choose a reason for hiding this comment

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

Copy link

@sdhull sdhull left a 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
Copy link

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"
Copy link

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 }
Copy link

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)
Copy link

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?

Copy link
Member

@jeremywadsack jeremywadsack left a 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)
Copy link
Member

@jeremywadsack jeremywadsack Sep 28, 2025

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 = {})
Copy link
Member

@jeremywadsack jeremywadsack Sep 28, 2025

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",
Copy link
Member

@jeremywadsack jeremywadsack Sep 28, 2025

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)
Copy link
Member

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.

Comment on lines +6 to +8
# Define Struct classes to replace OpenStruct
KubeConfigContext = Struct.new(:api_endpoint, :api_version, :namespace, :auth_options, :ssl_options)
KubeConfig = Struct.new(:context)
Copy link
Member

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

Comment on lines +18 to +19
EnforcedHashRocketStyle: key
EnforcedColonStyle: key
Copy link
Member

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.

@maokomioko
Copy link
Author

Hi guys,
Sure - let me get back to you with revised version. I'll keep changes to the minimum, removing the flavors.

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.

3 participants