Skip to content

Commit 5bd8bff

Browse files
committed
chore(refactor): rename aggregationpolicies to loggingroutes
Signed-off-by: Peter Wilcsinszky <[email protected]>
1 parent a9ef6e1 commit 5bd8bff

File tree

17 files changed

+291
-300
lines changed

17 files changed

+291
-300
lines changed

.idea/logging-operator.iml

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/logging-operator/crds/logging.banzaicloud.io_aggregationpolicies.yaml charts/logging-operator/crds/logging.banzaicloud.io_loggingroutes.yaml

+10-12
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ metadata:
66
annotations:
77
controller-gen.kubebuilder.io/version: v0.6.0
88
creationTimestamp: null
9-
name: aggregationpolicies.logging.banzaicloud.io
9+
name: loggingroutes.logging.banzaicloud.io
1010
spec:
1111
group: logging.banzaicloud.io
1212
names:
1313
categories:
1414
- logging-all
15-
kind: AggregationPolicy
16-
listKind: AggregationPolicyList
17-
plural: aggregationpolicies
15+
kind: LoggingRoute
16+
listKind: LoggingRouteList
17+
plural: loggingroutes
1818
shortNames:
19-
- agp
20-
singular: aggregationpolicy
19+
- lr
20+
singular: loggingroute
2121
scope: Cluster
2222
versions:
2323
- additionalPrinterColumns:
@@ -37,11 +37,9 @@ spec:
3737
type: object
3838
spec:
3939
properties:
40-
agent:
40+
source:
4141
type: string
42-
loggingRef:
43-
type: string
44-
watchNamespaceTargets:
42+
targets:
4543
properties:
4644
matchExpressions:
4745
items:
@@ -65,8 +63,8 @@ spec:
6563
type: object
6664
type: object
6765
required:
68-
- loggingRef
69-
- watchNamespaceTargets
66+
- source
67+
- targets
7068
type: object
7169
status:
7270
properties:

charts/logging-operator/templates/clusterrole.yaml

+16-16
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,13 @@ rules:
237237
- apiGroups:
238238
- logging.banzaicloud.io
239239
resources:
240-
- aggregationpolicies
240+
- clusterflows
241+
- clusteroutputs
242+
- flows
243+
- fluentbitagents
244+
- loggings
245+
- nodeagents
246+
- outputs
241247
verbs:
242248
- create
243249
- delete
@@ -249,21 +255,21 @@ rules:
249255
- apiGroups:
250256
- logging.banzaicloud.io
251257
resources:
252-
- aggregationpolicies/status
258+
- clusterflows/status
259+
- clusteroutputs/status
260+
- flows/status
261+
- fluentbitagents/status
262+
- loggings/status
263+
- nodeagents/status
264+
- outputs/status
253265
verbs:
254266
- get
255267
- patch
256268
- update
257269
- apiGroups:
258270
- logging.banzaicloud.io
259271
resources:
260-
- clusterflows
261-
- clusteroutputs
262-
- flows
263-
- fluentbitagents
264-
- loggings
265-
- nodeagents
266-
- outputs
272+
- loggingroutes
267273
verbs:
268274
- create
269275
- delete
@@ -275,13 +281,7 @@ rules:
275281
- apiGroups:
276282
- logging.banzaicloud.io
277283
resources:
278-
- clusterflows/status
279-
- clusteroutputs/status
280-
- flows/status
281-
- fluentbitagents/status
282-
- loggings/status
283-
- nodeagents/status
284-
- outputs/status
284+
- loggingroutes/status
285285
verbs:
286286
- get
287287
- patch

config/crd/bases/logging.banzaicloud.io_aggregationpolicies.yaml config/crd/bases/logging.banzaicloud.io_loggingroutes.yaml

