Hi All, I am wondering about question#3 in 'commands/arguments' lab in the appli . . .

Hi All, I am wondering about question#3 in ‘commands/arguments’ lab in the application lifecycle management section. the question is to modify the command in the file ubuntu-sleeper-2.yaml
My answer is command: ['sh', '-c', 'sleep 5000'] < marked wrong for some reason
Correct answer is:
My answer works completely fine so why marked wrong? it’s what is in the k8s doc
Is the script that evaluates the answer is hard-coding only one way to answer this question, perhaps?

Fernando Jimenez:
Most likely because if I recall correctly it will expect “4800” instead of “5000”.

the answer is with 5000, but for some reason only accepts one way of answering, I am guessing

Fernando Jimenez:
Ok, so I do not remember that one then, but I can see the difference between what you did and what you said it was right.

'sh', '-c', 'sleep 5000'

It will be

- sh
- -c
- 'sleep 5000'

which is not the expected command of

- sleep
- "5000"

They both work tho, I guess I am not understanding why the lab only accepts one way of answering this question.
This is from k8s:

  - name: myapp-container
    image: busybox:1.28
    command: ['sh', '-c', 'echo The app is running! &amp;&amp; sleep 3600']

Fernando Jimenez:
Yeah, there are many ways of doing “almost” the same thing, but in order to programmatically assert correctness, you must ask for one specifically and check that’s what it has been provided.

Fernando Jimenez:
At times it becomes almost as important how the task is been asked in order to ensure that’s what’s expected and you are going to be graded correctly.

good point @Fernando Jimenez how do we decide which syntax to use during the exam? I almost always follow what’s published in k8s documentation, hopefully that’s what they are expecting us to use.

Fernando Jimenez:
I know that there is uncertainty, at times, when we do not know. Practice is supposed to replace that uncertainty with experience. But documentation will not do that. Most of the time the “official” documentation is only half of the story and at best just a guide, but it is not the solution to how you might need to implement it.
Take this piece for example from the document

command: ['sh', '-c', 'echo The app is running! &amp;&amp; sleep 3600']

I noticed that quite a few people have trouble with it. Understanding why “sh -c” in this case, and what is it about the rest.
But this command has nothing to do with k8s and existed before we tried to send it to a container inside a pod. So the question would be, what do we need to know about how Linux commands work in the shell in order to be effective understanding what is asked of us?
Those that are experienced with Linux commands know that you do not need (normally) to do this

sh -c sleep 3600 

That’s creating a shell fork and telling it to execute the command sleep with the argument 3600 seconds.
It is not necessary to create another fork because sleep can be invoked directly, like

sleep 3600

I’ll say, in the exam pay attention to the question, most likely you’ll be told exactly what’s the command and do not guess. If you find yourself thinking that you need to guess, maybe it is truly a bad question, however, a higher chance is that something did not register when you read the question. Perhaps because unfamiliarity.
I hope this will not distress you and I wish you the best.

Ravi Shanker:
To solve the question it is expected to use the imperative way using the command and dry-run options. Seems for this reason the other option is showing wrong. kubectl run … --dry-run=client -o yaml --command – sleep 5000 >ubuntu-sleeper-2.yaml

Thanks much @Fernando Jimenez for your thorough explanation
Good point @Ravi Shanker i probably should start doing that instead for the sake of the exam