Skip to content

Commit

Permalink
fix: Actually write errors and not only error count into status
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jun 2, 2023
1 parent 9e023b7 commit 5940b8a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions e2e/gitops_errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func (suite *GitopsTestSuite) assertErrors(key client.ObjectKey, rstatus metav1.
g.Expect(cr.Errors).To(ConsistOf(expectedErrors))
g.Expect(cr.Warnings).To(ConsistOf(expectedWarnings))

g.Expect(kd.Status.LastDeployResult.Errors).To(Equal(len(expectedErrors)))
g.Expect(kd.Status.LastDeployResult.Warnings).To(Equal(len(expectedWarnings)))
g.Expect(lastDeployResult.Errors).To(ConsistOf(expectedErrors))
g.Expect(lastDeployResult.Warnings).To(ConsistOf(expectedWarnings))
}

func (suite *GitopsTestSuite) TestGitOpsErrors() {
Expand Down
4 changes: 3 additions & 1 deletion e2e/gitops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,9 @@ data:
if obj.Status.LastDeployResult == nil {
return false
}
return obj.Status.LastDeployResult.GitInfo.Commit == getHeadRevision(suite.T(), p)
ldr, err := obj.Status.GetLastDeployResult()
g.Expect(err).To(Succeed())
return ldr.GitInfo.Commit == getHeadRevision(suite.T(), p)
}, timeout, time.Second).Should(BeTrue())

suite.Run("cm1 and cm2 were not deleted", func() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/kluctl_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,6 @@ func (pt *preparedTarget) exportCommandResultMetricsToProm(summary *result.Comma
internal_metrics.NewKluctlNumberOfDeletedObjects(pt.pp.obj.Namespace, pt.pp.obj.Name).Set(float64(summary.DeletedObjects))
internal_metrics.NewKluctlNumberOfChangedObjects(pt.pp.obj.Namespace, pt.pp.obj.Name).Set(float64(summary.ChangedObjects))
internal_metrics.NewKluctlNumberOfOrphanObjects(pt.pp.obj.Namespace, pt.pp.obj.Name).Set(float64(summary.OrphanObjects))
internal_metrics.NewKluctlNumberOfWarnings(pt.pp.obj.Namespace, pt.pp.obj.Name, summary.Command.Command).Set(float64(summary.Warnings))
internal_metrics.NewKluctlNumberOfErrors(pt.pp.obj.Namespace, pt.pp.obj.Name, summary.Command.Command).Set(float64(summary.Errors))
internal_metrics.NewKluctlNumberOfWarnings(pt.pp.obj.Namespace, pt.pp.obj.Name, summary.Command.Command).Set(float64(len(summary.Warnings)))
internal_metrics.NewKluctlNumberOfErrors(pt.pp.obj.Namespace, pt.pp.obj.Name, summary.Command.Command).Set(float64(len(summary.Errors)))
}
4 changes: 2 additions & 2 deletions pkg/controllers/kluctldeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ func (r *KluctlDeploymentReconciler) buildFinalStatus(ctx context.Context, obj *
}
}

deployOk := lastDeployResult != nil && lastDeployResult.Errors == 0
pruneOk := lastPruneResult != nil && lastPruneResult.Errors == 0
deployOk := lastDeployResult != nil && len(lastDeployResult.Errors) == 0
pruneOk := lastPruneResult != nil && len(lastPruneResult.Errors) == 0
validateOk := lastValidateResult != nil && len(lastValidateResult.Errors) == 0 && lastValidateResult.Ready

if !obj.Spec.Prune {
Expand Down
9 changes: 5 additions & 4 deletions pkg/types/result/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ type CommandResultSummary struct {
ChangedObjects int `json:"changedObjects"`
OrphanObjects int `json:"orphanObjects"`
DeletedObjects int `json:"deletedObjects"`
Errors int `json:"errors"`
Warnings int `json:"warnings"`

Errors []DeploymentError `json:"errors"`
Warnings []DeploymentError `json:"warnings"`

TotalChanges int `json:"totalChanges"`
}
Expand Down Expand Up @@ -73,8 +74,8 @@ func (cr *CommandResult) BuildSummary() *CommandResultSummary {
ChangedObjects: count(func(o ResultObject) bool { return len(o.Changes) != 0 }),
OrphanObjects: count(func(o ResultObject) bool { return o.Orphan }),
DeletedObjects: count(func(o ResultObject) bool { return o.Deleted }),
Errors: len(cr.Errors),
Warnings: len(cr.Warnings),
Errors: cr.Errors,
Warnings: cr.Warnings,
}
for _, o := range cr.Objects {
ret.TotalChanges += len(o.Changes)
Expand Down
10 changes: 10 additions & 0 deletions pkg/types/result/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5940b8a

Please sign in to comment.