HDXTABLE-119 TDE fix datastore cleanup on resource update#6983
Open
teodorescuserban wants to merge 3 commits into
Open
HDXTABLE-119 TDE fix datastore cleanup on resource update#6983teodorescuserban wants to merge 3 commits into
teodorescuserban wants to merge 3 commits into
Conversation
Coverage Report for CI Build 7439Coverage decreased (-0.001%) to 80.132%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses HDXTABLE-119 by adding post-package_revise handling during resource_update to (1) clean up DataStore state when a resource’s format becomes unsupported and (2) re-trigger DataPusher when a supported resource’s file is actually replaced (URL change or upload).
Changes:
- Capture pre-update
datastore_activeand URL, then invoke a new_handle_datastore_on_resource_update()helper after the resource dict is refreshed. - Implement DataStore deletion +
datastore_activeflag clearing for unsupported formats, and DataPusher submission for supported formats when the file changes. - Add unit-style tests covering both bug scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
ckanext-hdx_package/ckanext/hdx_package/actions/update.py |
Adds _handle_datastore_on_resource_update() and calls it from resource_update using pre-update state. |
ckanext-hdx_package/ckanext/hdx_package/tests/test_actions/test_datastore_cleanup.py |
Adds focused tests for datastore cleanup and datapusher triggering logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+182
to
+205
| try: | ||
| _get_action('datastore_delete')( | ||
| {'ignore_auth': True}, | ||
| {'resource_id': resource_id, 'force': True} | ||
| ) | ||
| except tk.ObjectNotFound: | ||
| pass # table already gone, nothing to do | ||
| except Exception as e: | ||
| log.error('Failed to delete datastore table for resource %s: %s', resource_id, e) | ||
|
|
||
| # Update datastore_active flag directly; resource_patch would re-enter | ||
| # resource_update, and after_resource_delete only fires on full deletion. | ||
| try: | ||
| res_obj = _model.Resource.get(resource_id) | ||
| if res_obj: | ||
| new_extras = dict(res_obj.extras or {}) | ||
| new_extras['datastore_active'] = False | ||
| _model.Session.query(_model.Resource).filter_by(id=resource_id).update( | ||
| {'extras': new_extras}, synchronize_session=False | ||
| ) | ||
| _model.Session.commit() | ||
| except Exception as e: | ||
| log.error('Failed to set datastore_active=False for resource %s: %s', resource_id, e) | ||
|
|
Comment on lines
+8
to
+13
| import pytest | ||
| from unittest.mock import MagicMock, patch, call | ||
|
|
||
| import ckan.plugins as plugins | ||
|
|
||
| from ckanext.hdx_package.actions.update import _handle_datastore_on_resource_update |
Comment on lines
+50
to
+53
| mock_delete.assert_called_once_with( | ||
| {'ignore_auth': True}, | ||
| {'resource_id': RESOURCE_ID, 'force': True}, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.