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

[Draft] Proof of concept for xloader site url #234

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pwalsh
Copy link
Member

@pwalsh pwalsh commented Nov 18, 2024

We want to be able to communicate within a docker network without using the public site_url. This is a minimal proof of concept for achieving this.

@ThrawnCA
Copy link
Collaborator

CKAN 2.11 build is broken by ckan/ckan-docker-base#86 and needs to run the test container as root to work around it.

default:
description: |
Provide an alternate site URL for the xloader_submit action.
This is useful, for example, when the site is running within a docker network.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This is useful, for example, when the site is running within a docker network.
This is useful, for example, when the site is running within a docker network
or where the job runner can't access ckan using its normal public site URL.

@@ -2,6 +2,12 @@ version: 1
groups:
- annotation: ckanext-xloader settings
options:
- key: ckanext.xloader.site_url
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need an empty string default, it's normal for optional settings to be not present if not provided

Suggested change
default:

Copy link
Contributor

Choose a reason for hiding this comment

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

instead of the toolkit.config.get("ckanext.xloader.site_url") or toolkit.config.get("ckan.site_url") logic below we should be able to use just toolkit.config.get("ckanext.xloader.site_url") along with:

       validators: configured_default("ckan.site_url",None)

Copy link
Member Author

Choose a reason for hiding this comment

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

@wardi ok I see. so that default is just set in the config yaml, and then, any code can assume that fallback default for the ckanext.xloader.site_url setting?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, this validator will set ckanext.xloader.site_url to the same as ckan.site_url when it's not given. Another one of @smotornyuk 's clever ideas.

Comment on lines +64 to +68
site_url_configs = ("ckan.site_url", "ckanext.xloader.site_url")
if not any(site_url_configs):
raise Exception(
f"One of config options {site_url_configs} must be set to use ckanext-xloader."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

ckan will refuse to start if a site_url isn't provided, so this code would never get executed

Copy link
Member Author

Choose a reason for hiding this comment

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

@wardi here, I'm just extending the existing check for that. I prefer not to remove existing behavior, but just to provide the minimal new behavior required for the PR

https://github.com/ckan/ckanext-xloader/blob/master/ckanext/xloader/plugin.py#L64

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you did not cleanup the error message, this would not have been commented upon ;)

I'm fine leaving this in as its a belts and braces approach, better to fail early (if it does occur which is very very remote)

"result_url": callback_url,
"metadata": {
"ignore_hash": True,
"ckan_url": toolkit.config.get("ckanext.xloader.site_url")
Copy link
Collaborator

Choose a reason for hiding this comment

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

going to need more tests created to set these two values for proper validation.
one for default site url, another for the xloader override value. updating the fixture is so/so.

Copy link
Collaborator

@duttonw duttonw left a comment

Choose a reason for hiding this comment

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

would like to see more tests to ensure all paths are covered.

@pwalsh
Copy link
Member Author

pwalsh commented Nov 21, 2024

@duttonw yeah sure, will add tests, this is in draft as it is not ready for review by maintainers, I'm just doing a minimal validation of the approach ( I work with @wardi and @amercader at Link Digital ).

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.

4 participants