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

ScaledJob with Cron trigger does not scale down on completion #1893

Closed
jordenk opened this issue Jun 15, 2021 · 8 comments
Closed

ScaledJob with Cron trigger does not scale down on completion #1893

jordenk opened this issue Jun 15, 2021 · 8 comments
Labels
bug Something isn't working help wanted Looking for support from community stale All issues that are marked as stale due to inactivity

Comments

@jordenk
Copy link

jordenk commented Jun 15, 2021

Report

ScaledJob with cron trigger does not limit itself to a single, successful job execution.

I think the completions in steps to reproduce should limit this to a single job execution.

Expected Behavior

The scaledJob executes on a cron trigger. After the triggered job completes n times, where n is completions: n, the job should no longer be triggered.

Actual Behavior

The scaledJob executes on a cron trigger. Jobs are triggered every 30 seconds until the scaledJob ends.

spec.triggers[0].metadata.end

In this case, the job has successfully completed. completions: 1 is exceeded.

Steps to Reproduce the Problem

  1. Deploy a scaledjob of the form:
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
  name: scaled-job-name
  namespace: example
spec:
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 3
  maxReplicaCount: 1
  triggers:
  - type: cron
    metadata:
      timezone: America/New_York
      start: 54 13 * * *
      end: 59 13 * * *
      desiredReplicas: "1"
  jobTargetRef:
    parallelism: 1
    completions: 1
    backoffLimit: 3
    activeDeadlineSeconds: 3600
    template:
      spec:
        restartPolicy: OnFailure
        serviceAccountName: example-account
        containers:
        - name: example-curl
          image: curlimages/curl:7.77.0
          args:
          - "-s"
          - "-XPOST"
          - "-H"
          - "Content-Type: application/json"
          - "http://username:password@target-host:9099/path"
          - "--max-time"
          - "10.0"
  1. Wait until the scaled job schedule executes. The job will execute every 30 seconds.

Logs from KEDA operator

example

KEDA Version

2.2.0

Kubernetes Version

1.18

Platform

Amazon Web Services

Scaler Details

No response

Anything else?

No response

@jordenk jordenk added the bug Something isn't working label Jun 15, 2021
@stale
Copy link

stale bot commented Oct 13, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Oct 13, 2021
@stale
Copy link

stale bot commented Oct 20, 2021

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Oct 20, 2021
@marticardus
Copy link

I think that issue is interesting, i want to supply internal kubernetes cronjob systems with KEDA Cron to execute pods at cron schedule, for exemple, every 5 minuts.

Is a possiblity to re-open this issue?

@zroubalik zroubalik reopened this Mar 27, 2024
@stale stale bot removed the stale All issues that are marked as stale due to inactivity label Mar 27, 2024
@tomkerkhove tomkerkhove added the help wanted Looking for support from community label Apr 2, 2024
@dogzzdogzz
Copy link
Contributor

dogzzdogzz commented Apr 18, 2024

We have a similar use case in which we aim to utilize KEDA's ScaledJob with the Cron scaler to trigger one-time jobs. We prefer using ScaledJob over Kubernetes CronJob because KEDA supports timezone settings. This feature allows us to easily set jobs to run at local times without the need to manually convert them from UTC.

  - type: cron
    metadata:
      timezone: America/New_York
      start: 54 13 * * *
      end: 55 13 * * *
      desiredReplicas: "1"

Now we use below as a workaround

    if end_time - start_time < 60:
        sleep(end_time - start_time)

Copy link

stale bot commented Jun 18, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Jun 18, 2024
@zroubalik zroubalik removed the stale All issues that are marked as stale due to inactivity label Jun 25, 2024
Copy link

stale bot commented Aug 27, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Aug 27, 2024
Copy link

stale bot commented Sep 5, 2024

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Sep 5, 2024
@rhuanbarreto
Copy link

I'm interested in this. Maybe someone could reopen it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Looking for support from community stale All issues that are marked as stale due to inactivity
Projects
None yet
Development

No branches or pull requests

6 participants