+10-12
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ metadata:
66
annotations:
77
controller-gen.kubebuilder.io/version: v0.6.0
88
creationTimestamp: null
9-
name: aggregationpolicies.logging.banzaicloud.io
9+
name: loggingroutes.logging.banzaicloud.io
1010
spec:
1111
group: logging.banzaicloud.io
1212
names:
1313
categories:
1414
- logging-all
15-
kind: AggregationPolicy
16-
listKind: AggregationPolicyList
17-
plural: aggregationpolicies
15+
kind: LoggingRoute
16+
listKind: LoggingRouteList
17+
plural: loggingroutes
1818
shortNames:
19-
- agp
20-
singular: aggregationpolicy
19+
- lr
20+
singular: loggingroute
2121
scope: Cluster
2222
versions:
2323
- additionalPrinterColumns:
@@ -37,11 +37,9 @@ spec:
3737
type: object
3838
spec:
3939
properties:
40-
agent:
40+
source:
4141
type: string
42-
loggingRef:
43-
type: string
44-
watchNamespaceTargets:
42+
targets:
4543
properties:
4644
matchExpressions:
4745
items:
@@ -65,8 +63,8 @@ spec:
6563
type: object
6664
type: object
6765
required:
68-
- loggingRef
69-
- watchNamespaceTargets
66+
- source
67+
- targets
7068
type: object
7169
status:
7270
properties:

config/rbac/role.yaml

+16-16
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,13 @@ rules:
237237
- apiGroups:
238238
- logging.banzaicloud.io
239239
resources:
240-
- aggregationpolicies
240+
- clusterflows
241+
- clusteroutputs
242+
- flows
243+
- fluentbitagents
244+
- loggings
245+
- nodeagents
246+
- outputs
241247
verbs:
242248
- create
243249
- delete
@@ -249,21 +255,21 @@ rules:
249255
- apiGroups:
250256
- logging.banzaicloud.io
251257
resources:
252-
- aggregationpolicies/status
258+
- clusterflows/status
259+
- clusteroutputs/status
260+
- flows/status
261+
- fluentbitagents/status
262+
- loggings/status
263+
- nodeagents/status
264+
- outputs/status
253265
verbs:
254266
- get
255267
- patch
256268
- update
257269
- apiGroups:
258270
- logging.banzaicloud.io
259271
resources:
260-
- clusterflows
261-
- clusteroutputs
262-
- flows
263-
- fluentbitagents
264-
- loggings
265-
- nodeagents
266-
- outputs
272+
- loggingroutes
267273
verbs:
268274
- create
269275
- delete
@@ -275,13 +281,7 @@ rules:
275281
- apiGroups:
276282
- logging.banzaicloud.io
277283
resources:
278-
- clusterflows/status
279-
- clusteroutputs/status
280-
- flows/status
281-
- fluentbitagents/status
282-
- loggings/status
283-
- nodeagents/status
284-
- outputs/status
284+
- loggingroutes/status
285285
verbs:
286286
- get
287287
- patch

config/samples/fluentbit-ns-routing/logging/tenant-infra-logging.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ spec:
4848
connectTimeout: 2
4949
---
5050
apiVersion: logging.banzaicloud.io/v1beta1
51-
kind: AggregationPolicy
51+
kind: LoggingRoute
5252
metadata:
5353
name: tenants
5454
spec:
55-
loggingRef: infra
56-
watchNamespaceTargets:
55+
source: infra
56+
targets:
5757
matchExpressions:
5858
- key: tenant
5959
operator: Exists

