Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Kamel install with kit option can leave integrationkit stuck waiting for platform #810

Merged
merged 1 commit into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions pkg/controller/integrationkit/integrationkit_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down