You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/09/09 14:24:59 UTC

[GitHub] [camel-k] johnpoth opened a new pull request #2627: Upgrade sbo

johnpoth opened a new pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627


   <!-- Description -->
   
   This leverages some of the work by @pedjak in [sbo-919](https://github.com/redhat-developer/service-binding-operator/pull/919) that allows us to use SBO as a library. This means that the Service Binding Operator no longers needs to be installed.
   
   This has the benefit of simplifying the code a bit and allows us to upgrade to the latest version (#2553) without having to wait for [sbo-#927](https://github.com/redhat-developer/service-binding-operator/issues/927). It also avoids us having to use SBO as a service through CRDs which was a little messy. I've removed:
   
   - IntegrationPhaseWaitingForBindings
   - IntegrationConditionServiceBindingsCollectionReady
   - The ability to bind to an existing ServiceBinding (part of the updated specification)
   - Renamed ServiceBinding trait property to "service"
   
   As the specification is still work in progress (which we mention in the docs), I think that's o.k
   
   Thanks !
   
   <!--
   Enter your extended release note in the below block. If the PR requires
   additional action from users switching to the new release, include the string
   "action required". If no release note is required, write "NONE". 
   
   You can (optionally) mark this PR with labels "kind/bug" or "kind/feature" to make sure
   the text is added to the right section of the release notes. 
   -->
   
   **Release Note**
   ```release-note
   NONE
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] pedjak commented on a change in pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
pedjak commented on a change in pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#discussion_r708195684



##########
File path: pkg/trait/service_binding.go
##########
@@ -53,137 +54,65 @@ func (t *serviceBindingTrait) Configure(e *Environment) (bool, error) {
 		return false, nil
 	}
 
-	if len(t.ServiceBindings) == 0 {
+	if len(t.Services) == 0 {
 		return false, nil
 	}
 
 	return e.IntegrationInPhase(
 		v1.IntegrationPhaseInitialization,
-		v1.IntegrationPhaseWaitingForBindings,
 		v1.IntegrationPhaseDeploying,
 		v1.IntegrationPhaseRunning,
 	), nil
 }
 
 func (t *serviceBindingTrait) Apply(e *Environment) error {
-	services, err := t.parseProvisionedServices(e)
+	ctx, err := t.getContext(e)
 	if err != nil {
 		return err
 	}
-	serviceBindings, err := t.parseServiceBindings(e)
+	// let the SBO retry policy be controlled by Camel-k
+	err = process(ctx, getHandlers())
 	if err != nil {
 		return err
 	}
-	if len(services) > 0 {
-		serviceBindings = append(serviceBindings, e.Integration.Name)
-	}
-	if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
-		serviceBindingsCollectionReady := true
-		for _, name := range serviceBindings {
-			isIntSB := name == e.Integration.Name
-			serviceBinding, err := t.getServiceBinding(e, name)
-			// Do not throw an error if the ServiceBinding is not found and if we are managing it: we will create it
-			if (err != nil && !k8serrors.IsNotFound(err)) || (err != nil && !isIntSB) {
-				return err
-			}
-			if isIntSB {
-				request := createServiceBinding(e, services, e.Integration.Name)
-				e.Resources.Add(&request)
-			}
-			if isCollectionReady(serviceBinding) {
-				setCollectionReady(e, name, corev1.ConditionTrue)
-			} else {
-				setCollectionReady(e, name, corev1.ConditionFalse)
-				serviceBindingsCollectionReady = false
-			}
-		}
-		if !serviceBindingsCollectionReady {
-			e.PostProcessors = append(e.PostProcessors, func(environment *Environment) error {
-				e.Integration.Status.Phase = v1.IntegrationPhaseWaitingForBindings
-				return nil
-			})
-		}
-		return nil
-	} else if e.IntegrationInPhase(v1.IntegrationPhaseWaitingForBindings) {
-		for _, name := range serviceBindings {
-			serviceBinding, err := t.getServiceBinding(e, name)
-			if err != nil {
-				return err
-			}
-			if isCollectionReady(serviceBinding) {
-				setCollectionReady(e, name, corev1.ConditionTrue)
-			} else {
-				setCollectionReady(e, name, corev1.ConditionFalse)
-				return nil
-			}
-			if name == e.Integration.Name {
-				request := createServiceBinding(e, services, name)
-				e.Resources.Add(&request)
-			}
-		}
-	} else if e.IntegrationInPhase(v1.IntegrationPhaseDeploying, v1.IntegrationPhaseRunning) {
-		e.ServiceBindings = make(map[string]string)
-		for _, name := range serviceBindings {
-			sb, err := t.getServiceBinding(e, name)
-			if err != nil {
-				return err
-			}
-			if !isCollectionReady(sb) {
-				setCollectionReady(e, name, corev1.ConditionFalse)
-				e.PostProcessors = append(e.PostProcessors, func(environment *Environment) error {
-					e.Integration.Status.Phase = v1.IntegrationPhaseWaitingForBindings
-					return nil
-				})
-				return nil
-			}
-			e.ServiceBindings[name] = sb.Status.Secret
-			if name == e.Integration.Name {
-				request := createServiceBinding(e, services, name)
-				e.Resources.Add(&request)
-			}
-		}
+
+	secret := createSecret(ctx, e.Integration.Namespace)
+	if secret != nil {

Review comment:
       what is the reason for not injecting binding through SBO default pipeline?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] astefanutti commented on a change in pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
astefanutti commented on a change in pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#discussion_r705403224



##########
File path: pkg/install/operator.go
##########
@@ -406,13 +399,6 @@ func installLeaseBindings(ctx context.Context, c client.Client, namespace string
 	)
 }
 
-func installServiceBindings(ctx context.Context, c client.Client, namespace string, customizer ResourceCustomizer, collection *kubernetes.Collection, force bool) error {
-	return ResourcesOrCollect(ctx, c, namespace, collection, force, customizer,
-		"/rbac/operator-role-service-binding.yaml",
-		"/rbac/operator-role-binding-service-binding.yaml",

Review comment:
       It seems the `operator-role-binding-service-binding.yaml` file can also be removed. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] astefanutti commented on pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
astefanutti commented on pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#issuecomment-916866619


   The install is failing on OpenShift because of privileges escalation. The admin user that is used to install the operator is not granted permission to get CRDs. I think we can keep a separate RBAC manifest for the permissions required by the embedded SBO, and warn when the install user cannot create it, as we already do for other "addons".


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] johnpoth commented on pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
johnpoth commented on pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#issuecomment-927926347


   Yeah looks like there was a new [test](https://github.com/apache/camel-k/blob/main/e2e/common/kustomize/setup_test.go#L43) to make sure the correct number of Roles etc... were installed. Looks all good now


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] astefanutti commented on pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
astefanutti commented on pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#issuecomment-926703609


   The `TestBasicSetup` test fails consistently. I suspect there is a discrepancy that sneaked in during conflict resolution with the Kustomize PR and the embedded resources. Maybe worth re-running `make build-resources`. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] astefanutti commented on pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
astefanutti commented on pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#issuecomment-927931619


   Awesome, thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] johnpoth commented on pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
johnpoth commented on pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#issuecomment-919000361


   Thanks for reviewing ! PR should be ok now, switched to `ClusterRole`/`ClusterRoleBinding` for `CRD` rights ... thanks !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] johnpoth commented on a change in pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
johnpoth commented on a change in pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#discussion_r708209763



##########
File path: pkg/trait/service_binding.go
##########
@@ -53,137 +54,65 @@ func (t *serviceBindingTrait) Configure(e *Environment) (bool, error) {
 		return false, nil
 	}
 
-	if len(t.ServiceBindings) == 0 {
+	if len(t.Services) == 0 {
 		return false, nil
 	}
 
 	return e.IntegrationInPhase(
 		v1.IntegrationPhaseInitialization,
-		v1.IntegrationPhaseWaitingForBindings,
 		v1.IntegrationPhaseDeploying,
 		v1.IntegrationPhaseRunning,
 	), nil
 }
 
 func (t *serviceBindingTrait) Apply(e *Environment) error {
-	services, err := t.parseProvisionedServices(e)
+	ctx, err := t.getContext(e)
 	if err != nil {
 		return err
 	}
-	serviceBindings, err := t.parseServiceBindings(e)
+	// let the SBO retry policy be controlled by Camel-k
+	err = process(ctx, getHandlers())
 	if err != nil {
 		return err
 	}
-	if len(services) > 0 {
-		serviceBindings = append(serviceBindings, e.Integration.Name)
-	}
-	if e.IntegrationInPhase(v1.IntegrationPhaseInitialization) {
-		serviceBindingsCollectionReady := true
-		for _, name := range serviceBindings {
-			isIntSB := name == e.Integration.Name
-			serviceBinding, err := t.getServiceBinding(e, name)
-			// Do not throw an error if the ServiceBinding is not found and if we are managing it: we will create it
-			if (err != nil && !k8serrors.IsNotFound(err)) || (err != nil && !isIntSB) {
-				return err
-			}
-			if isIntSB {
-				request := createServiceBinding(e, services, e.Integration.Name)
-				e.Resources.Add(&request)
-			}
-			if isCollectionReady(serviceBinding) {
-				setCollectionReady(e, name, corev1.ConditionTrue)
-			} else {
-				setCollectionReady(e, name, corev1.ConditionFalse)
-				serviceBindingsCollectionReady = false
-			}
-		}
-		if !serviceBindingsCollectionReady {
-			e.PostProcessors = append(e.PostProcessors, func(environment *Environment) error {
-				e.Integration.Status.Phase = v1.IntegrationPhaseWaitingForBindings
-				return nil
-			})
-		}
-		return nil
-	} else if e.IntegrationInPhase(v1.IntegrationPhaseWaitingForBindings) {
-		for _, name := range serviceBindings {
-			serviceBinding, err := t.getServiceBinding(e, name)
-			if err != nil {
-				return err
-			}
-			if isCollectionReady(serviceBinding) {
-				setCollectionReady(e, name, corev1.ConditionTrue)
-			} else {
-				setCollectionReady(e, name, corev1.ConditionFalse)
-				return nil
-			}
-			if name == e.Integration.Name {
-				request := createServiceBinding(e, services, name)
-				e.Resources.Add(&request)
-			}
-		}
-	} else if e.IntegrationInPhase(v1.IntegrationPhaseDeploying, v1.IntegrationPhaseRunning) {
-		e.ServiceBindings = make(map[string]string)
-		for _, name := range serviceBindings {
-			sb, err := t.getServiceBinding(e, name)
-			if err != nil {
-				return err
-			}
-			if !isCollectionReady(sb) {
-				setCollectionReady(e, name, corev1.ConditionFalse)
-				e.PostProcessors = append(e.PostProcessors, func(environment *Environment) error {
-					e.Integration.Status.Phase = v1.IntegrationPhaseWaitingForBindings
-					return nil
-				})
-				return nil
-			}
-			e.ServiceBindings[name] = sb.Status.Secret
-			if name == e.Integration.Name {
-				request := createServiceBinding(e, services, name)
-				e.Resources.Add(&request)
-			}
-		}
+
+	secret := createSecret(ctx, e.Integration.Namespace)
+	if secret != nil {

Review comment:
       Hi @pedjak ! Thanks for taking a look!
   
   The Camel K Operator has it's own pipeline for creating Kubernetes resources (here the `Secret`). This allows to do versioning and garbage collection when those resources aren't needed anymore. This is why I didn't want SBO to create the `Secret` through it's default pipeline. I also didn't want it to create the "ServiceBinding" CR as it's not really needed in our "simple" case.
   
   All in all it was a pretty fluid experience using the API




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] astefanutti commented on pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
astefanutti commented on pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627#issuecomment-925591892


   @johnpoth could you please rebase the PR so we can have it merged? Thanks.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] astefanutti merged pull request #2627: Upgrade sbo

Posted by GitBox <gi...@apache.org>.
astefanutti merged pull request #2627:
URL: https://github.com/apache/camel-k/pull/2627


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org