Skip to content

Commit 025aae8

Browse files
committed
Merge branch 'improvement/ensure-fluent-bit-restarted' into q/133.0
2 parents cecaff4 + fa59b39 commit 025aae8

File tree

6 files changed

+41
-9
lines changed

6 files changed

+41
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
- Implement ability to add certificates to fluent-bit by mounting a fluent-bit-certs secret
6565
(PR[#4812](https://github.com/scality/metalk8s/pull/4812))
6666

67+
- Ensure fluent-bit pods are restarted when its configmap or secret is modified
68+
(PR[#4834](https://github.com/scality/metalk8s/pull/4834))
69+
6770
### Bug Fixes
6871

6972
- Fix a bug where part of the upgrade process would silently be skipped

charts/fluent-bit.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ image:
55
existingConfigMap: fluent-bit
66

77
podAnnotations:
8-
prometheus.io/scrape: "true"
9-
prometheus.io/port: "2020"
10-
prometheus.io/path: /api/v1/metrics/prometheus
8+
checksum/config: '__slot__:salt:metalk8s_kubernetes.get_object_digest(kind="ConfigMap", apiVersion="v1", namespace="metalk8s-logging", name="fluent-bit", path="data:fluent-bit.conf")'
9+
checksum/secret: '__slot__:salt:metalk8s_kubernetes.get_object_digest(kind="Secret", apiVersion="v1", namespace="metalk8s-logging", name="fluent-bit-certs", path="data", ignore_not_found=True)'
1110

1211
resources: '__var__(fluent_bit.spec.deployment.resources)'
1312

salt/_modules/metalk8s_kubernetes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,9 @@ def list_objects(
410410
return result.to_dict()["items"]
411411

412412

413-
def get_object_digest(path=None, checksum="sha256", *args, **kwargs):
413+
def get_object_digest(
414+
path=None, checksum="sha256", ignore_not_found=False, *args, **kwargs
415+
):
414416
"""
415417
Helper to get the digest of one kubernetes object or from a specific key
416418
of this object using a path
@@ -432,7 +434,11 @@ def get_object_digest(path=None, checksum="sha256", *args, **kwargs):
432434
obj = salt.utils.data.traverse_dict_and_list(obj, path, delimiter=":")
433435

434436
if not obj:
435-
raise CommandExecutionError(f'Unable to find key "{path}" in the object')
437+
if not ignore_not_found:
438+
raise CommandExecutionError(
439+
f'Unable to find key "{path}" in the object'
440+
)
441+
return ""
436442

437443
if isinstance(obj, dict):
438444
obj = json.dumps(obj, sort_keys=True)

salt/metalk8s/addons/logging/fluent-bit/deployed/chart.sls

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,10 +1694,11 @@ spec:
16941694
template:
16951695
metadata:
16961696
annotations:
1697-
checksum/config: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
1698-
prometheus.io/path: /api/v1/metrics/prometheus
1699-
prometheus.io/port: '2020'
1700-
prometheus.io/scrape: 'true'
1697+
checksum/config: __slot__:salt:metalk8s_kubernetes.get_object_digest(kind="ConfigMap",
1698+
apiVersion="v1", namespace="metalk8s-logging", name="fluent-bit", path="data:fluent-bit.conf")
1699+
checksum/secret: __slot__:salt:metalk8s_kubernetes.get_object_digest(kind="Secret",
1700+
apiVersion="v1", namespace="metalk8s-logging", name="fluent-bit-certs",
1701+
path="data", ignore_not_found=True)
17011702
labels:
17021703
app.kubernetes.io/instance: fluent-bit
17031704
app.kubernetes.io/name: fluent-bit

salt/metalk8s/addons/logging/fluent-bit/deployed/secret.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Create metalk8s-fluent-bit-certs Secret:
1919
metadata:
2020
name: fluent-bit-certs
2121
namespace: metalk8s-logging
22+
data: {}
2223

2324
{%- else %}
2425

salt/tests/unit/modules/files/test_metalk8s_kubernetes.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,28 @@ get_object_digest:
702702
raises: True
703703
result: 'Unable to find key "metadata:invalid:path" in the object'
704704

705+
# ignore_not_found = true and path points to an empty dict
706+
- obj:
707+
apiVersion: v1
708+
kind: Secret
709+
metadata:
710+
name: my_secret
711+
data: {}
712+
path: 'data'
713+
ignore_not_found: True
714+
result: ''
715+
716+
# ignore_not_found = true but there is a typo in the path
717+
- obj:
718+
apiVersion: v1
719+
kind: Secret
720+
metadata:
721+
name: my_secret
722+
data: {}
723+
path: 'daat'
724+
ignore_not_found: True
725+
result: ''
726+
705727
check_object_ready:
706728
# Simple Pod Ready
707729
- obj:

0 commit comments

Comments
 (0)