Skip to content

Commit

Permalink
Merge pull request RamenDR#310 from red-hat-storage/sync_us--main
Browse files Browse the repository at this point in the history
Syncing latest changes from upstream main for ramen
  • Loading branch information
ShyamsundarR committed Jun 21, 2024
2 parents 108215c + 0cac38e commit 870ff96
Show file tree
Hide file tree
Showing 33 changed files with 238 additions and 182 deletions.
23 changes: 23 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,29 @@ drenv cleanup

This should not be needed.

## Caching resources

If you run the drenv tool with a flaky network you can improve
reliability of starting the environment by caching resources.

To cache resources for the `regional-dr.yaml` environment run:

```
drenv cache envs/regional-dr.yaml
```

The cache expires in 2 days. To refresh the cache daily, you can install
a cron job to run `scripts/refresh-cache` daily as the user used to run
the environment.

See the `scripts/refresh-cache.crontab` for example user crontab.

To clear the cached resources run:

```
drenv clear
```

## The environment file

To create an environment you need an yaml file describing the
Expand Down
4 changes: 1 addition & 3 deletions test/addons/recipe/fetch → test/addons/argocd/cache
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# SPDX-License-Identifier: Apache-2.0

import os

from drenv import cache

os.chdir(os.path.dirname(__file__))
path = cache.path("addons/recipe.yaml")
cache.fetch(".", path)
cache.refresh(".", "addons/argocd-2.11.yaml")
5 changes: 3 additions & 2 deletions test/addons/argocd/start
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
import sys

from drenv import temporary_kubeconfig
Expand All @@ -20,8 +21,7 @@ def wait_for_clusters(clusters):

def deploy_argocd(cluster):
print("Deploying argocd")
path = cache.path("addons/argocd-2.11.yaml")
cache.fetch(".", path)
path = cache.get(".", "addons/argocd-2.11.yaml")
kubectl.apply("--filename", path, "--namespace", "argocd", context=cluster)


Expand Down Expand Up @@ -70,6 +70,7 @@ if len(sys.argv) != 4:
print(f"Usage: {sys.argv[0]} hub cluster1 cluster2")
sys.exit(1)

os.chdir(os.path.dirname(__file__))
hub, *clusters = sys.argv[1:]

wait_for_clusters(clusters)
Expand Down
11 changes: 11 additions & 0 deletions test/addons/cdi/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
from drenv import cache

os.chdir(os.path.dirname(__file__))
cache.refresh("operator", "addons/cdi-operator-1.59.0.yaml")
cache.refresh("cr", "addons/cdi-cr-1.59.0.yaml")
16 changes: 0 additions & 16 deletions test/addons/cdi/fetch

This file was deleted.

6 changes: 2 additions & 4 deletions test/addons/cdi/start
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ NAMESPACE = "cdi"

def deploy(cluster):
print("Deploying cdi operator")
path = cache.path("addons/cdi-operator-1.59.0.yaml")
cache.fetch("operator", path)
path = cache.get("operator", "addons/cdi-operator-1.59.0.yaml")
kubectl.apply("--filename", path, context=cluster)

print("Waiting until cdi-operator is rolled out")
Expand All @@ -28,8 +27,7 @@ def deploy(cluster):
)

