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

fix: Ensure network config in DataSourceOracle can be unpickled #5073

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

TheRealFalcon
Copy link
Member

Proposed Commit Message

fix: Ensure network config in DataSourceOracle can be unpickled

`_network_config` is only explicitly set on the instance if
`_is_iscsi_root()` is True. This means that when `_is_iscsi_root()` is
False, we're modifying the class variable directly. When the instance
gets pickled, the class variable is not included so such changes do
not get persisted. This commit fixes this.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

`_network_config` is only explicitly set on the instance if
`_is_iscsi_root()` is True. This means that when `_is_iscsi_root()` is
False, we're modifying the class variable directly. When the instance
gets pickled, the class variable is not included so such changes do
not get persisted. This commit fixes this.
@a-dubs
Copy link
Collaborator

a-dubs commented Mar 20, 2024

Changes look good! Are there any unit tests or anything to test pickling to prevent future regressions?

@TheRealFalcon
Copy link
Member Author

I was wondering about unit tests. Without the if not hasattr(self, "_network_config"): section, the other changes will fail the test_upgrade.py unit test. This issue was found due to failing tests (though somewhat reliant on ordering), so I think that's probably sufficient here. I think that anything else would likely be overly contrived, but I'm also open to ideas.

Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

+1 This LGTM. Better to have this mutable attribute specifically on the instance. And I'm good with tests/unittests/test_upgrade.py effectively catching your move from class attribute -> instance attribute and the assertion that the hasattr covereage is required to initialize the default value of _network_config across deserialization.

@TheRealFalcon TheRealFalcon merged commit 9633a7b into canonical:main Mar 26, 2024
29 checks passed
@TheRealFalcon TheRealFalcon deleted the oracle-pickle branch March 26, 2024 14:09
holmanb pushed a commit that referenced this pull request Apr 3, 2024
`_network_config` is only explicitly set on the instance if
`_is_iscsi_root()` is True. This means that when `_is_iscsi_root()` is
False, we're modifying the class variable directly. When the instance
gets pickled, the class variable is not included so such changes do
not get persisted. This commit fixes this.
holmanb pushed a commit that referenced this pull request Apr 3, 2024
`_network_config` is only explicitly set on the instance if
`_is_iscsi_root()` is True. This means that when `_is_iscsi_root()` is
False, we're modifying the class variable directly. When the instance
gets pickled, the class variable is not included so such changes do
not get persisted. This commit fixes this.
holmanb pushed a commit that referenced this pull request Apr 3, 2024
`_network_config` is only explicitly set on the instance if
`_is_iscsi_root()` is True. This means that when `_is_iscsi_root()` is
False, we're modifying the class variable directly. When the instance
gets pickled, the class variable is not included so such changes do
not get persisted. This commit fixes this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants