Skip to content

Commit 798d077

Browse files
datadog-agent-integrations-bot[bot]AAraKKesteveny91
authored
Fix Velero tests and stop using bitnami images (#21274) (#21296)
* Move bitnami image used for testing to bitnami legacy * Add changelog * Increase timeout when installing velero * Decrease timeout for installation. Did not work. * Add custom kubectl image (cherry picked from commit 04d89ef) Co-authored-by: Juanpe Araque <[email protected]> Co-authored-by: Steven Yuen <[email protected]>
1 parent 9b46168 commit 798d077

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

velero/changelog.d/21274.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove usage of bitnami images for testing and add ruff rules from parent directory

velero/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ include = [
5858
dev-mode-dirs = [
5959
".",
6060
]
61+
62+
[tool.ruff]
63+
extend = "../pyproject.toml"

velero/tests/conftest.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# All rights reserved
33
# Licensed under a 3-clause BSD style license (see LICENSE)
44
import os
5-
from contextlib import ExitStack
5+
from contextlib import ExitStack, contextmanager
66

77
import pytest
88

99
from datadog_checks.dev import TempDir, run_command
1010
from datadog_checks.dev.fs import path_join
11-
from datadog_checks.dev.kind import kind_run
11+
from datadog_checks.dev.kind import KindLoad, kind_run
1212
from datadog_checks.dev.kube_port_forward import port_forward
1313

1414
from .common import MOCKED_INSTANCE, PORT
@@ -17,6 +17,19 @@
1717
KIND_DIR = os.path.join(HERE, 'kind')
1818

1919

20+
@contextmanager
21+
def build_and_load_kubectl_image(image_tag: str):
22+
print("Building custom kubectl image...")
23+
dockerfile_path = os.path.join(KIND_DIR, 'kubectl.Dockerfile')
24+
25+
# Build the custom kubectl image
26+
run_command(
27+
['docker', 'build', '-t', image_tag, '-f', dockerfile_path, '.'],
28+
check=True,
29+
)
30+
yield
31+
32+
2033
def setup_velero():
2134
"""Set up Velero, MinIO and Nginx in the Kind cluster."""
2235
# Apply MinIO deployment
@@ -63,10 +76,12 @@ def get_instances(velero_host, velero_port, node_agent_host, node_agent_port):
6376
@pytest.fixture(scope='session')
6477
def dd_environment():
6578
kind_config = os.path.join(KIND_DIR, 'kind-config.yaml')
79+
custom_kubectl_image_tag = "custom-kubectl:latest"
6680

6781
with TempDir('helm_dir') as helm_dir:
6882
with kind_run(
69-
conditions=[setup_velero],
83+
wrappers=[build_and_load_kubectl_image(custom_kubectl_image_tag)],
84+
conditions=[KindLoad(custom_kubectl_image_tag), setup_velero],
7085
kind_config=kind_config,
7186
env_vars={
7287
"HELM_CACHE_HOME": path_join(helm_dir, 'Caches'),

velero/tests/kind/kubectl.Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM debian:bullseye-slim
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends wget gnupg coreutils ca-certificates && \
4+
rm -rf /var/lib/apt/lists/*
5+
6+
RUN wget -q -O kubectl https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl && \
7+
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
8+
rm kubectl

velero/tests/kind/velero-values.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,20 @@ metrics:
3535
# Deploy node-agent since we're monitoring it
3636
deployNodeAgent: true
3737

38+
# Override kubectl image to avoid bitnami dependency
39+
# This should be updated when velero has a final solution to depending on bitnami images
40+
# https://github.com/vmware-tanzu/helm-charts/issues/698
41+
kubectl:
42+
image:
43+
repository: custom-kubectl
44+
tag: "latest"
45+
pullPolicy: Never
46+
3847
# Default resource requests/limits
3948
resources:
4049
requests:
4150
cpu: 500m
4251
memory: 128Mi
4352
limits:
4453
cpu: 1000m
45-
memory: 512Mi
54+
memory: 512Mi

0 commit comments

Comments
 (0)