Need help on cronjob question in Mock test

I am not able to find issue in answer. kindly help me to find issue.

Question:
For this question, please set the context to cluster1 by running:

kubectl config use-context cluster1

In the ckad-job namespace, create a cronjob named simple-python-job to run every 30 minutes to list all the running processes inside a container that used python image (the command needs to be run in a shell).

In Python, ps –eaf can be use to list all the running processes.

My answer is:

apiVersion: batch/v1
kind: CronJob
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"batch/v1","kind":"CronJob","metadata":{"annotations":{},"creationTimestamp":null,"name":"simple-python-job","namespace":"ckad-job"},"spec":{"jobTemplate":{"metadata":{"creationTimestamp":null,"name":"simple-python-job"},"spec":{"template":{"metadata":{"creationTimestamp":null},"spec":{"containers":[{"command":["/bin/sh","-c","ps -eaf"],"image":"python","name":"simple-python-job","resources":{}}],"restartPolicy":"OnFailure"}}}},"schedule":"*/30 * * * *"},"status":{}}
  creationTimestamp: "2024-01-10T19:33:42Z"
  generation: 1
  name: simple-python-job
  namespace: ckad-job
  resourceVersion: "5413"
  uid: 40584d7c-6926-4912-b726-37f5f3738a83
spec:
  concurrencyPolicy: Allow
  failedJobsHistoryLimit: 1
  jobTemplate:
    metadata:
      creationTimestamp: null
      name: simple-python-job
    spec:
      template:
        metadata:
          creationTimestamp: null
        spec:
          containers:
          - command:
            - /bin/sh
            - -c
            - ps -eaf
            image: python
            imagePullPolicy: Always
            name: simple-python-job
            resources: {}
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
          dnsPolicy: ClusterFirst
          restartPolicy: OnFailure
          schedulerName: default-scheduler
          securityContext: {}
          terminationGracePeriodSeconds: 30
  schedule: '*/30 * * * *'
  successfulJobsHistoryLimit: 3
  suspend: false
status:
  lastScheduleTime: "2024-01-10T20:30:00Z"
  lastSuccessfulTime: "2024-01-10T20:30:41Z"

Correct answer is:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: simple-python-job
  namespace: ckad-job
spec:
  schedule: "*/30 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: simple-python-job
            image: python
            imagePullPolicy: IfNotPresent
            command:
            - /bin/sh
            - -c
            - ps –eaf
          restartPolicy: OnFailure

I am not able to find where is the actual issue in my implementation.

Issue is "incorrect command’ rest is okay.

You’re setting a number of options in your YAML that the answer does not, so I’d start by trying to run the supplied answer, seeing if it runs, and then figure out which items you added are not kosher with the grader.

i have just copied yaml from the deployment. This is not exact yaml which i created. I have just mentioned that answer says that ‘incorrect command’.

can you please tell me how command is incorrect?

“copied from the deployment” – which deployment?

The jobTemplate block is not exactly the same as the template block of a deployment, in any case. So: did you try to run the second version of the YAML, to see if it (1) works, and (2) passes the grader?

Hey,

Can you please read my question again?

Answer says that everything is correct but not command. So my question is why do you think my command is not correct?

Also, here deployment means i fetched the yaml of my answer to paste it here from cronjob which is running status.

I hope i answered your question.

I don’t think the problem is with not reading it; I have. What you wrote is, in truth, not real clear.

  1. What “command” are you talking about. I see YAML. It has a command block. But how you ran it? You have not said.
  2. Where did you see this error? Could you perhaps copy it from the terminal, if that’s where it appeared.

Insufficient data for a meaningful answer :frowning:

Also: please take the answer (as posted by the solutions tab; I don’t mean what you wrote), and try to run it. I want to see if there’s an error in your YAML.

Hey,

As I mentioned already, there is only one command block in both yamls i shared.

I have one copied from terminal which I implemented and one the original answer while doing score check.

I think there is any insufficient information in my answer, i have mentioned, question, my answer yaml and also the yaml by kodekloud mock test. Which information is missing here?

Both yamls are running and running the job. My questions is that why it has incorrect answer in mock test. What’s wring in command block which is exactly same in original answer.

Does the answer from the solutions tab pass the grader? If it does, then it’s not the command block that’s the problem. Beyond that, I really can’t tell you. The grader can be opaque, and it can be hard to tell why it fails. This is why I’ve asked you a few times now to try that version of the YAML, so we can make sure that the recommended solution passes the grader. If both fail, that’s news. If it does not, we can test to see why we get a different response on your original file.

Hi,

For sure something is broken here.
I have the same issue - my question check is failing on subtask “Does cronjob run ps –eaf command?”
I copied command section from provided answer, but Lab still complaining about this.