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

Issue/662 default storage class #745

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
1c4ca85
compiled new requirements.txt
fraugabel Aug 29, 2024
8880a15
added makdirs check in helper.py
fraugabel Aug 29, 2024
a4e3603
deleted gen_sonsobuoy
fraugabel Sep 2, 2024
dcec54e
re-compiled requirements
fraugabel Sep 2, 2024
fad1ed6
re-added gen_sonobuoy_result_file
fraugabel Sep 4, 2024
b92fade
re-added gen_sonobuoy_result_file
fraugabel Sep 4, 2024
545d0ed
added cleanup() as subfunction to check_default_persistentvolumeclaim…
fraugabel Sep 9, 2024
9956bd1
added cleanup() as subfunction to check_default_persistentvolumeclaim…
fraugabel Sep 9, 2024
43e1282
rebased
fraugabel Sep 9, 2024
218883f
resolved sonobuoy filename issue
fraugabel Oct 2, 2024
1743399
Default Retries adjustable on module level
fraugabel Oct 2, 2024
f717aa8
cleanup on module level and cleanup on ressource conflict
fraugabel Oct 2, 2024
2fd1fc7
recompiled requirements.in after deleting fabric
fraugabel Oct 7, 2024
95c74c6
added debug option
fraugabel Oct 7, 2024
12d3c15
added debug option
fraugabel Oct 7, 2024
d00f1ba
creating context manager
fraugabel Oct 7, 2024
8afc712
context manager cleaning up
fraugabel Oct 7, 2024
13c7622
cleaning up with error handling
fraugabel Oct 7, 2024
0211b18
break apart monolyte
fraugabel Oct 7, 2024
a0aa07b
prepare part
fraugabel Oct 8, 2024
bdbabc2
extending prepare part
fraugabel Oct 8, 2024
ff8fb83
preparing in short loops working
fraugabel Oct 8, 2024
b94df03
preparing in short loops working
fraugabel Oct 8, 2024
4407373
context manager workin except for SCSTestExceptions
fraugabel Oct 8, 2024
0ff381a
SCSTestExceptions must be raised inside with block
fraugabel Oct 8, 2024
b44b0ad
SCSTestException correctly caught into yaml
fraugabel Oct 23, 2024
6e079ed
fixed modul sorting and doc string def prepare
fraugabel Oct 27, 2024
0ba6f9a
checked convoluted exit
fraugabel Oct 28, 2024
3706237
checked convoluted exit
fraugabel Oct 28, 2024
0465356
checked convoluted exit
fraugabel Oct 28, 2024
ad39c6d
for flake
fraugabel Oct 28, 2024
31f9e68
csi provider check
fraugabel Oct 29, 2024
0f16b17
csi provider check
fraugabel Oct 29, 2024
4f1a0f1
ReadWriteOnce and PVC Bound tested
fraugabel Oct 29, 2024
7696250
ReadWriteOnce and PVC Bound tested
fraugabel Oct 30, 2024
ea6c576
default values
fraugabel Oct 30, 2024
92ea10e
refracturing Exception chain
fraugabel Nov 6, 2024
f9436e5
removed files that are not supposed to be in the PR
fraugabel Nov 6, 2024
78872c5
fixed key error in getting default storage class
fraugabel Nov 11, 2024
5ff4bda
successfully tested csi-provider function
fraugabel Nov 11, 2024
20ffdab
Make executable, fix error message
mbuechse Nov 13, 2024
fe7e58a
simplify check_default_storageclass
mbuechse Nov 13, 2024
50643b2
typos in create_pvc_pod
mbuechse Nov 13, 2024
389e87a
commenting
fraugabel Nov 13, 2024
c9a8b23
raising 404
fraugabel Nov 14, 2024
2d3e749
raising 404
fraugabel Nov 14, 2024
0dea150
raising 404
fraugabel Nov 14, 2024
400fb54
raising regular Exception 1
fraugabel Nov 18, 2024
e00043e
raising regular Exception 1
fraugabel Nov 18, 2024
0a54a9f
indentation
fraugabel Nov 18, 2024
1dd96ed
indentation
fraugabel Nov 18, 2024
a335677
indentation
fraugabel Nov 18, 2024
d853396
dividing 404
fraugabel Nov 18, 2024
edb6dc1
dividing 404
fraugabel Nov 18, 2024
86858e4
dividing 404
fraugabel Nov 18, 2024
d5e4d76
dividing 404
fraugabel Nov 18, 2024
8fa3945
dividing 404
fraugabel Nov 18, 2024
b284203
dividing 404
fraugabel Nov 18, 2024
64a411a
dividing 404
fraugabel Nov 18, 2024
898825c
dividing 404
fraugabel Nov 18, 2024
e98f92d
dividing 404
fraugabel Nov 18, 2024
e8798a8
dividing 404
fraugabel Nov 18, 2024
6e5754e
Merge branch 'main' into issue/662_default_storage_class
fraugabel Nov 18, 2024
21436f7
researched again csi-provider compliance
fraugabel Nov 21, 2024
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
53 changes: 37 additions & 16 deletions Tests/iaas/security-groups/default-security-group-rules.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a mistake, this file does not belong to this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file seems to be here in error.

Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def check_default_rules(rules, short=False):
if short is True, the testing mode is set on short for older OpenStack versions
"""
ingress_rules = egress_rules = 0
egress_vars = {'IPv4': {}, 'IPv6': {}}
egress_vars = {"IPv4": {}, "IPv6": {}}
for key, value in egress_vars.items():
value['default'] = 0
value["default"] = 0
if not short:
value['custom'] = 0
value["custom"] = 0
if not rules:
logger.info("No default security group rules defined.")
for rule in rules:
Expand All @@ -42,36 +42,48 @@ def check_default_rules(rules, short=False):
if not short:
# we allow ingress from the same security group
# but only for the default security group
if rule.remote_group_id == "PARENT" and not rule["used_in_non_default_sg"]:
if (
rule.remote_group_id == "PARENT"
and not rule["used_in_non_default_sg"]
):
continue
ingress_rules += 1
elif direction == "egress" and ethertype in egress_vars:
egress_rules += 1
if short:
egress_vars[ethertype]['default'] += 1
egress_vars[ethertype]["default"] += 1
continue
if rule.remote_ip_prefix:
# this rule does not allow traffic to all external ips
continue
# note: these two are not mutually exclusive
if rule["used_in_default_sg"]:
egress_vars[ethertype]['default'] += 1
egress_vars[ethertype]["default"] += 1
if rule["used_in_non_default_sg"]:
egress_vars[ethertype]['custom'] += 1
egress_vars[ethertype]["custom"] += 1
# test whether there are no unallowed ingress rules
if ingress_rules:
logger.error(f"Expected no default ingress rules, found {ingress_rules}.")
# test whether all expected egress rules are present
missing = [(key, key2) for key, val in egress_vars.items() for key2, val2 in val.items() if not val2]
missing = [
(key, key2)
for key, val in egress_vars.items()
for key2, val2 in val.items()
if not val2
]
if missing:
logger.error(
"Expected rules for egress for IPv4 and IPv6 both for default and custom security groups. "
f"Missing rule types: {', '.join(str(x) for x in missing)}"
)
logger.info(str({
"Unallowed Ingress Rules": ingress_rules,
"Egress Rules": egress_rules,
}))
logger.info(
str(
{
"Unallowed Ingress Rules": ingress_rules,
"Egress Rules": egress_rules,
}
)
)


def create_security_group(conn, sg_name: str = SG_NAME, description: str = DESCRIPTION):
Expand Down Expand Up @@ -139,7 +151,9 @@ def main():
"to the OS_CLOUD environment variable",
)
parser.add_argument(
"--debug", action="store_true", help="Enable debug logging",
"--debug",
action="store_true",
help="Enable debug logging",
)
args = parser.parse_args()
openstack.enable_logging(debug=args.debug)
Expand All @@ -164,10 +178,17 @@ def main():
test_rules(conn)

c = counting_handler.bylevel
logger.debug(f"Total critical / error / warning: {c[logging.CRITICAL]} / {c[logging.ERROR]} / {c[logging.WARNING]}")
logger.debug(
f"Total critical / error / warning: {c[logging.CRITICAL]} / {c[logging.ERROR]} / {c[logging.WARNING]}"
)
if not c[logging.CRITICAL]:
print("security-groups-default-rules-check: " + ('PASS', 'FAIL')[min(1, c[logging.ERROR])])
return min(127, c[logging.CRITICAL] + c[logging.ERROR]) # cap at 127 due to OS restrictions
print(
"security-groups-default-rules-check: "
+ ("PASS", "FAIL")[min(1, c[logging.ERROR])]
)
return min(
127, c[logging.CRITICAL] + c[logging.ERROR]
) # cap at 127 due to OS restrictions


if __name__ == "__main__":
Expand Down
27 changes: 12 additions & 15 deletions Tests/kaas/k8s-default-storage-class/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import logging
from kubernetes import client, config
import os

manual_result_file_template = {
"name": None,
Expand All @@ -13,7 +14,7 @@


def initialize_logging():
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.DEBUG)
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.INFO)


def print_usage(file=sys.stderr):
Expand All @@ -34,11 +35,11 @@ class SCSTestException(Exception):
"""Raised when an Specific test did not pass"""

def __init__(self, *args, return_code: int):
super().__init__(*args)
self.return_code = return_code


def setup_k8s_client(kubeconfigfile=None):

if kubeconfigfile:
logger.debug(f"using kubeconfig file '{kubeconfigfile}'")
config.load_kube_config(kubeconfigfile)
Expand All @@ -56,19 +57,15 @@ def setup_k8s_client(kubeconfigfile=None):


def gen_sonobuoy_result_file(error_n: int, error_msg: str, test_file_name: str):

test_name = test_file_name.replace(".py", "")

test_name = test_file_name.removesuffix(".py")
test_status = "passed"

if error_n != 0:
test_status = test_name + "_" + str(error_n)

result_file = manual_result_file_template

result_file["name"] = test_name
result_file["status"] = test_status
result_file["details"]["messages"] = error_msg

with open(f"./{test_name}.result.yaml", "w") as file:
yaml.dump(result_file, file)
result_file = manual_result_file_template
result_file["name"] = test_name
result_file["status"] = test_status
result_file["details"]["messages"] = error_msg

script_directory = os.path.dirname(os.path.abspath(__file__))
with open(f"{script_directory}/{test_name}.result.yaml", "w") as file:
yaml.dump(result_file, file)
Loading
Loading