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

Configure rbd-mirror debug logs dynamically #1346

Merged
merged 6 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 28 additions & 0 deletions test/addons/rbd-mirror/start
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ def fetch_secret_info(cluster):
return info


def enable_rbd_mirror_debug_logs(cluster):
print(f"Enable rbd-mirror debug logs in cluster '{cluster}'")
for who in "client.rbd-mirror.a", "client.rbd-mirror-peer":
ceph.set_config(cluster, who, "debug_ms", "1")
ceph.set_config(cluster, who, "debug_rbd", "15")
ceph.set_config(cluster, who, "debug_rbd_mirror", "30")
ceph.set_config(cluster, who, "log_file", "/var/log/ceph/$cluster-$name.log")
ceph.set_config(cluster, "mgr", "mgr/rbd_support/log_level", "debug")


def disable_rbd_mirror_debug_logs(cluster):
print(f"Disable rbd-mirror debug logs in cluster '{cluster}'")
for who in "client.rbd-mirror.a", "client.rbd-mirror-peer":
ceph.rm_config(cluster, who, "debug_ms")
ceph.rm_config(cluster, who, "debug_rbd")
ceph.rm_config(cluster, who, "debug_rbd_mirror")
ceph.rm_config(cluster, who, "log_file")
ceph.rm_config(cluster, "mgr", "mgr/rbd_support/log_level")


def configure_rbd_mirroring(cluster, peer_info):
print(f"Applying rbd mirror secret in cluster '{cluster}'")

Expand Down Expand Up @@ -219,6 +239,14 @@ os.chdir(os.path.dirname(__file__))
cluster1 = sys.argv[1]
cluster2 = sys.argv[2]

# Run with RBD_MIRROR_DEBUG=0 to disable debug logs.
if os.environ.get("RBD_MIRROR_DEBUG") == "0":
disable_rbd_mirror_debug_logs(cluster1)
disable_rbd_mirror_debug_logs(cluster2)
else:
enable_rbd_mirror_debug_logs(cluster1)
enable_rbd_mirror_debug_logs(cluster2)

cluster1_info = fetch_secret_info(cluster1)
cluster2_info = fetch_secret_info(cluster2)

Expand Down
10 changes: 9 additions & 1 deletion test/addons/rook-cluster/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

# yamllint disable rule:line-length
---
resources:
- ${base_url}/cluster-test.yaml
- https://raw.githubusercontent.com/rook/rook/release-1.13/deploy/examples/cluster-test.yaml
patchesJson6902:
- target:
kind: CephCluster
Expand All @@ -21,3 +22,10 @@ patchesJson6902:
path: /spec/network
value:
provider: host
# Enable log collection. Logs are created in /data/rook/rook-ceph/log and rotated.
- op: add
path: /spec/logCollector
value:
enabled: true
periodicity: daily
nirs marked this conversation as resolved.
Show resolved Hide resolved
maxLogSize: 50M
10 changes: 1 addition & 9 deletions test/addons/rook-cluster/start
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,14 @@ import yaml
import drenv
from drenv import kubectl

# Update this when upgrading rook.
VERSION = "release-1.13"
BASE_URL = f"https://raw.githubusercontent.com/rook/rook/{VERSION}/deploy/examples"

# The ceph, and ceph-csi iamges are very large (500m each), using larger
# timeout to avoid timeouts with flaky network.
TIMEOUT = 600


def deploy(cluster):
print("Deploying rook ceph cluster")
with drenv.kustomization(
"kustomization.yaml",
base_url=BASE_URL,
) as kustomization:
kubectl.apply("--kustomize", kustomization, context=cluster)
kubectl.apply("--kustomize", ".", context=cluster)


def wait(cluster):
Expand Down
7 changes: 4 additions & 3 deletions test/addons/rook-operator/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

# yamllint disable rule:line-length
---
resources:
- ${base_url}/crds.yaml
- ${base_url}/common.yaml
- ${base_url}/operator.yaml
- https://raw.githubusercontent.com/rook/rook/release-1.13/deploy/examples/crds.yaml
- https://raw.githubusercontent.com/rook/rook/release-1.13/deploy/examples/common.yaml
- https://raw.githubusercontent.com/rook/rook/release-1.13/deploy/examples/operator.yaml
patchesJson6902:
- target:
kind: ConfigMap
Expand Down
28 changes: 0 additions & 28 deletions test/addons/rook-operator/rook-config-override.yaml

This file was deleted.

14 changes: 1 addition & 13 deletions test/addons/rook-operator/start
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,12 @@
import os
import sys

import drenv
from drenv import kubectl

# Update this when upgrading rook.
VERSION = "release-1.13"
BASE_URL = f"https://raw.githubusercontent.com/rook/rook/{VERSION}/deploy/examples"


def deploy(cluster):
print("Deploying rook ceph operator")
with drenv.kustomization(
"kustomization.yaml",
base_url=BASE_URL,
) as kustomization:
kubectl.apply("--kustomize", kustomization, context=cluster)
kubectl.apply("--kustomize", ".", context=cluster)


def wait(cluster):
Expand All @@ -44,9 +35,6 @@ def wait(cluster):
context=cluster,
)

print("Applying rook-config-override")
kubectl.apply("--filename=rook-config-override.yaml", context=cluster)


if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} cluster")
Expand Down
7 changes: 7 additions & 0 deletions test/addons/rook-toolbox/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

# yamllint disable rule:line-length
---
resources:
- https://raw.githubusercontent.com/rook/rook/release-1.13/deploy/examples/toolbox.yaml
6 changes: 1 addition & 5 deletions test/addons/rook-toolbox/start
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ import sys
from drenv import ceph
from drenv import kubectl

# Update this when upgrading rook.
VERSION = "release-1.13"
BASE_URL = f"https://raw.githubusercontent.com/rook/rook/{VERSION}/deploy/examples"


def deploy(cluster):
print("Deploying rook ceph toolbox")
kubectl.apply("--filename", f"{BASE_URL}/toolbox.yaml", context=cluster)
kubectl.apply("--kustomize", ".", context=cluster)


def wait(cluster):
Expand Down
14 changes: 14 additions & 0 deletions test/drenv/ceph.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ def clear_osd_blocklist(cluster):
tool(cluster, "ceph", "osd", "blocklist", "clear")


def set_config(cluster, who, option, value):
"""
See https://docs.ceph.com/en/latest/rados/configuration/ceph-conf/#commands
"""
tool(cluster, "ceph", "config", "set", who, option, value)


def rm_config(cluster, who, option):
"""
See https://docs.ceph.com/en/latest/rados/configuration/ceph-conf/#commands
"""
tool(cluster, "ceph", "config", "rm", who, option)


def tool(cluster, *args):
return kubectl.exec(
"deploy/rook-ceph-tools",
Expand Down
Loading