-
Notifications
You must be signed in to change notification settings - Fork 0
Rework unsupported security types #153
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
Conversation
Reviewer's GuideThis PR introduces an environment-variable–backed configuration for unsupported security-type architectures in the Azure utils, refactors existing security‐type logic to consume the new accessor, and adds comprehensive unit tests for that accessor. Sequence diagram for get_safe_security_type logic updatesequenceDiagram
participant "Caller"
participant Utils
"Caller"->>Utils: get_safe_security_type(image_type)
Utils->>Utils: get_unsupported_security_type_arches()
Utils->>Utils: Check if image_type in unsupported arches
alt image_type unsupported
Utils-->>"Caller": return None
else image_type supported
Utils-->>"Caller": return security_type
end
Class diagram for UNSUPPORTED_SECURITY_TYPE_ARCHES and get_unsupported_security_type_arches changesclassDiagram
class AzurePublishingMetadata {
<<inherits PublishingMetadata>>
}
class Utils {
+UNSUPPORTED_SECURITY_TYPE_ARCHES: str
+get_unsupported_security_type_arches() List[str]
}
Utils : UNSUPPORTED_SECURITY_TYPE_ARCHES
Utils : get_unsupported_security_type_arches()
AzurePublishingMetadata --|> PublishingMetadata
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- The split on an empty UNSUPPORTED_SECURITY_TYPE_ARCHES yields [""], which is likely unintended—consider filtering out empty strings so it returns an empty list instead.
- The new get_safe_security_type check uses
if image_type not in get_unsupported_security_type_arches()which seems to invert the original logic (only x64Gen2 should get a security type); please verify that this condition matches the intended behavior.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The split on an empty UNSUPPORTED_SECURITY_TYPE_ARCHES yields [""], which is likely unintended—consider filtering out empty strings so it returns an empty list instead.
- The new get_safe_security_type check uses `if image_type not in get_unsupported_security_type_arches()` which seems to invert the original logic (only x64Gen2 should get a security type); please verify that this condition matches the intended behavior.
## Individual Comments
### Comment 1
<location> `cloudpub/ms_azure/utils.py:317-319` </location>
<code_context>
return True
+def get_unsupported_security_type_arches() -> List[str]:
+ """Return the list of arches that don't support security type."""
+ return UNSUPPORTED_SECURITY_TYPE_ARCHES.split(",")
+
+
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Whitespace in environment variable values may cause subtle bugs.
Strip whitespace from each item after splitting to ensure consistent list values and prevent comparison issues.
```suggestion
def get_unsupported_security_type_arches() -> List[str]:
"""Return the list of arches that don't support security type."""
return [arch.strip() for arch in UNSUPPORTED_SECURITY_TYPE_ARCHES.split(",")]
```
</issue_to_address>
### Comment 2
<location> `cloudpub/ms_azure/utils.py:335-336` </location>
<code_context>
def get_safe_security_type(image_type):
- # Arches which aren't x86Gen2 (like ARM64) doesn't work well with security type
- if image_type != "x64Gen2":
+ # Some arches (like x86 Gen1) doesn't support security type, so we need to skip them.
+ if image_type not in get_unsupported_security_type_arches():
return None
return security_type
</code_context>
<issue_to_address>
**issue (bug_risk):** Logic appears inverted for skipping unsupported arches.
The current logic skips supported arches instead of unsupported ones. Update the condition to 'if image_type in get_unsupported_security_type_arches()' so only unsupported arches are skipped.
</issue_to_address>
### Comment 3
<location> `tests/ms_azure/test_utils.py:586-587` </location>
<code_context>
assert res == disk_version_arm64_obj
+
+ @mock.patch("cloudpub.ms_azure.utils.UNSUPPORTED_SECURITY_TYPE_ARCHES", "x64Gen1")
+ def test_get_unsupported_security_type_arches_default(self) -> None:
+ """Test that the function returns the default value when env var is not set."""
+ res = get_unsupported_security_type_arches()
</code_context>
<issue_to_address>
**suggestion (testing):** Consider adding a test for whitespace handling in UNSUPPORTED_SECURITY_TYPE_ARCHES.
Please add a test case where the environment variable includes extra whitespace to ensure the function properly strips it from the values.
</issue_to_address>
### Comment 4
<location> `tests/ms_azure/test_utils.py:604-605` </location>
<code_context>
+ res = get_unsupported_security_type_arches()
+ assert res == ["x64Gen1", "x64Gen2", "arm64Gen1"]
+
+ @mock.patch("cloudpub.ms_azure.utils.UNSUPPORTED_SECURITY_TYPE_ARCHES", "")
+ def test_get_unsupported_security_type_arches_empty(self) -> None:
+ """Test that the function returns empty list when env var is empty."""
+ res = get_unsupported_security_type_arches()
</code_context>
<issue_to_address>
**question (testing):** The test for empty string returns [""], which may not be the intended behavior.
Should get_unsupported_security_type_arches() return an empty list instead of [""] when the environment variable is empty? If so, please update both the function and its test.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
ed92382 to
d2a52d5
Compare
f1ca669 to
e5d239e
Compare
e1a0572 to
a677e8c
Compare
This commit adds a new property for `AzurePublishingMetadata` named `unsupported_security_type_arches` which aims to map the list of unsupported arches which shouldn't receive a value for security_type on SKU building. When not set this value defaults to `x64Gen1`. It also changes the `_build_skus` and `update_skus` functions to receive the list of unsupported arches and use the default when not set. Signed-off-by: Jonathan Gangi <jgangi@redhat.com> Assisted-by: Cursor/Gemini
a677e8c to
7b704af
Compare
|
@lslebodn PTAL again. Since this is a exclusion method and we only have I know that we will no longer plan to mix up arches in a single plan but this might be useful beside being part of code correctness. It also offers more control to us if we need to bypass a certain type of arch |
I do not worry much about exclusion. I am just curious how much configurable exclusion would be useful. We should build skus based on matrix IMHO we should either fix defaults based on expected plans settings. |
|
In the current code it's always whatever it's set there OR |
|
Closing as it will be done differently, with a more flexible way of controlling the security type for new SKUs |
The previous code would always let the
security_typeto be any configured value in the plan as long as it was marked as aX86Gen2.However, recently Azure introduced support for trusted boot for
armGen2which requires setting the same value for the security type asx86Gen2. With this change, we only need to ignore the values forx86Gen1now, as it doesn't support secure boot.This PR changes the behavior of
update_skus(and_build_skus) to ONLY IGNORE the existing value for security type forx86Gen1by default and allow the ignore list to be received as parameter, so we can properly set it without code changes in the future.