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

CA-388587: Fix filtering the xapi-clusterd db and log any errors #67

Merged
merged 5 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 0 additions & 5 deletions tests/unit/test_filter_xapi_clusterd_db.py
bernhardkaindl marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@
import json
import os

import pytest


# Minimal example of a xapi-clusterd/db file, with sensitive data
# BUG: The new cluster_config has no "pems" key, so the filter has to be updated
Expand Down Expand Up @@ -200,7 +198,6 @@ def test_remove_token(isolated_bugtool):
assert_filter_xapi_clusterd_db(isolated_bugtool, ORIGINAL, expected_json)


@pytest.mark.xfail(reason="bugtool currently fails to handle missing authkey")
def test_no_authkey(isolated_bugtool):
"""Assert that filter_xapi_clusterd_db() handles missing authkey"""

Expand All @@ -220,7 +217,6 @@ def remove_authkey(json_data):
)


@pytest.mark.xfail(reason="bugtool currently fails to handle missing pems")
def test_no_pems(isolated_bugtool):
"""Assert that filter_xapi_clusterd_db() handles missing pems"""

Expand All @@ -240,7 +236,6 @@ def remove_pems(json_data):
)


@pytest.mark.xfail(reason="bugtool currently fails to handle missing pems.blobs")
def test_no_blobs(isolated_bugtool):
"""Assert that filter_xapi_clusterd_db() handles missing blobs"""

Expand Down
11 changes: 7 additions & 4 deletions xen-bugtool
Original file line number Diff line number Diff line change
Expand Up @@ -1502,15 +1502,18 @@ def filter_xenstore_secrets(s, state):
def filter_xapi_clusterd_db(cap):
clusterd_data = {}

try:
try: # pylint: disable=too-many-try-statements
with open(XAPI_CLUSTERD, 'r') as f:
clusterd_data = json.load(f)

config_keys = ['cluster_config', 'old_cluster_config']
for config_key in config_keys:
if config_key in clusterd_data:
clusterd_data[config_key]['pems']['blobs'] = "REMOVED"
edwintorok marked this conversation as resolved.
Show resolved Hide resolved
clusterd_data[config_key]['authkey'] = "REMOVED"
if config_key in clusterd_data.keys():
conf = clusterd_data[config_key]
if "pems" in conf and "blobs" in conf["pems"]:
conf["pems"]["blobs"] = "REMOVED"
if "authkey" in conf:
conf["authkey"] = "REMOVED"

if "token" in clusterd_data:
clusterd_data["token"] = "REMOVED"
Expand Down
Loading