DeriveFromObject readiness doesn't work for a Job object
arturkasperek opened this issue · 3 comments
What happened?
When I was trying to create an Object (with DeriveFromObject
readiness parameter ) that manages a Kubernetes Job it hangs in Ready: False
state. Job is successfully finished and Object doesn't respect that
CC: @phisco I think you should know more since I sow that you implemented that new parameter :-)
How can we reproduce it?
Create an object like here:
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: Object
metadata:
name: test-job
spec:
deletionPolicy: Delete
forProvider:
manifest:
apiVersion: batch/v1
kind: Job
metadata:
name: test-job
namespace: apps
spec:
template:
spec:
containers:
- name: pi
image: perl:5.34.0
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
managementPolicy: Default
providerConfigRef:
name: default
readiness:
policy: DeriveFromObject
Wait till the job will finish and notice that Object
status didn't change:
...
Status:
Completion Time: 2023-07-12T11:17:26Z
Conditions:
Last Probe Time: 2023-07-12T11:17:26Z
Last Transition Time: 2023-07-12T11:17:26Z
Status: True
Type: Complete
Ready: 0
Start Time: 2023-07-12T11:16:06Z
Succeeded: 1
Uncounted Terminated Pods:
Conditions:
Last Transition Time: 2023-07-12T11:16:33Z
Reason: Unavailable
Status: False
Type: Ready
Last Transition Time: 2023-07-12T11:16:06Z
Reason: ReconcileSuccess
Status: True
Type: Synced
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CreatedExternalResource 10m managed/object.kubernetes.crossplane.io Successfully requested creation of external resource
What environment did it happen in?
Crossplane version: upbound/crossplane:v1.12.1-up.2
Provider kubernetes: xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.9.0
Kubernetes distribution: EKS
DeriveFromObject
is going to derive the status from the status of the object, but only if the underlying resource has an element in status.conditions
with type: Ready
. Which is not the case for jobs as you can see, they only have type: Completed
. With the current implementation there is no way to pick the condition to match, however I don't think in this case it would make sense to mark the resource as ready once it's Completed only, so I'd suggest you to switch to the default SuccessfulCreate
readiness policy
I see your point - we would have to stream somehow type: Completed
into Object
.
It don't make sense to stream type: Completed
into type: Ready
I have the same problem for deployments - would it make sense with another AllStatusTrue
policy that simply checks that all conditions have status: True
?