feat: Add future warning for api_name in DataVolume constructor, it will default to storage#2649
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ocp_resources/datavolume.py (1)
151-161: FutureWarning logic looks good overall.The warning is clear, actionable, and
stacklevel=2correctly points callers to their own code. One minor note:Previously, an explicit
api_name=Nonecall would leaveself.api_nameasNone, causingto_dict(line 188) to skip populating thepvc/storagespec block entirely. With this change, explicitapi_name=Nonenow triggers the warning and silently defaults to"pvc", which is a subtle behavioral difference. If that edge case was never intended to be supported, this is fine — but worth being aware of.If you want to guard against it, you could use a sentinel instead of
None:Optional: use a sentinel to distinguish "not provided" from explicit None
+_UNSET = object() + def __init__( self, ... - api_name: str | None = None, + api_name: str | None | object = _UNSET, ... ) -> None: ... - if api_name is None: + if api_name is _UNSET: warn( "The default 'api_name' will change from 'pvc' to 'storage' in a future release. " "To maintain existing behavior and suppress this warning, " "explicitly set api_name='pvc' in your constructor call.", FutureWarning, stacklevel=2, ) self.api_name = "pvc" else: self.api_name = api_name
If I'm getting this correctly, |
|
/verified |
|
/lgtm |
… API (#3878) ##### Short description: With the current PR, we are making sure that DataVolume creation won't be affected by defaulting the `api_name` to `storage` and therefore, we are making DataVolume creation in priority class test to use the storage API and remove duplicate parameters ##### More details: After [this change](RedHatQE/openshift-python-wrapper#2649), we are raising a warning when DataVolume are being created with the default `api_name`. Implementing step 2 of https://issues.redhat.com/browse/CNV-79539 ##### What this PR does / why we need it: We need this to achieve a smooth transition to "storage" as the default API name when creating a DataVolume. ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated data volume test configuration to use new API endpoint parameter. * **Refactor** * Simplified data volume constructor parameters; removed volume_mode and access_modes configuration in favor of api_name endpoint specification. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
… API (#3878) ##### Short description: With the current PR, we are making sure that DataVolume creation won't be affected by defaulting the `api_name` to `storage` and therefore, we are making DataVolume creation in priority class test to use the storage API and remove duplicate parameters ##### More details: After [this change](RedHatQE/openshift-python-wrapper#2649), we are raising a warning when DataVolume are being created with the default `api_name`. Implementing step 2 of https://issues.redhat.com/browse/CNV-79539 ##### What this PR does / why we need it: We need this to achieve a smooth transition to "storage" as the default API name when creating a DataVolume. ##### Which issue(s) this PR fixes: ##### Special notes for reviewer: ##### jira-ticket: <!-- full-ticket-url needs to be provided. This would add a link to the pull request to the jira and close it when the pull request is merged If the task is not tracked by a Jira ticket, just write "NONE". --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Updated data volume test configuration to use new API endpoint parameter. * **Refactor** * Simplified data volume constructor parameters; removed volume_mode and access_modes configuration in favor of api_name endpoint specification. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Short description:
Add a warning to inform consumers that the default API name will soon change from "pvc" to "storage".
More details:
Implementing step 1 of https://issues.redhat.com/browse/CNV-79539
What this PR does / why we need it:
We need this to achieve a smooth transition to "storage" as the default API name when creating a DataVolume.
Which issue(s) this PR fixes:
Special notes for reviewer:
Bug:
Summary by CodeRabbit
api_nameparameter is not explicitly specified. The default value will change from "pvc" to "storage" in a future release. Explicitly setapi_nameto avoid warnings and ensure compatibility with future versions.