print("Deploying cdi cr")
path = cache.path("addons/cdi-cr-1.59.0.yaml")
cache.fetch("cr", path)
path = cache.get("cr", "addons/cdi-cr-1.59.0.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# SPDX-License-Identifier: Apache-2.0

import os

from drenv import cache

os.chdir(os.path.dirname(__file__))
path = cache.path("addons/csi-addons.yaml")
cache.fetch(".", path)
cache.refresh(".", "addons/csi-addons.yaml")
3 changes: 1 addition & 2 deletions test/addons/csi-addons/start
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ from drenv import cache

def deploy(cluster):
print("Deploying csi addon for volume replication")
path = cache.path("addons/csi-addons.yaml")
cache.fetch(".", path)
path = cache.get(".", "addons/csi-addons.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
11 changes: 11 additions & 0 deletions test/addons/kubevirt/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
from drenv import cache

os.chdir(os.path.dirname(__file__))
cache.refresh("operator", "addons/kubevirt-operator-1.2.1.yaml")
cache.refresh("cr", "addons/kubevirt-cr-1.2.1.yaml")
16 changes: 0 additions & 16 deletions test/addons/kubevirt/fetch

This file was deleted.

6 changes: 2 additions & 4 deletions test/addons/kubevirt/start
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ NAMESPACE = "kubevirt"

def deploy(cluster):
print("Deploying kubevirt operator")
path = cache.path("addons/kubevirt-operator-1.2.1.yaml")
cache.fetch("operator", path)
path = cache.get("operator", "addons/kubevirt-operator-1.2.1.yaml")
kubectl.apply("--filename", path, context=cluster)

print("Waiting until virt-operator is rolled out")
Expand All @@ -28,8 +27,7 @@ def deploy(cluster):
)

print("Deploying kubevirt cr")
path = cache.path("addons/kubevirt-cr-1.2.1.yaml")
cache.fetch("cr", path)
path = cache.get("cr", "addons/kubevirt-cr-1.2.1.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# SPDX-License-Identifier: Apache-2.0

import os

from drenv import cache

os.chdir(os.path.dirname(__file__))
path = cache.path("addons/ocm-controller.yaml")
cache.fetch(".", path)
cache.refresh(".", "addons/ocm-controller.yaml")
3 changes: 1 addition & 2 deletions test/addons/ocm-controller/start
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ from drenv import cache

def deploy(cluster):
print("Deploying ocm controller")
path = cache.path("addons/ocm-controller.yaml")
cache.fetch(".", path)
path = cache.get(".", "addons/ocm-controller.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
11 changes: 11 additions & 0 deletions test/addons/olm/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
from drenv import cache

os.chdir(os.path.dirname(__file__))
cache.refresh("crds", "addons/olm-crds-0.27.yaml")
cache.refresh("operators", "addons/olm-operators-0.27.yaml")
15 changes: 0 additions & 15 deletions test/addons/olm/fetch

This file was deleted.

6 changes: 2 additions & 4 deletions test/addons/olm/start
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def deploy(cluster):
# The CustomResourceDefinition "clusterserviceversions.operators.coreos.com"
# is invalid: metadata.annotations: Too long: must have at most 262144 bytes
# See https://medium.com/pareture/kubectl-install-crd-failed-annotations-too-long-2ebc91b40c7d
path = cache.path("addons/olm-crds-0.27.yaml")
cache.fetch("crds", path)
path = cache.get("crds", "addons/olm-crds-0.27.yaml")
kubectl.apply("--filename", path, "--server-side=true", context=cluster)

print("Waiting until cdrs are established")
Expand All @@ -33,8 +32,7 @@ def deploy(cluster):
)

print("Deploying olm")
path = cache.path("addons/olm-operators-0.27.yaml")
cache.fetch("operators", path)
path = cache.get("operators", "addons/olm-operators-0.27.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
4 changes: 1 addition & 3 deletions test/addons/rook-cephfs/fetch → test/addons/recipe/cache
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# SPDX-License-Identifier: Apache-2.0

import os

from drenv import cache

os.chdir(os.path.dirname(__file__))
path = cache.path("addons/rook-cephfs-1.14.yaml")
cache.fetch(".", path)
cache.refresh(".", "addons/recipe.yaml")
3 changes: 1 addition & 2 deletions test/addons/recipe/start
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ os.chdir(os.path.dirname(__file__))
cluster = sys.argv[1]

print("Deploying recipe crd")
path = cache.path("addons/recipe.yaml")
cache.fetch(".", path)
path = cache.get(".", "addons/recipe.yaml")
kubectl.apply("--filename", path, context=cluster)
10 changes: 10 additions & 0 deletions test/addons/rook-cephfs/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
from drenv import cache

os.chdir(os.path.dirname(__file__))
cache.refresh(".", "addons/rook-cephfs-1.14.yaml")
3 changes: 1 addition & 2 deletions test/addons/rook-cephfs/start
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ from drenv import kubectl

def deploy(cluster):
print("Creating CephFS instance and storage/snapshot classes")
path = cache.path("addons/rook-cephfs-1.14.yaml")
cache.fetch(".", path)
path = cache.get(".", "addons/rook-cephfs-1.14.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
10 changes: 10 additions & 0 deletions test/addons/rook-cluster/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
from drenv import cache

os.chdir(os.path.dirname(__file__))
cache.refresh(".", "addons/rook-cluster-1.14.yaml")
12 changes: 0 additions & 12 deletions test/addons/rook-cluster/fetch

This file was deleted.

3 changes: 1 addition & 2 deletions test/addons/rook-cluster/start
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ TIMEOUT = 600

def deploy(cluster):
print("Deploying rook ceph cluster")
path = cache.path("addons/rook-cluster-1.14.yaml")
cache.fetch(".", path)
path = cache.get(".", "addons/rook-cluster-1.14.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
10 changes: 10 additions & 0 deletions test/addons/rook-operator/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
from drenv import cache

os.chdir(os.path.dirname(__file__))
cache.refresh(".", "addons/rook-operator-1.14.yaml")
12 changes: 0 additions & 12 deletions test/addons/rook-operator/fetch

This file was deleted.

3 changes: 1 addition & 2 deletions test/addons/rook-operator/start
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ from drenv import cache

def deploy(cluster):
print("Deploying rook ceph operator")
path = cache.path("addons/rook-operator-1.14.yaml")
cache.fetch(".", path)
path = cache.get(".", "addons/rook-operator-1.14.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
10 changes: 10 additions & 0 deletions test/addons/rook-toolbox/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
from drenv import cache

os.chdir(os.path.dirname(__file__))
cache.refresh(".", "addons/rook-toolbox-1.14.yaml")
12 changes: 0 additions & 12 deletions test/addons/rook-toolbox/fetch

This file was deleted.

3 changes: 1 addition & 2 deletions test/addons/rook-toolbox/start
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ from drenv import cache

def deploy(cluster):
print("Deploying rook ceph toolbox")
path = cache.path("addons/rook-toolbox-1.14.yaml")
cache.fetch(".", path)
path = cache.get(".", "addons/rook-toolbox-1.14.yaml")
kubectl.apply("--filename", path, context=cluster)


Expand Down
Loading

0 comments on commit 870ff96

Please sign in to comment.