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

Proposal: Support concurrency groups #41

Open
irvinlim opened this issue Apr 10, 2022 · 0 comments
Open

Proposal: Support concurrency groups #41

irvinlim opened this issue Apr 10, 2022 · 0 comments
Labels
component/execution Issues or PRs related exclusively to the Execution component (Job, JobConfig) kind/proposal Proposal for new ideas or features

Comments

@irvinlim
Copy link
Member

irvinlim commented Apr 10, 2022

Motivation

Currently, concurrency policies are only supported only on a single JobConfig-level. There could be two JobConfigs that cannot run at the same time, and we want to provide some concurrency control on a controller-level to help with this.

Proposal

It should be simple to extend concurrency policy to support named concurrency groups, such that:

  1. The default concurrency group is empty, which means to group by JobConfig (predominant behavior).
  2. If so desired, users can specify an optional concurrency.group. This group name is namespaced, and two identical names in different namespaces should not contribute to the same concurrency count.
  3. Need to enforce concurrency policies for this group in multiple places:
    • ActiveJobStore: Need to use group instead of JobConfig name.
    • JobQueueController: Probably need to rewrite to update PerConfigReconciler to PerGroupReconciler.
    • JobValidatingWebhook: Need to index all Jobs by group, instead of looking up JobConfig's status for enforcement.
    • JobConfigController: Need to handle new JobConfigStatus.
  4. Concurrency group name can support context variables for the jobconfig context.
    • Example: The default concurrency group would be ${jobconfig.uid}, which evaluates to the JobConfig's UID.

API Design

JobConfig

  1. Update ConcurrencySpec like as follows:

    apiVersion: execution.furiko.io/v1alpha1
    kind: JobConfig
    metadata:
      name: my-job-config
      namespace: my-namespace
    spec:
      concurrency:
        policy: Forbid
        group: my-custom-group
  2. JobConfigStatus will have to be updated as well:

    apiVersion: execution.furiko.io/v1alpha1
    kind: JobConfig
    metadata:
      name: my-job-config
      namespace: my-namespace
    status:
      state: JobQueued  # Refers to jobs for the JobConfig, not the concurrency group.
      jobs:  # Contains references for JobConfig's actual children jobs.
        queued: 2
        queuedJobs: 
          - namespace: my-namespace
             name: my-job-config.1
          - namespace: my-namespace
             name: my-job-config.2
      concurrencyGroup:  # Contains references for all Jobs in the JobConfig's concurrency group.
        name: my-custom-group  # Defaults to JobConfig name
        queued: 4
        queuedJobs: 
          - namespace: my-namespace
             name: my-job-config.1
          - namespace: my-namespace
             name: my-job-config.2
          - namespace: my-namespace
             name: another-job-config.1
          - namespace: my-namespace
             name: another-job-config.1

Job

  1. Update StartPolicySpec as follows:

    apiVersion: execution.furiko.io/v1alpha1
    kind: Job
    metadata:
      name: my-job
      namespace: my-namespace
    spec:
      startPolicy:
        concurrencyPolicy: Forbid
        concurrencyGroup: my-custom-group
  2. It should be possible for the JobStatus to show a more detailed message about the concurrency group:

    apiVersion: execution.furiko.io/v1alpha1
    kind: Job
    metadata:
      name: my-job
      namespace: my-namespace
    status:
      condition:
        finished:
          result: AdmissionError
          reason: AdmissionError
          message: Cannot start new Job, concurrency group "my-custom-group" has 2 active Jobs but concurrency policy is Forbid

References

@irvinlim irvinlim added kind/proposal Proposal for new ideas or features component/execution Issues or PRs related exclusively to the Execution component (Job, JobConfig) labels Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/execution Issues or PRs related exclusively to the Execution component (Job, JobConfig) kind/proposal Proposal for new ideas or features
Projects
None yet
Development

No branches or pull requests

1 participant