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

Use Azure Storage Tables for collection and container configuration #48

Merged
merged 35 commits into from
Feb 17, 2022

Conversation

lossyrob
Copy link
Contributor

@lossyrob lossyrob commented Feb 9, 2022

Description

This PR removes the hard-coded configuration for collections in favor of configuration stored in Azure Storage Tables.

It refactors the CommonConfig class, moving it to use pydantic.BaseSettings and adding table configuration for the tables holding the collection and container configurations.

It adds Azurite into the development environment, which is used to hold dev data in those tables.

It also refactors some of the usage of caching, using cachetools.cachedmethod with instance caches.

It adds a storage account to the terraform deployment, and a CLI that can be used to populate the tables with configuration.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Added unit tests
  • Deployed to dev stack, wrote config to table, tested mosaic/info and queryable endpoints, verified render links generated based on config

Checklist:

Please delete options that are not relevant.

  • I have performed a self-review
  • Changelog has been updated
  • Documentation has been updated
  • Unit tests pass locally (./scripts/test)
  • Code is linted and styled (./scripts/format)

Brining in the type stubs for cachetools caused
mypy to complain about unknown types for the key
function
Also run flake8 on pccommon,
which wasn't happening
Also refactor CommonConfig to use pydantic settings.
Create a table setup for collection configuration
and container configuration.
Use cachetools to cache the configuration.
Encode collection configuration and container
configuration (which was hardcoded) as JSON.
This can be used to populate the initial
table structure in deployment as well, after
which this test data will diverge from production
settings.
Also account for environment prefix for DEBUG
that change with refactor to use BaseSettings in
CommonConfig
@lossyrob lossyrob force-pushed the feature/rde/table-configs branch from c25477a to f6069f8 Compare February 9, 2022 15:59
@lossyrob lossyrob force-pushed the feature/rde/table-configs branch from 2708a3d to a44c544 Compare February 9, 2022 19:44
@lossyrob lossyrob marked this pull request as ready for review February 10, 2022 04:56
@lossyrob lossyrob requested a review from mmcfarland February 10, 2022 04:56
Copy link
Member

@mmcfarland mmcfarland left a comment

Choose a reason for hiding this comment

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

This looks good! I was able to test it locally with the explorer and it fetches the mosaicInfo as expected, but the subsequent tile requests error (see below).

The only other comment is that it looks like the cli is used for dumping/loading a table-wide file. Is there a mode to target a particular rowkey only? I'm thinking of the use case of tweaking render params for a new collection and just working in a single file rather than the dump of the whole table.

pccommon/pccommon/tables.py Show resolved Hide resolved
This was left over from a previous
implementation, should have been cleaned up.
@lossyrob
Copy link
Contributor Author

The only other comment is that it looks like the cli is used for dumping/loading a table-wide file. Is there a mode to target a particular rowkey only? I'm thinking of the use case of tweaking render params for a new collection and just working in a single file rather than the dump of the whole table.

The dump is table-wide, but the load would handle a single collection (JSON with a top level single key). But it's a good point that the workflow would likely to be to dump a single collection, tweak, and the load that same file. Will change.

- name: "PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY"
value: "{{ .Values.tiler.storage.account_key }}"
- name: "PCAPIS_CONTAINER_CONFIG__TABLE_NAME"
value: "{{ .Values.tiler.storage.container_config_table_name }}"
- name: APP_INSIGHTS_INSTRUMENTATION_KEY
Copy link
Contributor

Choose a reason for hiding this comment

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

Might need to update this to PCAPIS_APP_INSIGHTS_INSTRUMENTATION_KEY

- PCAPIS_CONTAINER_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_CONTAINER_CONFIG__TABLE_NAME=containerconfig

# Used for logging and metrics
- APP_INSIGHTS_INSTRUMENTATION_KEY
Copy link
Contributor

Choose a reason for hiding this comment

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

Might need to update this to PCAPIS_APP_INSIGHTS_INSTRUMENTATION_KEY

Comment on lines +31 to +32
default=None,
env=APP_INSIGHTS_INSTRUMENTATION_KEY,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does setting env like this avoid the env_prefix?

@mmcfarland mmcfarland merged commit 33f5487 into main Feb 17, 2022
@mmcfarland mmcfarland deleted the feature/rde/table-configs branch February 17, 2022 21:06
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