diff --git a/components/application-broker/internal/broker/provision.go b/components/application-broker/internal/broker/provision.go index 3b82e36907a9..0a9f7a5f2820 100644 --- a/components/application-broker/internal/broker/provision.go +++ b/components/application-broker/internal/broker/provision.go @@ -236,11 +236,11 @@ func (svc *ProvisionService) do(iID internal.InstanceID, opID internal.Operation applicationID := string(appID) applicationName := string(appName) - // enable the namespace default Knative Broker - if err := svc.enableDefaultKnativeBroker(namespace); err != nil { + // create Kyma EventActivation + if err := svc.createEaOnSuccessProvision(applicationName, applicationID, namespace, displayName, iID); err != nil { instanceState = internal.InstanceStateFailed opState = internal.OperationStateFailed - opDesc = fmt.Sprintf("provisioning failed while enabling default Knative Broker for namespace: %s on error: %s", namespace, err) + opDesc = fmt.Sprintf("provisioning failed while creating EventActivation on error: %s", err) svc.updateStates(iID, opID, instanceState, opState, opDesc) return } @@ -255,11 +255,11 @@ func (svc *ProvisionService) do(iID internal.InstanceID, opID internal.Operation return } - // create Kyma EventActivation - if err := svc.createEaOnSuccessProvision(applicationName, applicationID, namespace, displayName, iID); err != nil { + // enable the namespace default Knative Broker + if err := svc.enableDefaultKnativeBroker(namespace); err != nil { instanceState = internal.InstanceStateFailed opState = internal.OperationStateFailed - opDesc = fmt.Sprintf("provisioning failed while creating EventActivation on error: %s", err) + opDesc = fmt.Sprintf("provisioning failed while enabling default Knative Broker for namespace: %s on error: %s", namespace, err) svc.updateStates(iID, opID, instanceState, opState, opDesc) return } diff --git a/components/application-broker/internal/broker/provision_test.go b/components/application-broker/internal/broker/provision_test.go index f91173dfbd6f..5d64f57e041e 100644 --- a/components/application-broker/internal/broker/provision_test.go +++ b/components/application-broker/internal/broker/provision_test.go @@ -819,6 +819,17 @@ func TestDoProvision(t *testing.T) { } for _, tc := range []testCase{ + { + name: "provision fail no channel found", + givenCanProvisionOutput: access.CanProvisionOutput{Allowed: true}, + expectedOpState: internal.OperationStateFailed, + expectedOpDesc: `provisioning failed while persisting Knative Subscription for application: ec-prod namespace: example-namespace on error: getting the Knative channel for the application [ec-prod]: channels.messaging.knative.dev "" not found`, + expectedEventActivationCreated: true, + expectedInstanceState: internal.InstanceStateFailed, + initialObjs: []runtime.Object{ + bt.NewAppNamespace(string(appNs), false), + }, + }, { name: "provision success subscription created before", givenCanProvisionOutput: access.CanProvisionOutput{Allowed: true}, @@ -866,7 +877,7 @@ func TestDoProvision(t *testing.T) { mockServiceInstanceGetter := &automock.ServiceInstanceGetter{} defer mockServiceInstanceGetter.AssertExpectations(t) - mockOperationStorage.On("UpdateStateDesc", iID, opID, internal.OperationStateSucceeded, fixProvisionSucceeded()).Return(nil).Once() + mockOperationStorage.On("UpdateStateDesc", iID, opID, tc.expectedOpState, &tc.expectedOpDesc).Return(nil).Once() mockAccessChecker.On("CanProvision", fixInstanceID(), fixAppServiceID(), fixNs(), time.Minute).Return(tc.givenCanProvisionOutput, tc.givenCanProvisionError) mockInstanceStorage.On("UpdateState", fixInstanceID(), tc.expectedInstanceState).Return(nil).Once() if tc.expectedEventActivationCreated {