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

Allow enqueuer to enqueue multiple jobs with the same instance #4218

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

johha
Copy link
Contributor

@johha johha commented Feb 14, 2025

Refactor enqueuer so that it can enqueue multiple jobs with the same instance.
This will allow in the future to e.g. pass down an enqueuer instance to ensure consistent priorities.

Instead of providing a job in initialize it will be provided in enqueue(job), enqueue_pollable(job), or run_inline(job):

class Enqueuer
      def initialize(opts={})
        @opts = opts
        @timeout_calculator = JobTimeoutCalculator.new(VCAP::CloudController::Config.config)
        @priority_overwriter = JobPriorityOverwriter.new(VCAP::CloudController::Config.config)
        load_delayed_job_plugins
      end

      def enqueue(job)
        enqueue_job(job)
      end

      def enqueue_pollable(job, existing_guid: nil)
        wrapped_job = PollableJobWrapper.new(job, existing_guid:)

        wrapped_job = yield wrapped_job if block_given?

        delayed_job = enqueue_job(wrapped_job)
        PollableJobModel.find_by_delayed_job(delayed_job)
      end

      def run_inline(job)
        run_immediately do
          Delayed::Job.enqueue(TimeoutJob.new(job, job_timeout(job)), @opts)
        end
      end

  • I have reviewed the contributing guide

  • I have viewed, signed, and submitted the Contributor License Agreement

  • I have made this pull request to the main branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

@johha johha force-pushed the enqueuer-refactor branch 6 times, most recently from aceed81 to 10874e3 Compare February 14, 2025 15:33
@johha johha force-pushed the enqueuer-refactor branch from 10874e3 to 5ddd571 Compare February 17, 2025 07:34
@johha johha marked this pull request as ready for review February 17, 2025 08:21
@kathap
Copy link
Contributor

kathap commented Feb 17, 2025

Needs this line in service_instances_spec.rb to be changed to the new design?
allow_any_instance_of(VCAP::CloudController::Jobs::Enqueuer).to receive(:enqueue_pollable).and_raise(Sequel::DatabaseDisconnectError)
no, no need for it :)

@johha johha merged commit 9cf8c45 into main Feb 19, 2025
8 checks passed
@johha johha deleted the enqueuer-refactor branch February 19, 2025 10:28
ari-wg-gitbot added a commit to cloudfoundry/capi-release that referenced this pull request Feb 19, 2025
Changes in cloud_controller_ng:

- Allow enqueuer to enqueue multiple jobs with the same instance
    PR: cloudfoundry/cloud_controller_ng#4218
    Author: Johannes Haass <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants