Skip to content

Commit 697917e

Browse files
committed
Fix enforcing the restricted mode
1 parent 99af9b3 commit 697917e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

docker/mongodb-kubernetes-tests/tests/opsmanager/om_ops_manager_backup_sharded_cluster.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,27 @@ def s3_bucket(aws_s3_client: AwsS3Client, namespace: str) -> str:
4343
yield from create_s3_bucket(aws_s3_client, "test-bucket-sharded-")
4444

4545

46+
@fixture(scope="module")
47+
def enforced_pss_namespace(namespace: str) -> str:
48+
# Change pod-security mode from warn to enforce. This will make test fail if operator and deployments don't support enforce mode
49+
# This will not work in multi-cluster, because Istio injects sidecar and that breaks restricted level
50+
if not is_multi_cluster():
51+
label_namespace(namespace, {"pod-security.kubernetes.io/enforce": "restricted"})
52+
53+
return namespace
54+
55+
4656
@fixture(scope="module")
4757
def ops_manager(
48-
namespace: str,
58+
enforced_pss_namespace: str,
4959
s3_bucket: str,
5060
custom_version: Optional[str],
5161
custom_appdb_version: str,
5262
) -> MongoDBOpsManager:
5363
resource: MongoDBOpsManager = MongoDBOpsManager.from_yaml(
54-
yaml_fixture("om_ops_manager_backup.yaml"), namespace=namespace
64+
yaml_fixture("om_ops_manager_backup.yaml"), namespace=enforced_pss_namespace
5565
)
5666

57-
# Change pod-security mode from warn to enforce. This will make test fail if operator and deployments don't support enforce mode
58-
# This will not work in multi-cluster, because Istio injects sidecar and that breaks restricted level
59-
if not is_multi_cluster():
60-
label_namespace(
61-
namespace, {"pod-security.kubernetes.io/enforce": None, "pod-security.kubernetes.io/warn": "restricted"}
62-
)
63-
6467
try_load(resource)
6568
return resource
6669

0 commit comments

Comments
 (0)