halkyonio / operator

Kubernetes Operator simplifying the development of microservices on k8s !
Apache License 2.0
40 stars 14 forks source link

Todo: Change component status when build starts/ends #60

Open cmoulliard opened 5 years ago

cmoulliard commented 5 years ago

Description of the problem

We don't change the component status when we use the Build mode and when Tekton starts or ends the task of the build

oc get all
NAME                              READY     STATUS      RESTARTS   AGE
pod/s2i-buildah-push-pod-e08506   0/8       Completed   0          11m

NAME                               AGE
task.tekton.dev/s2i-buildah-push   11m

NAME                                  SUCCEEDED   REASON    STARTTIME   COMPLETIONTIME
taskrun.tekton.dev/s2i-buildah-push   False                 11m         2m

NAME                                                  RUNTIME       VERSION   AGE       MODE      STATUS    MESSAGE                                                                REVISION
component.devexp.runtime.redhat.com/fruit-client-sb   spring-boot   2.1.3     11m       build     Pending   pod is not ready for component 'fruit-client-sb' in namespace 'demo'   
cmoulliard commented 5 years ago

I have updated the code to change the status to building when the component will be be processed by the build reconcile.

As the code that we use is the same between the dev or build installation to keep track of the pod status changes, how can I fetch the taskRun/s2i-buildah-push pod created by tekton to update finally the Component status to Ready if the build succeed or fail ? @metacosm Should we have 2 fetch functions or one where we pass as parameter the deploymentMode and where we change the label to get the taskRun pod ?

metacosm commented 5 years ago

@cmoulliard I think we should have only one function and use the deploymentMode. That said, that function should probably be changed, since in calling code, we're only interested in the pod status and its name, not the pod itself…

cmoulliard commented 5 years ago

I propose then to enrich the fetch function and to use as label to query the build's pod this selector - https://github.com/snowdrop/component-operator/blob/166030e6bdaabc7d91fe45ca9525564838cff430/pkg/controller/component/helpers.go#L58 and of course the app: component_name selector for a dev's pod

cmoulliard commented 5 years ago

BTW, we have also to change the code in order to use isPodReady for dev deployment and isBuildSucceed for build deployment

Here are the different status reported by the taskRun pod. Value is equal to True if it succeeded

oc get taskruns
NAME               SUCCEEDED   REASON    STARTTIME   COMPLETIONTIME
s2i-buildah-push   Unknown     Pending   6s              

oc get taskruns
NAME               SUCCEEDED   REASON     STARTTIME   COMPLETIONTIME
s2i-buildah-push   Unknown     Building   24s         

oc get taskruns
NAME               SUCCEEDED   REASON    STARTTIME   COMPLETIONTIME
s2i-buildah-push   False                 2m          51s
cmoulliard commented 5 years ago

I can't use fetchPod to get the pod and next check if isBuildSucceeded as the status and conditions are managed by the taskRun resource and not directly by the pod of task doing the build