Skip to content

Commit

Permalink
WIP: experiment to test on gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed Dec 21, 2023
1 parent 09bc14f commit 1785626
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/actions/e2e-knative-yaks/exec-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ export CAMEL_K_TEST_IMAGE_VERSION=${CUSTOM_VERSION}
export CAMEL_K_TEST_SAVE_FAILED_TEST_NAMESPACE=${SAVE_FAILED_TEST_NS}

# Then run integration tests
yaks test e2e/yaks/common
yaks test e2e/yaks/common/kamelet-binding
12 changes: 9 additions & 3 deletions e2e/yaks/common/kamelet-binding/yaks-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ pre:
kubectl apply -f timer-source-binding-kb.yaml -n $YAKS_NAMESPACE
kubectl apply -f logger-sink-binding-kb.yaml -n $YAKS_NAMESPACE
kubectl wait kameletbinding timer-source-binding-kb --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
kubectl wait kameletbinding logger-sink-binding-kb --for=condition=Ready --timeout=10m -n $YAKS_NAMESPACE
kubectl wait kameletbinding timer-source-binding-kb --for=condition=Ready --timeout=5m -n $YAKS_NAMESPACE
kubectl wait kameletbinding logger-sink-binding-kb --for=condition=Ready --timeout=5m -n $YAKS_NAMESPACE
post:
- name: print dump
if: env:CI=true && failure()
run: yaks dump --includes app=camel-k
run: |
kubectl get klb -o yaml -n $YAKS_NAMESPACE
kubectl get it -o yaml -n $YAKS_NAMESPACE
kubectl get ksvc -o yaml -n $YAKS_NAMESPACE
kubectl get deploy -o yaml -n $YAKS_NAMESPACE
kubectl get pods -o yaml -n $YAKS_NAMESPACE
yaks dump --includes app=camel-k
5 changes: 4 additions & 1 deletion pkg/controller/integration/integration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,16 @@ func add(ctx context.Context, mgr manager.Manager, c client.Client, r reconcile.
if ok, err := kubernetes.IsAPIResourceInstalled(c, servingv1.SchemeGroupVersion.String(), reflect.TypeOf(servingv1.Service{}).Name()); err != nil {
return err
} else if ok {
// Check for permission to watch the ConsoleCLIDownload resource
// Check for permission to watch the KnativeService resource
checkCtx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
if ok, err = kubernetes.CheckPermission(checkCtx, c, serving.GroupName, "services", platform.GetOperatorWatchNamespace(), "", "watch"); err != nil {
return err
} else if ok {
log.Info("The operator has the privileges to watch KnativeService resources.")
b.Owns(&servingv1.Service{}, builder.WithPredicates(StatusChangedPredicate{}))
} else {
log.Info("The operator has not the privileges to watch KnativeService resources. Won't be able to work with Knative!")
}
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/integration/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (action *monitorAction) CanHandle(integration *v1.Integration) bool {
}

func (action *monitorAction) Handle(ctx context.Context, integration *v1.Integration) (*v1.Integration, error) {
action.L.Info("Integration monitoring")
// When in InitializationFailed condition a kit is not available for the integration
// so handle it differently from the rest
if isInInitializationFailed(integration.Status) {
Expand Down Expand Up @@ -314,6 +315,7 @@ func (action *monitorAction) updateIntegrationPhaseAndReadyCondition(
ctx context.Context, environment *trait.Environment, integration *v1.Integration,
pendingPods []corev1.Pod, runningPods []corev1.Pod,
) error {
action.L.Info("updateIntegrationPhaseAndReadyCondition()")
controller, err := action.newController(environment, integration)
if err != nil {
return err
Expand Down Expand Up @@ -472,6 +474,7 @@ func (action *monitorAction) probeReadiness(
ctx context.Context, environment *trait.Environment, integration *v1.Integration,
unreadyPods []corev1.Pod, readyPods []corev1.Pod,
) error {
action.L.Info("probeReadiness()")
readyCondition := v1.IntegrationCondition{
Type: v1.IntegrationConditionReady,
Status: corev1.ConditionFalse,
Expand Down
6 changes: 6 additions & 0 deletions pkg/controller/integration/monitor_knative.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package integration

import (
"context"
"fmt"

corev1 "k8s.io/api/core/v1"

Expand All @@ -36,9 +37,11 @@ type knativeServiceController struct {
var _ controller = &knativeServiceController{}

func (c *knativeServiceController) checkReadyCondition(ctx context.Context) (bool, error) {
fmt.Println("checkReadyCondition()")
// Check the KnativeService conditions
if ready := kubernetes.GetKnativeServiceCondition(*c.obj, servingv1.ServiceConditionReady); ready.IsFalse() &&
ready.GetReason() == "RevisionFailed" {
fmt.Println("ksvc revision failed")
c.integration.Status.Phase = v1.IntegrationPhaseError
c.integration.SetReadyConditionError(ready.Message)
return true, nil
Expand All @@ -52,12 +55,15 @@ func (c *knativeServiceController) getPodSpec() corev1.PodSpec {
}

func (c *knativeServiceController) updateReadyCondition(readyPods []corev1.Pod) bool {
fmt.Println("updateReadyCondition()")
ready := kubernetes.GetKnativeServiceCondition(*c.obj, servingv1.ServiceConditionReady)
if ready.IsTrue() {
fmt.Println("ksvc ready is true")
c.integration.SetReadyCondition(corev1.ConditionTrue,
v1.IntegrationConditionKnativeServiceReadyReason, "")
return true
}
fmt.Println("ksvc ready is false")
c.integration.SetReadyCondition(corev1.ConditionFalse,
ready.GetReason(), ready.GetMessage())

Expand Down
1 change: 0 additions & 1 deletion pkg/util/kubernetes/permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
// in the cluster.
// E.g. checkPermission(client, olmv1alpha1.GroupName, "clusterserviceversions", namespace, "camel-k", "get")
//

func CheckPermission(ctx context.Context, client kubernetes.Interface, group, resource, namespace, name, verb string) (bool, error) {
sarReview := &authorizationv1.SelfSubjectAccessReview{
Spec: authorizationv1.SelfSubjectAccessReviewSpec{
Expand Down

0 comments on commit 1785626

Please sign in to comment.