Skip to content

Commit

Permalink
operator: Update dependencies and dev tools (grafana#11232)
Browse files Browse the repository at this point in the history
  • Loading branch information
periklis committed Jan 22, 2024
1 parent 3933910 commit 0dc8f52
Show file tree
Hide file tree
Showing 25 changed files with 307 additions and 376 deletions.
1 change: 1 addition & 0 deletions operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Release 5.8.3

- [11232](https://github.com/grafana/loki/pull/11232) **periklis**: Update dependencies and dev tools
- [11129](https://github.com/grafana/loki/pull/11129) **periklis**: Update deps to secure webhooks for CVE-2023-44487
- [11624](https://github.com/grafana/loki/pull/11624) **xperimental**: React to changes in ConfigMap used for storage CA

Expand Down
2 changes: 1 addition & 1 deletion operator/apis/config/v1/projectconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
cfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
cfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
)

// BuiltInCertManagement is the configuration for the built-in facility to generate and rotate
Expand Down
3 changes: 1 addition & 2 deletions operator/controllers/loki/alertingrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"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/source"

lokiv1 "github.com/grafana/loki/operator/apis/loki/v1"
"github.com/grafana/loki/operator/controllers/loki/internal/lokistack"
Expand Down Expand Up @@ -49,6 +48,6 @@ func (r *AlertingRuleReconciler) Reconcile(ctx context.Context, _ ctrl.Request)
func (r *AlertingRuleReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&lokiv1.AlertingRule{}).
Watches(&source.Kind{Type: &corev1.Namespace{}}, &handler.EnqueueRequestForObject{}, builder.OnlyMetadata).
Watches(&corev1.Namespace{}, &handler.EnqueueRequestForObject{}, builder.OnlyMetadata).
Complete(r)
}
23 changes: 9 additions & 14 deletions operator/controllers/loki/lokistack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

configv1 "github.com/grafana/loki/operator/apis/config/v1"
lokiv1 "github.com/grafana/loki/operator/apis/loki/v1"
Expand Down Expand Up @@ -202,9 +201,9 @@ func (r *LokiStackReconciler) buildController(bld k8s.Builder) error {
Owns(&rbacv1.ClusterRoleBinding{}, updateOrDeleteOnlyPred).
Owns(&rbacv1.Role{}, updateOrDeleteOnlyPred).
Owns(&rbacv1.RoleBinding{}, updateOrDeleteOnlyPred).
Watches(&source.Kind{Type: &corev1.Service{}}, r.enqueueForAlertManagerServices(), createUpdateOrDeletePred).
Watches(&source.Kind{Type: &corev1.Secret{}}, r.enqueueForStorageSecret(), createUpdateOrDeletePred).
Watches(&source.Kind{Type: &corev1.ConfigMap{}}, r.enqueueForStorageCA(), createUpdateOrDeletePred)
Watches(&corev1.Service{}, r.enqueueForAlertManagerServices(), createUpdateOrDeletePred).
Watches(&corev1.Secret{}, r.enqueueForStorageSecret(), createUpdateOrDeletePred).
Watches(&corev1.ConfigMap{}, r.enqueueForStorageCA(), createUpdateOrDeletePred)

if r.FeatureGates.LokiStackAlerts {
bld = bld.Owns(&monitoringv1.PrometheusRule{}, updateOrDeleteOnlyPred)
Expand All @@ -217,19 +216,18 @@ func (r *LokiStackReconciler) buildController(bld k8s.Builder) error {
}

if r.FeatureGates.OpenShift.ClusterTLSPolicy {
bld = bld.Watches(&source.Kind{Type: &openshiftconfigv1.APIServer{}}, r.enqueueAllLokiStacksHandler(), updateOrDeleteOnlyPred)
bld = bld.Watches(&openshiftconfigv1.APIServer{}, r.enqueueAllLokiStacksHandler(), updateOrDeleteOnlyPred)
}

if r.FeatureGates.OpenShift.ClusterProxy {
bld = bld.Watches(&source.Kind{Type: &openshiftconfigv1.Proxy{}}, r.enqueueAllLokiStacksHandler(), updateOrDeleteOnlyPred)
bld = bld.Watches(&openshiftconfigv1.Proxy{}, r.enqueueAllLokiStacksHandler(), updateOrDeleteOnlyPred)
}

return bld.Complete(r)
}

func (r *LokiStackReconciler) enqueueAllLokiStacksHandler() handler.EventHandler {
ctx := context.TODO()
return handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
lokiStacks := &lokiv1.LokiStackList{}
if err := r.Client.List(ctx, lokiStacks); err != nil {
r.Log.Error(err, "Error getting LokiStack resources in event handler")
Expand Down Expand Up @@ -265,8 +263,7 @@ func statusDifferent(e event.UpdateEvent) bool {
}

func (r *LokiStackReconciler) enqueueForAlertManagerServices() handler.EventHandler {
ctx := context.TODO()
return handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
lokiStacks := &lokiv1.LokiStackList{}
if err := r.Client.List(ctx, lokiStacks); err != nil {
r.Log.Error(err, "Error getting LokiStack resources in event handler")
Expand Down Expand Up @@ -298,8 +295,7 @@ func (r *LokiStackReconciler) enqueueForAlertManagerServices() handler.EventHand
}

func (r *LokiStackReconciler) enqueueForStorageSecret() handler.EventHandler {
ctx := context.TODO()
return handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
lokiStacks := &lokiv1.LokiStackList{}
if err := r.Client.List(ctx, lokiStacks); err != nil {
r.Log.Error(err, "Error getting LokiStack resources in event handler")
Expand All @@ -326,8 +322,7 @@ func (r *LokiStackReconciler) enqueueForStorageSecret() handler.EventHandler {
}

func (r *LokiStackReconciler) enqueueForStorageCA() handler.EventHandler {
ctx := context.TODO()
return handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
return handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
lokiStacks := &lokiv1.LokiStackList{}
if err := r.Client.List(ctx, lokiStacks, client.InNamespace(obj.GetNamespace())); err != nil {
r.Log.Error(err, "Error listing LokiStack resources for storage CA update")
Expand Down
13 changes: 6 additions & 7 deletions operator/controllers/loki/lokistack_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/source"

configv1 "github.com/grafana/loki/operator/apis/config/v1"
lokiv1 "github.com/grafana/loki/operator/apis/loki/v1"
Expand Down Expand Up @@ -198,12 +197,12 @@ func TestLokiStackController_RegisterWatchedResources(t *testing.T) {
index int
watchesCallsCount int
featureGates configv1.FeatureGates
src source.Source
src client.Object
pred builder.OwnsOption
}
table := []test{
{
src: &source.Kind{Type: &openshiftconfigv1.APIServer{}},
src: &openshiftconfigv1.APIServer{},
index: 3,
watchesCallsCount: 4,
featureGates: configv1.FeatureGates{
Expand All @@ -214,7 +213,7 @@ func TestLokiStackController_RegisterWatchedResources(t *testing.T) {
pred: updateOrDeleteOnlyPred,
},
{
src: &source.Kind{Type: &openshiftconfigv1.Proxy{}},
src: &openshiftconfigv1.Proxy{},
index: 3,
watchesCallsCount: 4,
featureGates: configv1.FeatureGates{
Expand All @@ -225,21 +224,21 @@ func TestLokiStackController_RegisterWatchedResources(t *testing.T) {
pred: updateOrDeleteOnlyPred,
},
{
src: &source.Kind{Type: &corev1.Service{}},
src: &corev1.Service{},
index: 0,
watchesCallsCount: 3,
featureGates: configv1.FeatureGates{},
pred: createUpdateOrDeletePred,
},
{
src: &source.Kind{Type: &corev1.Secret{}},
src: &corev1.Secret{},
index: 1,
watchesCallsCount: 3,
featureGates: configv1.FeatureGates{},
pred: createUpdateOrDeletePred,
},
{
src: &source.Kind{Type: &corev1.ConfigMap{}},
src: &corev1.ConfigMap{},
index: 2,
watchesCallsCount: 3,
featureGates: configv1.FeatureGates{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/source"

lokiv1 "github.com/grafana/loki/operator/apis/loki/v1"
"github.com/grafana/loki/operator/internal/external/k8s"
Expand Down Expand Up @@ -64,7 +63,7 @@ func (r *LokiStackZoneAwarePodReconciler) SetupWithManager(mgr ctrl.Manager) err
func (r *LokiStackZoneAwarePodReconciler) buildController(bld k8s.Builder) error {
return bld.
Named("ZoneAwarePod").
Watches(&source.Kind{Type: &corev1.Pod{}}, &handler.EnqueueRequestForObject{}, createOrUpdatePodWithLabelPred).
Watches(&corev1.Pod{}, &handler.EnqueueRequestForObject{}, createOrUpdatePodWithLabelPred).
Complete(r)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/source"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/grafana/loki/operator/internal/external/k8s/k8sfakes"
)
Expand All @@ -18,12 +18,12 @@ func TestLokiStackZoneAwarePodController_RegisterWatchedResources(t *testing.T)
type test struct {
index int
watchesCallsCount int
src source.Source
src client.Object
pred builder.OwnsOption
}
table := []test{
{
src: &source.Kind{Type: &corev1.Pod{}},
src: &corev1.Pod{},
index: 0,
watchesCallsCount: 1,
pred: createOrUpdatePodWithLabelPred,
Expand Down
3 changes: 1 addition & 2 deletions operator/controllers/loki/recordingrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"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/source"

lokiv1 "github.com/grafana/loki/operator/apis/loki/v1"
"github.com/grafana/loki/operator/controllers/loki/internal/lokistack"
Expand Down Expand Up @@ -49,6 +48,6 @@ func (r *RecordingRuleReconciler) Reconcile(ctx context.Context, req ctrl.Reques
func (r *RecordingRuleReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&lokiv1.RecordingRule{}).
Watches(&source.Kind{Type: &corev1.Namespace{}}, &handler.EnqueueRequestForObject{}, builder.OnlyMetadata).
Watches(&corev1.Namespace{}, &handler.EnqueueRequestForObject{}, builder.OnlyMetadata).
Complete(r)
}
2 changes: 1 addition & 1 deletion operator/docs/operator/feature-gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ K8S Controller-runtime v1alpha1.ControllerMetrics
</td>
<td>
<em>(Optional)</em>
<p>Metrics contains thw controller metrics configuration</p>
<p>Metrics contains the controller metrics configuration</p>
</td>
</tr>
<tr>
Expand Down
42 changes: 21 additions & 21 deletions operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ go 1.20

require (
github.com/ViaQ/logerr/v2 v2.1.0
github.com/go-logr/logr v1.2.3
github.com/go-logr/logr v1.2.4
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.1
github.com/grafana/loki v1.6.2-0.20230403212622-90888a0cc737
github.com/grafana/loki/operator/apis/loki v0.0.0-00010101000000-000000000000
github.com/imdario/mergo v0.3.13
github.com/maxbrunsfeld/counterfeiter/v6 v6.7.0
github.com/openshift/api v0.0.0-20231106214852-01c8600e6489 // release-4.13
github.com/openshift/library-go v0.0.0-20231115094609-5e510a6e9a52
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.48.0
github.com/openshift/api v0.0.0-20231031181504-3be12e93388f // release-4.14
github.com/openshift/library-go v0.0.0-20231103161458-0ec67489d123
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.67.1
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/common v0.44.0
github.com/prometheus/prometheus v0.42.0
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.26.10
k8s.io/apimachinery v0.26.10
k8s.io/apiserver v0.26.10
k8s.io/client-go v0.26.10
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749
sigs.k8s.io/controller-runtime v0.14.7
k8s.io/api v0.27.7
k8s.io/apimachinery v0.27.7
k8s.io/apiserver v0.27.7
k8s.io/client-go v0.27.7
k8s.io/utils v0.0.0-20230505201702-9f6742963106
sigs.k8s.io/controller-runtime v0.15.3
sigs.k8s.io/yaml v1.3.0
)

Expand Down Expand Up @@ -53,8 +53,8 @@ require (
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/googleapis v1.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand Down Expand Up @@ -121,13 +121,13 @@ require (
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/weaveworks/common v0.0.0-20221201103051-7c2720a9024d // indirect
github.com/weaveworks/promrus v1.2.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
go.etcd.io/etcd/client/v3 v3.5.5 // indirect
go.etcd.io/etcd/api/v3 v3.5.7 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect
go.etcd.io/etcd/client/v3 v3.5.7 // indirect
go.opentelemetry.io/otel v1.11.2 // indirect
go.opentelemetry.io/otel/trace v1.11.2 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go4.org/netipx v0.0.0-20230125063823-8449b0a6169f // indirect
Expand All @@ -142,17 +142,17 @@ require (
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.12.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2 // indirect
google.golang.org/grpc v1.52.3 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.26.10 // indirect
k8s.io/component-base v0.26.10 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221207184640-f3cff1453715 // indirect
k8s.io/apiextensions-apiserver v0.27.7 // indirect
k8s.io/component-base v0.27.7 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
Expand Down
Loading

0 comments on commit 0dc8f52

Please sign in to comment.