Skip to content

HDXTABLE-119 TDE fix datastore cleanup on resource update#6983

Open
teodorescuserban wants to merge 3 commits into
devfrom
hdxtable-119
Open

HDXTABLE-119 TDE fix datastore cleanup on resource update#6983
teodorescuserban wants to merge 3 commits into
devfrom
hdxtable-119

Conversation

@teodorescuserban

Copy link
Copy Markdown
Member

No description provided.

@coveralls

coveralls commented May 25, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 7439

Coverage decreased (-0.001%) to 80.132%

Details

  • Coverage decreased (-0.001%) from the base build.
  • Patch coverage: 6 uncovered changes across 1 file (23 of 29 lines covered, 79.31%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
ckanext-hdx_package/ckanext/hdx_package/actions/update.py 29 23 79.31%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 18160
Covered Lines: 14552
Line Coverage: 80.13%
Coverage Strength: 0.8 hits per line

💛 - Coveralls

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_active and URL, then invoke a new _handle_datastore_on_resource_update() helper after the resource dict is refreshed.
  • Implement DataStore deletion + datastore_active flag 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},
)
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