Skip to content

Commit

Permalink
chore: address review comments and make test more robust
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Wilcsinszky <[email protected]>
  • Loading branch information
pepov committed Jul 26, 2023
1 parent 136d078 commit 4574b11
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
10 changes: 8 additions & 2 deletions controllers/logging/logging_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,14 @@ func TestLogginResourcesWithNonUniqueLoggingRefs(t *testing.T) {
g.Eventually(getLoggingProblems(logging2)).WithPolling(time.Second).WithTimeout(5 * time.Second).Should(gomega.ContainElement(gomega.ContainSubstring("Deprecated")))
g.Eventually(getLoggingProblems(logging3)).WithPolling(time.Second).WithTimeout(5 * time.Second).Should(gomega.BeEmpty())

logging1.Spec.ClusterDomain = utils.StringPointer("change something to trigger new reconciliation")
g.Expect(mgr.GetClient().Update(context.TODO(), logging1)).Should(gomega.Succeed())
g.Eventually(func() error {
l := &v1beta1.Logging{}
if err := mgr.GetClient().Get(context.TODO(), client.ObjectKeyFromObject(logging1), l); err != nil {
return err
}
l.Spec.ErrorOutputRef = "trigger reconcile"
return mgr.GetClient().Update(context.TODO(), l)
}).WithPolling(time.Second).WithTimeout(5 * time.Second).Should(gomega.Succeed())
g.Eventually(getLoggingProblems(logging1)).WithPolling(time.Second).WithTimeout(5 * time.Second).Should(gomega.ContainElement(gomega.ContainSubstring("Deprecated")))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/model/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func NewValidationReconciler(
resources.Logging.Status.Problems = nil

loggingsForTheSameRef := make([]string, 0)
for _, l := range resources.AllLoggings.Items {
for _, l := range resources.AllLoggings {
if l.Name == resources.Logging.Name {
continue
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/resources/model/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ func (r LoggingResourceRepository) LoggingResourcesFor(ctx context.Context, logg

var err error

res.AllLoggings = v1beta1.LoggingList{}
if err := r.Client.List(ctx, &res.AllLoggings); err != nil {
allLoggings := &v1beta1.LoggingList{}
if err := r.Client.List(ctx, allLoggings); err != nil {
errs = errors.Append(errs, err)
}
res.AllLoggings = allLoggings.Items

res.Fluentd.ClusterFlows, err = r.ClusterFlowsFor(ctx, logging)
errs = errors.Append(errs, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/model/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

type LoggingResources struct {
AllLoggings v1beta1.LoggingList
AllLoggings []v1beta1.Logging
Logging v1beta1.Logging
Fluentd FluentdLoggingResources
SyslogNG SyslogNGLoggingResources
Expand Down

0 comments on commit 4574b11

Please sign in to comment.