Do configuration changes only if the kaniko job is required to be created
wso2/k8s-api-operator#350
@@ -342,11 +342,16 @@ func (r *ReconcileAPI) Reconcile(request reconcile.Request) (reconcile.Result, e
// check if the image already exists
imageExist, errImage := registry.IsImageExist(&r.client)
if errImage != nil {
- log.Error(errImage, "Error in image finding")
- }
- log.Info("Is MGW runtime image exist in the docker registry?",
+ log.Error(errImage, "Error finding the MGW image in registry. Continue with creating Kaniko job",
+ "mgw_docker_image", mgwDockerImage)
+ } else {
+ log.Info("Existence of MGW runtime image in the docker registry",
"exists", strconv.FormatBool(imageExist), "mgw_docker_image", mgwDockerImage)
+ }
+ // create Kaniko job
+ // if updating api or overriding api or image not found
+ if instance.Spec.UpdateTimeStamp != "" || instance.Spec.Override || !imageExist {
// handling analytics
log.Info("Handling analytics")
if err := analytics.Handle(&r.client, userNamespace); err != nil {
@@ -387,10 +392,7 @@ func (r *ReconcileAPI) Reconcile(request reconcile.Request) (reconcile.Result, e
log.Info("No kaniko-arguments config map is available in wso2-system namespace")
}
- // create Kaniko job
- // if updating api or overriding api or image not found
var kanikoJob *batchv1.Job
- if instance.Spec.UpdateTimeStamp != "" || instance.Spec.Override || !imageExist {
log.Info("Deploying the Kaniko job in cluster")
kanikoJob = kaniko.Job(instance, controlConfigData, kanikoArgs.Data[kanikoArguments], ownerRef)
if err := controllerutil.SetControllerReference(instance, kanikoJob, r.scheme); err != nil {
@@ -400,7 +402,7 @@ func (r *ReconcileAPI) Reconcile(request reconcile.Request) (reconcile.Result, e
if errJob := k8s.CreateIfNotExists(&r.client, kanikoJob); errJob != nil {
return reconcile.Result{}, errJob
}
- }
+
// if kaniko job started (i.e. not nil)
if kanikoJob != nil {
// check for kaniko completion
@@ -428,6 +430,7 @@ func (r *ReconcileAPI) Reconcile(request reconcile.Request) (reconcile.Result, e
reqLogger.Info("Kaniko job is completed successfully", "job_status", kanikoJob.Status)
}
}
+ }
// kaniko job completed or not ran (i.e. image already exists)
// deploying the MGW runtime image
