This is an automated email from the ASF dual-hosted git repository.

astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/master by this push:
     new f37e79d  fix: Kamel install with kit option can leave integrationkit 
stuck waiting for platform
f37e79d is described below

commit f37e79d2c614fbdad5ebce991a267b2b4eb99be2
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Thu Jul 11 13:05:13 2019 +0100

    fix: Kamel install with kit option can leave integrationkit stuck waiting 
for platform
    
    fixes #809
---
 .../integrationkit/integrationkit_controller.go    | 38 ++++++++++++++++++++++
 pkg/platform/platform.go                           |  2 +-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/pkg/controller/integrationkit/integrationkit_controller.go 
b/pkg/controller/integrationkit/integrationkit_controller.go
index fd2d599..431b8ef 100644
--- a/pkg/controller/integrationkit/integrationkit_controller.go
+++ b/pkg/controller/integrationkit/integrationkit_controller.go
@@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 
or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
+
 package integrationkit
 
 import (
@@ -27,6 +28,8 @@ import (
        "k8s.io/apimachinery/pkg/api/errors"
        k8serrors "k8s.io/apimachinery/pkg/api/errors"
        "k8s.io/apimachinery/pkg/runtime"
+       "k8s.io/apimachinery/pkg/types"
+       k8sclient "sigs.k8s.io/controller-runtime/pkg/client"
 
        "sigs.k8s.io/controller-runtime/pkg/controller"
        "sigs.k8s.io/controller-runtime/pkg/event"
@@ -106,6 +109,41 @@ func add(mgr manager.Manager, r reconcile.Reconciler) 
error {
                return err
        }
 
+       // Watch for IntegrationPlatform phase transitioning to ready and 
enqueue
+       // requests for any integrationkits that are in phase waiting for 
platform
+       err = c.Watch(&source.Kind{Type: &v1alpha1.IntegrationPlatform{}}, 
&handler.EnqueueRequestsFromMapFunc{
+               ToRequests: handler.ToRequestsFunc(func(a handler.MapObject) 
[]reconcile.Request {
+                       platform := a.Object.(*v1alpha1.IntegrationPlatform)
+                       var requests []reconcile.Request
+
+                       if platform.Status.Phase == 
v1alpha1.IntegrationPlatformPhaseReady {
+                               list := &v1alpha1.IntegrationKitList{}
+
+                               if err := mgr.GetClient().List(context.TODO(), 
&k8sclient.ListOptions{Namespace: platform.Namespace}, list); err != nil {
+                                       log.Error(err, "Failed to retrieve 
integrationkit list")
+                                       return requests
+                               }
+
+                               for _, kit := range list.Items {
+                                       if kit.Status.Phase == 
v1alpha1.IntegrationKitPhaseWaitingForPlatform {
+                                               log.Infof("Platform %s ready, 
wake-up integrationkit: %s", platform.Name, kit.Name)
+                                               requests = append(requests, 
reconcile.Request{
+                                                       NamespacedName: 
types.NamespacedName{
+                                                               Namespace: 
kit.Namespace,
+                                                               Name:      
kit.Name,
+                                                       },
+                                               })
+                                       }
+                               }
+                       }
+
+                       return requests
+               }),
+       })
+       if err != nil {
+               return err
+       }
+
        return nil
 }
 
diff --git a/pkg/platform/platform.go b/pkg/platform/platform.go
index a8ea575..92682c2 100644
--- a/pkg/platform/platform.go
+++ b/pkg/platform/platform.go
@@ -38,7 +38,7 @@ func GetOrLookup(ctx context.Context, c k8sclient.Reader, 
namespace string, name
 
 // Get returns the currently installed platform
 func Get(ctx context.Context, c k8sclient.Reader, namespace string, name 
string) (*v1alpha1.IntegrationPlatform, error) {
-       return kubernetes.GetIntegrationPlatform(ctx, c, namespace, name)
+       return kubernetes.GetIntegrationPlatform(ctx, c, name, namespace)
 }
 
 // GetCurrentPlatform returns the currently installed platform

Reply via email to