Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loggingroute notifications for changes in the logging resource status #1640

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions controllers/logging/loggingroute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ import (
"github.com/go-logr/logr"
apitypes "k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/kube-logging/logging-operator/pkg/resources/fluentbit"
Expand Down Expand Up @@ -116,6 +114,6 @@ func SetupLoggingRouteWithManager(mgr ctrl.Manager, logger logr.Logger) error {

return ctrl.NewControllerManagedBy(mgr).
For(&loggingv1beta1.LoggingRoute{}).
Watches(&loggingv1beta1.Logging{}, loggingRequestMapper, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Watches(&loggingv1beta1.Logging{}, loggingRequestMapper).
Complete(NewLoggingRouteReconciler(mgr.GetClient(), logger))
}
13 changes: 1 addition & 12 deletions pkg/resources/fluentbit/tenants.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"

"emperror.dev/errors"
"golang.org/x/exp/slices"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -71,19 +70,9 @@ func FindTenants(ctx context.Context, target metav1.LabelSelector, reader client
}
}

sort.Slice(tenants, func(i, j int) bool {
sort.SliceStable(tenants, func(i, j int) bool {
return tenants[i].Name < tenants[j].Name
})
// Make sure our tenant list is stable
slices.SortStableFunc(tenants, func(a, b Tenant) int {
if a.Name < b.Name {
return -1
}
if a.Name == b.Name {
return 0
}
return 1
})

return tenants, nil
}
Expand Down
Loading