controllers/logging/logging_controller.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,12 @@ func (r *LoggingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
227227
return ctrl.Result{}, errors.New("fluentbit has to be removed from the logging resource before the new FluentbitAgent can be reconciled")
228228
}
229229
l := log.WithName("fluentbit")
230+
aps, err := r.loggingRoutes(ctx, logging.Name)
231+
if err != nil {
232+
return ctrl.Result{}, err
233+
}
230234
for _, f := range loggingResources.Fluentbits {
231235
f := f
232-
aps, err := r.aggregationPoliciesForAgent(ctx, logging.Name, f.Name)
233-
if err != nil {
234-
return ctrl.Result{}, err
235-
}
236236
reconcilers = append(reconcilers, fluentbit.New(
237237
r.Client,
238238
l.WithValues("fluentbitagent", f.Name),
@@ -278,15 +278,15 @@ func (r *LoggingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
278278
return ctrl.Result{}, nil
279279
}
280280

281-
func (r *LoggingReconciler) aggregationPoliciesForAgent(ctx context.Context, logging, agent string) (aps []loggingv1beta1.AggregationPolicy, err error) {
282-
apList := &loggingv1beta1.AggregationPolicyList{}
281+
func (r *LoggingReconciler) loggingRoutes(ctx context.Context, logging string) (aps []loggingv1beta1.LoggingRoute, err error) {
282+
apList := &loggingv1beta1.LoggingRouteList{}
283283
err = r.Client.List(ctx, apList)
284284
if err != nil {
285-
err = errors.WrapIf(err, "listing aggregation policies")
285+
err = errors.WrapIf(err, "listing logging routes")
286286
return
287287
}
288288
for _, ap := range apList.Items {
289-
if ap.Spec.LoggingRef == logging && (ap.Spec.Agent == "" || ap.Spec.Agent == agent) {
289+
if ap.Spec.Source == logging {
290290
aps = append(aps, ap)
291291
}
292292
}
@@ -453,6 +453,8 @@ func SetupLoggingWithManager(mgr ctrl.Manager, logger logr.Logger) *ctrl.Builder
453453
return reconcileRequestsForLoggingRef(loggingList.Items, o.Spec.LoggingRef)
454454
case *loggingv1beta1.FluentbitAgent:
455455
return reconcileRequestsForLoggingRef(loggingList.Items, o.Spec.LoggingRef)
456+
case *loggingv1beta1.LoggingRoute:
457+
return reconcileRequestsForLoggingRef(loggingList.Items, o.Spec.Source)
456458
case *corev1.Secret:
457459
r := regexp.MustCompile(`^logging\.banzaicloud\.io/(.*)`)
458460
var requestList []reconcile.Request
@@ -502,7 +504,7 @@ func SetupLoggingWithManager(mgr ctrl.Manager, logger logr.Logger) *ctrl.Builder
502504
Watches(&loggingv1beta1.SyslogNGOutput{}, requestMapper).
503505
Watches(&loggingv1beta1.SyslogNGFlow{}, requestMapper).
504506
Watches(&corev1.Secret{}, requestMapper).
505-
Watches(&loggingv1beta1.AggregationPolicy{}, requestMapper)
507+
Watches(&loggingv1beta1.LoggingRoute{}, requestMapper)
506508

507509
// TODO remove with the next major release
508510
if os.Getenv("ENABLE_NODEAGENT_CRD") != "" {

controllers/logging/aggregationpolicy_controller.go controllers/logging/loggingroute_controller.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,36 @@ import (
2828
loggingv1beta1 "github.com/kube-logging/logging-operator/pkg/sdk/logging/api/v1beta1"
2929
)
3030

31-
func NewAggregationPolicyReconciler(client client.Client, log logr.Logger) *AggregationPolicyReconciler {
32-
return &AggregationPolicyReconciler{
31+
func NewLoggingRouteReconciler(client client.Client, log logr.Logger) *LoggingRouteReconciler {
32+
return &LoggingRouteReconciler{
3333
Client: client,
3434
Log: log,
3535
}
3636
}
3737

38-
// AggregationPolicyReconciler reconciles an AggregationPolicy object
39-
type AggregationPolicyReconciler struct {
38+
// LoggingRouteReconciler reconciles an LoggingRoute object
39+
type LoggingRouteReconciler struct {
4040
client.Client
4141
Log logr.Logger
4242
}
4343

44-
// +kubebuilder:rbac:groups=logging.banzaicloud.io,resources=aggregationpolicies,verbs=get;list;watch;create;update;patch;delete
45-
// +kubebuilder:rbac:groups=logging.banzaicloud.io,resources=aggregationpolicies/status,verbs=get;update;patch
44+
// +kubebuilder:rbac:groups=logging.banzaicloud.io,resources=loggingroutes,verbs=get;list;watch;create;update;patch;delete
45+
// +kubebuilder:rbac:groups=logging.banzaicloud.io,resources=loggingroutes/status,verbs=get;update;patch
4646

47-
// Reconcile aggregation policies
48-
func (r *AggregationPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
49-
var agrPol loggingv1beta1.AggregationPolicy
50-
if err := r.Client.Get(ctx, req.NamespacedName, &agrPol); err != nil {
47+
// Reconcile routes between logging domains
48+
func (r *LoggingRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
49+
var loggingRoute loggingv1beta1.LoggingRoute
50+
if err := r.Client.Get(ctx, req.NamespacedName, &loggingRoute); err != nil {
5151
return reconcile.Result{}, client.IgnoreNotFound(err)
5252
}
5353

54-
tenants, err := fluentbit.FindTenants(ctx, agrPol.Spec.WatchNamespaceTargets, r.Client)
54+
tenants, err := fluentbit.FindTenants(ctx, loggingRoute.Spec.Targets, r.Client)
5555
if err != nil {
5656
return ctrl.Result{}, errors.WrapIf(err, "listing tenants")
5757
}
5858

5959
var problems []string
60-
agrPol.Status.Tenants = make([]loggingv1beta1.Tenant, 0)
60+
loggingRoute.Status.Tenants = make([]loggingv1beta1.Tenant, 0)
6161

6262
for _, t := range tenants {
6363
valid := true
@@ -74,13 +74,13 @@ func (r *AggregationPolicyReconciler) Reconcile(ctx context.Context, req ctrl.Re
7474
Namespaces: t.Namespaces,
7575
}
7676
if valid {
77-
agrPol.Status.Tenants = append(agrPol.Status.Tenants, tenantStatus)
77+
loggingRoute.Status.Tenants = append(loggingRoute.Status.Tenants, tenantStatus)
7878
}
7979
}
8080

81-
agrPol.Status.Problems = problems
81+
loggingRoute.Status.Problems = problems
8282

83-
err = r.Status().Update(ctx, &agrPol)
83+
err = r.Status().Update(ctx, &loggingRoute)
8484
if err != nil {
8585
return ctrl.Result{}, err
8686
}

docs/configuration/crds/v1beta1/_index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ For more information please click on the name
1212
| **[](../extensions/v1alpha1/filetailer/)** | | extensions |
1313
| **[HostTailer](../extensions/v1alpha1/hosttailer_types/)** | HostTailer's main goal is to tail custom files and transmit their changes to stdout. This way the logging-operator is able to process them. | extensions |
1414
| **[](../extensions/v1alpha1/systemdtailer/)** | | extensions |
15-
| **[AggregationPolicySpec](aggregationpolicy_types/)** | | v1beta1 |
1615
| **[ClusterFlow](clusterflow_types/)** | ClusterFlow is the Schema for the clusterflows API | v1beta1 |
1716
| **[ClusterOutput](clusteroutput_types/)** | ClusterOutput is the Schema for the clusteroutputs API | v1beta1 |
1817
| **[Common](common_types/)** | ImageSpec Metrics Security | v1beta1 |
@@ -21,6 +20,7 @@ For more information please click on the name
2120
| **[FluentbitSpec](fluentbit_types/)** | FluentbitSpec defines the desired state of FluentbitAgent | v1beta1 |
2221
| **[FluentdSpec](fluentd_types/)** | FluentdSpec defines the desired state of Fluentd | v1beta1 |
2322
| **[Logging](logging_types/)** | Logging system configuration | v1beta1 |
23+
| **[LoggingRouteSpec](loggingroute_types/)** | | v1beta1 |
2424
| **[_hugoNodeAgent](node_agent_types/)** | | v1beta1 |
2525
| **[OutputSpec](output_types/)** | OutputSpec defines the desired state of Output | v1beta1 |
2626
| **[SyslogNGClusterFlow](syslogng_clusterflow_types/)** | SyslogNGClusterFlow is the Schema for the syslog-ng clusterflows API | v1beta1 |

0 commit comments

Comments
 (0)