Skip to content

Commit

Permalink
Merge pull request redhat-appstudio#680 from jgwest/fix-gei-not-found…
Browse files Browse the repository at this point in the history
…-log-aug-2023

GITOPSRVCE-775: fix 'engine instance is nil' err in logs
  • Loading branch information
openshift-ci[bot] authored Oct 17, 2023
2 parents 9fe4fc7 + d09a94c commit 88ed290
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ func (a applicationEventLoopRunner_Action) handleNewGitOpsDeplEvent(ctx context.
isWorkspaceTarget := gitopsDeployment.Spec.Destination.Environment == ""
managedEnv, engineInstance, destinationName, err := a.reconcileManagedEnvironmentOfGitOpsDeployment(ctx, gitopsDeployment,
gitopsDeplNamespace, isWorkspaceTarget)
if err != nil {
if err != nil || managedEnv == nil {

userError := "Unable to reconcile the ManagedEnvironment. Verify that the ManagedEnvironment and Secret are correctly defined, and have valid credentials"
devError := fmt.Errorf("unable to get or create managed environment, isworkspacetarget:%v: %v", isWorkspaceTarget, err)
devError := fmt.Errorf("unable to get or create managed environment, isworkspacetarget:%v: %w", isWorkspaceTarget, err)

return nil, nil, deploymentModifiedResult_Failed, gitopserrors.NewUserDevError(userError, devError)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,12 @@ func internalProcessMessage_internalReconcileSharedManagedEnv(ctx context.Contex
func getManagedEnvironmentCRs(ctx context.Context,
managedEnvironmentCRName string,
managedEnvironmentCRNamespace string,
workspaceClient client.Client, workspaceNamespace corev1.Namespace, k8sClientFactory SRLK8sClientFactory, dbQueries db.DatabaseQueries,
clusterUser db.ClusterUser, log logr.Logger) (managedgitopsv1alpha1.GitOpsDeploymentManagedEnvironment, corev1.Secret, bool, error) {
workspaceClient client.Client,
workspaceNamespace corev1.Namespace,
k8sClientFactory SRLK8sClientFactory,
dbQueries db.DatabaseQueries,
clusterUser db.ClusterUser,
log logr.Logger) (managedgitopsv1alpha1.GitOpsDeploymentManagedEnvironment, corev1.Secret, bool, error) {

const (
resourceDoesNotExist = true
Expand Down
9 changes: 4 additions & 5 deletions tests-e2e/core/gitopsdeployment_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var _ = Describe("GitOpsDeployment Condition Tests", func() {
gitOpsDeploymentResource := gitopsDeplFixture.BuildGitOpsDeploymentResource("managed-environment-gitops-depl",
fixture.RepoURL, fixture.GitopsDeploymentPath,
managedgitopsv1alpha1.GitOpsDeploymentSpecType_Automated)

gitOpsDeploymentResource.Spec.Destination = managedgitopsv1alpha1.ApplicationDestination{
Environment: "does-not-exist", // This is the invalid value, which should return a condition error
Namespace: "",
Expand All @@ -29,13 +30,12 @@ var _ = Describe("GitOpsDeployment Condition Tests", func() {
k8sClient, err := fixture.GetE2ETestUserWorkspaceKubeClient()
Expect(err).To(Succeed())

err = k8s.Create(&gitOpsDeploymentResource, k8sClient)
Expect(err).To(Succeed())
Expect(k8s.Create(&gitOpsDeploymentResource, k8sClient)).To(Succeed())

expectedConditions := []managedgitopsv1alpha1.GitOpsDeploymentCondition{
{
Type: managedgitopsv1alpha1.GitOpsDeploymentConditionErrorOccurred,
Message: "an unknown error occurred",
Message: "Unable to reconcile the ManagedEnvironment. Verify that the ManagedEnvironment and Secret are correctly defined, and have valid credentials",
Status: managedgitopsv1alpha1.GitOpsConditionStatusTrue,
Reason: managedgitopsv1alpha1.GitopsDeploymentReasonErrorOccurred,
},
Expand All @@ -48,8 +48,7 @@ var _ = Describe("GitOpsDeployment Condition Tests", func() {
)

By("delete the GitOpsDeployment resource")
err = k8s.Delete(&gitOpsDeploymentResource, k8sClient)
Expect(err).To(Succeed())
Expect(k8s.Delete(&gitOpsDeploymentResource, k8sClient)).To(Succeed())
})
})
})

0 comments on commit 88ed290

Please sign in to comment.