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: Support metadata annotations for ephemeral volume claims #6259

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dpertin
Copy link

@dpertin dpertin commented Oct 22, 2024

Add x-kubernetes-preserve-unknown-fields to ScaledJob CRD in order to support metadata in ephemeral volume claims

Based on #1311

Previously, ArgoCD used to see a diff, bypassed the error but kept the application "OutOfSync":
image
Yet a warning was triggered: unknown field "spec.jobTargetRef.template.spec.volumes[5].ephemeral.volumeClaimTemplate.metadata.annotations"

Now the change is applied, the desired block is part of the "live manifest" and the application is "Synced":
image

Checklist

Fixes #6254

@dpertin dpertin force-pushed the 6254-volumeclaim-metadata branch from 2e104a0 to ebb2775 Compare October 22, 2024 14:57
@JorTurFer
Copy link
Member

Thanks for the fix! He have merged this PR, and I'd say that it will fix the current issue too. Could you double check it?

Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

@dpertin any update please?

@malcolm061990
Copy link

Hi @JorTurFer @zroubalik
The problem still exists deploying keda scaledjob using 2.16.1 chart:

        - ephemeral:
            volumeClaimTemplate:
              metadata:
                annotations:
                  annotaion: annotation
                labels:
                  label: label
              spec:
                accessModes:
                - ReadWriteOnce
                resources:
                  requests:
                    storage: 100Gi
          name: ephemeral-volume
kubectl apply --dry-run=server -f scaledjoboutput.yaml
Error from server (BadRequest): error when creating "scaledjoboutput.yaml": ScaledJob in version "v1alpha1" cannot be handled as a ScaledJob: strict decoding error: unknown field "spec.jobTargetRef.template.spec.volumes[2].ephemeral.volumeClaimTemplate.metadata.annotations", unknown field "spec.jobTargetRef.template.spec.volumes[2].ephemeral.volumeClaimTemplate.metadata.labels"

@JorTurFer
Copy link
Member

Could you share a demo ScaledJob to test it on my local?

@malcolm061990
Copy link

Could you share a demo ScaledJob to test it on my local?

@JorTurFer
Sure, here it is:

---
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
  labels:
    name: godummy
  name: godummy
  namespace: default
spec:
  failedJobsHistoryLimit: 2
  jobTargetRef:
    activeDeadlineSeconds: 7200
    backoffLimit: 1
    completions: 1
    parallelism: 1
    template:
      metadata:
        annotations: null
      spec:
        containers:
        - command:
          - -c
          - job
          env: null
          image: godummy:main
          imagePullPolicy: Always
          name: godummy-container
          volumeMounts:
          - mountPath: /app/data/
            name: ephemeral-volume
          - mountPath: /tmp
            name: tmp
          - mountPath: /etc/ssl/certs/app-ca.pem
            name: vol-app-ca
            readOnly: true
            subPath: app-ca.pem
        imagePullSecrets:
        - name: registry-secret
        restartPolicy: Never
        volumes:
        - emptyDir: {}
          name: tmp
        - name: vol-app-ca
          secret:
            secretName: app-ca
        - ephemeral:
            volumeClaimTemplate:
              metadata:
                annotations:
                  annotaion: annotaion
                labels:
                  label: label
              spec:
                accessModes:
                - ReadWriteOnce
                resources:
                  requests:
                    storage: 100Gi
          name: ephemeral-volume
  maxReplicaCount: 1
  minReplicaCount: 0
  pollingInterval: 30
  successfulJobsHistoryLimit: 3
  triggers:
  - authenticationRef:
      kind: ClusterTriggerAuthentication
      name: trigger
    metadata:
      bootstrapServers: bootstrapServer1:9092,bootstrapServer2:9092,bootstrapServer3:9092
      consumerGroup: infra
      lagThreshold: "10000"
      scaleToZeroOnInvalidOffset: "true"
      topic: godummy-job
    type: kafka

@JorTurFer
Copy link
Member

I've tested and the CRD in KEDA repo is correct and it keeps the annotation
image
I'm going to check using helm chart v2.16.1

@JorTurFer
Copy link
Member

JorTurFer commented Feb 18, 2025

Helm chart doesn't work, there are missing changes related with that CRD in the chart. The problem is solved in KEDA repo, but helm chart is still not working. @zroubalik @wozniakjan , we should ensure that the CRDs are updated during the helm release process, probably I made some mistake during last release and the CRD isn't correctly placed there

I think that this PR isn't required as this repo is fixed

@malcolm061990
Copy link

thanks @JorTurFer for your help
please notify me in this ticket when it will be fixed :)

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.

Support metadata annotations in ScaledJob template's volume claims
4 participants