-
Notifications
You must be signed in to change notification settings - Fork 4
MLE-25548: Support update and hot reload for Fluent-Bit #116
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
Changes from 5 commits
f609517
0bc8ea4
e7cd350
9c09682
949a7b0
8bc6b3c
51281c4
59a0aab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import ( | |
| "embed" | ||
| "strings" | ||
|
|
||
| "github.com/cisco-open/k8s-objectmatcher/patch" | ||
| "github.com/marklogic/marklogic-operator-kubernetes/pkg/result" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/apimachinery/pkg/api/errors" | ||
|
|
@@ -44,6 +45,32 @@ func (oc *OperatorContext) ReconcileConfigMap() result.ReconcileResult { | |
| logger.Error(err, "MarkLogic scripts configmap creation is failed") | ||
| return result.Error(err) | ||
| } | ||
| } else { | ||
| // ConfigMap exists, check if it needs to be updated | ||
| desiredConfigMap := oc.generateConfigMapDef(objectMeta, marklogicServerAsOwner(cr)) | ||
|
|
||
| patchDiff, err := patch.DefaultPatchMaker.Calculate(configmap, desiredConfigMap, | ||
| patch.IgnoreStatusFields(), | ||
| patch.IgnoreVolumeClaimTemplateTypeMetaAndStatus(), | ||
| patch.IgnoreField("kind")) | ||
| if err != nil { | ||
| logger.Error(err, "Error calculating patch for MarkLogic ConfigMap") | ||
| return result.Error(err) | ||
| } | ||
|
|
||
| if !patchDiff.IsEmpty() { | ||
| logger.Info("MarkLogic ConfigMap data has changed, updating it") | ||
| configmap.Data = desiredConfigMap.Data | ||
|
||
| if err := patch.DefaultAnnotator.SetLastAppliedAnnotation(configmap); err != nil { | ||
| logger.Error(err, "Failed to set last applied annotation for MarkLogic ConfigMap") | ||
| } | ||
| err = client.Update(oc.Ctx, configmap) | ||
| if err != nil { | ||
| logger.Error(err, "MarkLogic ConfigMap update failed") | ||
| return result.Error(err) | ||
| } | ||
| logger.Info("MarkLogic ConfigMap update is successful") | ||
| } | ||
pengzhouml marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return result.Continue() | ||
|
|
@@ -78,6 +105,32 @@ func (oc *OperatorContext) ReconcileFluentBitConfigMap() result.ReconcileResult | |
| logger.Error(err, "Fluent Bit configmap creation is failed") | ||
| return result.Error(err) | ||
| } | ||
| } else { | ||
| // ConfigMap exists, check if it needs to be updated | ||
| desiredConfigMap := oc.generateFluentBitDef(objectMeta, marklogicServerAsOwner(cr)) | ||
rwinieski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| patchDiff, err := patch.DefaultPatchMaker.Calculate(configmap, desiredConfigMap, | ||
| patch.IgnoreStatusFields(), | ||
| patch.IgnoreVolumeClaimTemplateTypeMetaAndStatus(), | ||
| patch.IgnoreField("kind")) | ||
| if err != nil { | ||
| logger.Error(err, "Error calculating patch for Fluent Bit ConfigMap") | ||
| return result.Error(err) | ||
| } | ||
|
|
||
| if !patchDiff.IsEmpty() { | ||
| logger.Info("Fluent Bit ConfigMap data has changed, updating it") | ||
| configmap.Data = desiredConfigMap.Data | ||
|
||
| if err := patch.DefaultAnnotator.SetLastAppliedAnnotation(configmap); err != nil { | ||
| logger.Error(err, "Failed to set last applied annotation for Fluent Bit ConfigMap") | ||
| } | ||
| err = client.Update(oc.Ctx, configmap) | ||
| if err != nil { | ||
| logger.Error(err, "Fluent Bit ConfigMap update failed") | ||
| return result.Error(err) | ||
| } | ||
| logger.Info("Fluent Bit ConfigMap update is successful") | ||
| } | ||
pengzhouml marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| return result.Continue() | ||
|
|
@@ -165,10 +218,14 @@ func (oc *OperatorContext) getFluentBitData() map[string]string { | |
| log_level: info | ||
| daemon: off | ||
| parsers_file: parsers.yaml | ||
| http_server: on | ||
| http_listen: 0.0.0.0 | ||
pengzhouml marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| http_port: 2020 | ||
| hot_reload: on | ||
| storage.metrics: on | ||
|
|
||
| pipeline: | ||
| inputs:` | ||
| // Add INPUT sections based on enabled log types | ||
| if strings.TrimSpace(oc.MarklogicGroup.Spec.LogCollection.Inputs) != "" { | ||
| fluentBitData["fluent-bit.yaml"] += "\n" + normalizeYAMLIndentation(oc.MarklogicGroup.Spec.LogCollection.Inputs, 4, 6) | ||
| } else { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.