-
Notifications
You must be signed in to change notification settings - Fork 170
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
Adding kms policy name for same kms encryption keys #11497
base: master
Are you sure you want to change the base?
Conversation
Verification job: https://jenkins-csb-odf-qe-ocs4.dno.corp.redhat.com/job/qe-rdr-setup/1655/ |
1213ae1
to
7dd7b3a
Compare
Verification job here: https://jenkins-csb-odf-qe-ocs4.dno.corp.redhat.com/job/qe-rdr-setup/1667/ |
New validation: |
ocs_ci/utility/kms.py
Outdated
@@ -129,7 +129,7 @@ def __init__(self): | |||
"VAULT_BACKEND", defaults.VAULT_DEFAULT_BACKEND_VERSION | |||
) | |||
self.kmsid = None | |||
self.vault_policy_name = None | |||
self.vault_policy_name = self.kms_vault_policy_name() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.vault_policy_name = self.kms_vault_policy_name() | |
self.vault_policy_name = self.kms_vault_policy_name |
There is an issue:
2025-03-05 12:12:01 > self.vault_policy_name = self.kms_vault_policy_name()
2025-03-05 12:12:01 E TypeError: 'str' object is not callable
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: shivamdurgbuns The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
New changes are detected. LGTM label has been removed. |
new vaildation job: https://jenkins-csb-odf-qe-ocs4.dno.corp.redhat.com/job/qe-rdr-setup/1680/ |
Signed-off-by: Shivam Durgbuns <[email protected]>
Signed-off-by: Shivam Durgbuns <[email protected]>
Signed-off-by: Shivam Durgbuns <[email protected]>
Signed-off-by: Shivam Durgbuns <[email protected]>
Signed-off-by: Shivam Durgbuns <[email protected]>
Signed-off-by: Shivam Durgbuns <[email protected]>
Signed-off-by: Shivam Durgbuns <[email protected]>
ab5f891
to
ff28082
Compare
json_out = json.loads(out) | ||
if self.vault_policy_name in json_out: | ||
# if policy already exists append the secondary cluster backend path to the policy | ||
poilcy_data = ( | ||
f"\n}}\n" | ||
f'path "{self.vault_backend_path}/*" {{\n' | ||
f' capabilities = ["create", "read", "update","delete"]' | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in poilcy_data
and you are repeating this unnecesarly. Should be defined once only.
This is simplified how you can do this:
json_out = json.loads(out) | |
if self.vault_policy_name in json_out: | |
# if policy already exists append the secondary cluster backend path to the policy | |
poilcy_data = ( | |
f"\n}}\n" | |
f'path "{self.vault_backend_path}/*" {{\n' | |
f' capabilities = ["create", "read", "update","delete"]' | |
) | |
existing_policy_data = None | |
read_policy_cmd = f"vault policy read {self.vault_policy_name}" | |
try: | |
existing_policy_data = subprocess.check_output(shlex.split(read_policy_cmd)) | |
logger.info(f"Existing policy found!:\n{existing_policy_data}") | |
expect Exception: | |
logger.info("No existing policy found!") | |
policy_backend_path = ( | |
f'path "{self.vault_backend_path}/*" {{\n' | |
f' capabilities = ["create", "read", "update","delete"]' | |
f"\n}}\n" | |
) | |
policy_sys_mount = ( | |
f'path "sys/mounts" {{\n' | |
f'capabilities = ["read"]\n' | |
f"}}" | |
) | |
if existing_policy_data is None: | |
policy = policy_backend_path + policy_sys_mount | |
else: | |
policy = policy_backend_path + existing_policy_data | |
vault_hcl = tempfile.NamedTemporaryFile( | |
mode="a+", prefix="test", delete=False | |
) | |
logger.info( | |
f"Creating or updating policy: {self.vault_policy_name} with content:\n" | |
f"{policy}" | |
) | |
with open(vault_hcl.name, "a") as hcl: | |
hcl.write(policy) |
f'path "{self.vault_backend_path}/*" {{\n' | ||
f' capabilities = ["create", "read", "update","delete"]' | ||
) | ||
vault_hcl = tempfile.NamedTemporaryFile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the rest from this line can be deleted if you will follow the suggestion from code above
Fixes issue: #11495