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

Weaver: add option to automatically unregister old providers #423

Merged
merged 6 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@
[Unreleased](https://github.com/bird-house/birdhouse-deploy/tree/master) (latest)
------------------------------------------------------------------------------------------------------------------

[//]: # (list changes here, using '-' for each new entry, remove this when items are added)
## Changes

- Weaver: add option to automatically unregister old providers

Introduces the `WEAVER_UNREGISTER_DROPPED_PROVIDERS` variable. If set to "True", Weaver providers that are no longer
working (not responding when deployed) and are not named in `WEAVER_WPS_PROVIDERS` will be unregistered. This is
useful when deploying Weaver with fewer providers than a previous deployment.

For example, if the stack is deployed with the Weaver, Finch, and Raven components. Then later deployed with just
Weaver and Raven, the Finch provider will be unregistered from weaver.

Previously, the Finch provider would have remained as a Weaver provider despite the fact that it has been removed from
the stack.

[2.0.5](https://github.com/bird-house/birdhouse-deploy/tree/2.0.5) (2024-01-22)
------------------------------------------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions birdhouse/components/weaver/default.env
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ export WEAVER_WPS_PROVIDERS_RETRY_AFTER=5

export WEAVER_MONGODB_DATA_DIR='${DATA_PERSIST_ROOT}/mongodb_weaver_persist'

# If "True", Weaver providers that are no longer working (not responding when deployed) and are not named in
# WEAVER_WPS_PROVIDERS will be unregistered. This is useful when deploying Weaver with fewer providers than a previous
# deployment.
export WEAVER_UNREGISTER_DROPPED_PROVIDERS="False"

export DELAYED_EVAL="
$DELAYED_EVAL
Expand Down
31 changes: 31 additions & 0 deletions birdhouse/components/weaver/post-docker-compose-up
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,37 @@ for prov in ${WEAVER_WPS_PROVIDERS}; do
done
echo "${PREFIX}All Weaver remote WPS providers registered successfully!"

if [ x"${WEAVER_UNREGISTER_DROPPED_PROVIDERS}" = x"True" ]; then
# Get all registered providers whether they are working or not
all_providers_resp=$( \
curl_cmd --insecure --silent --location \
-m ${REQUEST_TIMEOUT} \
-b "${cookie}" \
"${WEAVER_URL}/providers?check=false&detail=false" \
)
# Get all registered working providers
working_providers_resp=$( \
curl_cmd --insecure --silent --location \
-m ${REQUEST_TIMEOUT} \
-b "${cookie}" \
"${WEAVER_URL}/providers?check=true&detail=false" \
)
working_providers=$(echo "$working_providers_resp" | tr '\n' ' ' | \
sed -e 's/.*"providers":\[//' -e 's/\].*//' -e 's/[",]/ /g')
for prov in $(echo "$all_providers_resp" | sed -e 's/.*"providers":\[//' -e 's/\].*//' -e 's/[",]/ /g'); do
# Note: both WEAVER_WPS_PROVIDERS and working_providers are whitespace delimited with no newlines
if echo " ${WEAVER_WPS_PROVIDERS} " | grep -qv "[[:space:]]${prov}[[:space:]]" && \
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will be run each time autodeploy runs, which runs inside its own container. Please test this with autodeploy.

The reason curl was a docker run is because there are no curl in the autodeploy container.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

can confirm this check works in the autodeploy container: grep, sed, etc. all work in that environment.

echo " ${working_providers} " | grep -qv "[[:space:]]${prov}[[:space:]]"; then
# unregister provider that is no longer specified in WEAVER_WPS_PROVIDERS and is no longer working
echo "${PREFIX}Unregistering the remote WPS provider matching [${prov}] not in WEAVER_WPS_PROVIDERS."
curl_cmd --insecure --silent --location \
-m ${REQUEST_TIMEOUT} \
-b "${cookie}" \
-X DELETE \
"${WEAVER_URL}/providers/${prov}"
fi
done
fi

echo "${PREFIX}Starting Weaver WebApp/Worker Celery tasks validation..."
CUR_SCRIPT_DIR="$(dirname "$(realpath "$0")")"
Expand Down
5 changes: 5 additions & 0 deletions birdhouse/env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,11 @@ export THREDDS_ADDITIONAL_CATALOG=""
# (note: if using 'DATA_PERSIST_ROOT', it must be defined earlier, either in this file or from 'default.env')
#export WEAVER_MONGODB_DATA_DIR='${DATA_PERSIST_ROOT}/mongodb_weaver_persist'

# If "True", Weaver providers that are no longer working (not responding when deployed) and are not named in
# WEAVER_WPS_PROVIDERS will be unregistered. This is useful when deploying Weaver with fewer providers than a previous
# deployment.
#export WEAVER_UNREGISTER_DROPPED_PROVIDERS="True"

# If "True", requests to the geoserver endpoint will not be authorized through twitcher/magpie
# (note: this is NOT recommended but will slightly improve performance when accessing geoserver endpoints)
#export GEOSERVER_SKIP_AUTH=True
Expand Down
Loading