Skip to content

Commit 79bb8d0

Browse files
authored
fix(plugins): error not reported in plugin (#1755)
* fix: set HelmReconcileFailedCondition if HelmRelease creation fails for Plugin On-behalf-of: @SAP krzysztof.zagorski@sap.com * fix flaky E2E test from catalog scenario On-behalf-of: @SAP krzysztof.zagorski@sap.com
1 parent 511db1e commit 79bb8d0

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

e2e/catalog/scenarios/catalog_fail.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (s *scenario) ExecuteCPDFailScenario(ctx context.Context, namespace string)
4444
g.Expect(inventory).To(HaveLen(len(catalog.Spec.Sources)), "number of Catalog status inventory map should be equal to catalog sources length")
4545
for groupKey, items := range inventory {
4646
g.Expect(items).To(HaveLen(4), "each Catalog status inventory entry should have 4 items")
47-
s.expectStatusPropagationInCatalogInventory(ctx, groupKey, false)
47+
s.expectStatusPropagationInCatalogInventory(g, ctx, groupKey, false)
4848
}
4949
catalogReady := catalog.Status.GetConditionByType(greenhousemetav1alpha1.ReadyCondition)
5050
g.Expect(catalogReady).ToNot(BeNil(), "the Catalog should have a Ready condition")
@@ -81,7 +81,7 @@ func (s *scenario) ExecuteArtifactFailScenario(ctx context.Context, namespace st
8181
g.Expect(inventory).To(HaveLen(len(catalog.Spec.Sources)), "number of Catalog status inventory map should be equal to catalog sources length")
8282
for groupKey, items := range inventory {
8383
g.Expect(items).To(HaveLen(4), "each Catalog status inventory entry should have 4 items")
84-
s.expectStatusPropagationInCatalogInventory(ctx, groupKey, true)
84+
s.expectStatusPropagationInCatalogInventory(g, ctx, groupKey, true)
8585
}
8686
catalogReady := catalog.Status.GetConditionByType(greenhousemetav1alpha1.ReadyCondition)
8787
g.Expect(catalogReady).ToNot(BeNil(), "the Catalog should have a Ready condition")
@@ -119,7 +119,7 @@ func (s *scenario) ExecuteGitAuthFailScenario(ctx context.Context, namespace str
119119
g.Expect(inventory).To(HaveLen(len(catalog.Spec.Sources)), "number of Catalog status inventory map should be equal to catalog sources length")
120120
for groupKey, items := range inventory {
121121
g.Expect(items).To(HaveLen(4), "each Catalog status inventory entry should have 4 items")
122-
s.expectStatusPropagationInCatalogInventory(ctx, groupKey, true)
122+
s.expectStatusPropagationInCatalogInventory(g, ctx, groupKey, true)
123123
}
124124
catalogReady := catalog.Status.GetConditionByType(greenhousemetav1alpha1.ReadyCondition)
125125
g.Expect(catalogReady).ToNot(BeNil(), "the Catalog should have a Ready condition")

e2e/catalog/scenarios/catalog_success.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (s *scenario) verifySuccess(ctx context.Context, expectedLabels map[string]
7171
g.Expect(inventory).To(HaveLen(len(catalog.Spec.Sources)), "number of Catalog status inventory map should be equal to catalog sources length")
7272
for groupKey, items := range inventory {
7373
g.Expect(items).To(HaveLen(4), "each Catalog status inventory entry should have 4 items")
74-
s.expectStatusPropagationInCatalogInventory(ctx, groupKey, false)
74+
s.expectStatusPropagationInCatalogInventory(g, ctx, groupKey, false)
7575
}
7676
catalogReady := catalog.Status.GetConditionByType(greenhousemetav1alpha1.ReadyCondition)
7777
g.Expect(catalogReady).ToNot(BeNil(), "the Catalog should have a Ready condition")

e2e/catalog/scenarios/scenario.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,12 @@ func checkIfRepositoryIsOverridden(spec greenhousev1alpha1.PluginDefinitionSpec,
357357
}
358358
}
359359

360-
func (s *scenario) expectStatusPropagationInCatalogInventory(ctx context.Context, groupKey string, ignoreNotFound bool) {
360+
func (s *scenario) expectStatusPropagationInCatalogInventory(g Gomega, ctx context.Context, groupKey string, ignoreNotFound bool) {
361361
GinkgoHelper()
362362
catalog := &greenhousev1alpha1.Catalog{}
363-
Expect(s.k8sClient.Get(ctx, client.ObjectKeyFromObject(s.catalog), catalog)).ToNot(HaveOccurred(), "there should be no error getting the Catalog")
363+
g.Expect(s.k8sClient.Get(ctx, client.ObjectKeyFromObject(s.catalog), catalog)).ToNot(HaveOccurred(), "there should be no error getting the Catalog")
364364
groupInventory := catalog.Status.Inventory[groupKey]
365-
Expect(groupInventory).ToNot(BeEmpty(), "the Catalog status inventory for the source should not be empty")
365+
g.Expect(groupInventory).ToNot(BeEmpty(), "the Catalog status inventory for the source should not be empty")
366366
for _, resource := range groupInventory {
367367
kindInventoryStatus := resource.Ready
368368
var fluxObj lifecycle.CatalogObject
@@ -384,9 +384,9 @@ func (s *scenario) expectStatusPropagationInCatalogInventory(ctx context.Context
384384
// ignore not found errors
385385
return
386386
}
387-
Expect(err).ToNot(HaveOccurred(), "there should be no error getting the catalog flux resource: "+fluxObj.GetName())
387+
g.Expect(err).ToNot(HaveOccurred(), "there should be no error getting the catalog flux resource: "+fluxObj.GetName())
388388
fluxCondition := meta.FindStatusCondition(fluxObj.GetConditions(), fluxmeta.ReadyCondition)
389-
Expect(fluxCondition).ToNot(BeNil(), "the underlying resource should have a Ready condition: "+fluxObj.GetName())
390-
Expect(kindInventoryStatus).To(Equal(fluxCondition.Status), "the Catalog inventory status should contain the flux resource condition status")
389+
g.Expect(fluxCondition).ToNot(BeNil(), "the underlying resource should have a Ready condition: "+fluxObj.GetName())
390+
g.Expect(kindInventoryStatus).To(Equal(fluxCondition.Status), "the Catalog inventory status should contain the flux resource condition status")
391391
}
392392
}

internal/controller/plugin/plugin_controller_flux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ func (r *PluginReconciler) ensureHelmRelease(
228228
return controllerutil.SetControllerReference(plugin, release, r.Scheme())
229229
})
230230
if err != nil {
231-
plugin.SetCondition(greenhousemetav1alpha1.FalseCondition(
232-
greenhousev1alpha1.StatusUpToDateCondition, "", "failed to create/update Helm release: "+err.Error()))
231+
plugin.SetCondition(greenhousemetav1alpha1.TrueCondition(
232+
greenhousev1alpha1.HelmReconcileFailedCondition, "", "Failed to create/update Helm release: "+err.Error()))
233233
return err
234234
}
235235
switch result {

0 commit comments

Comments
 (0)