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

fix: WP-813 CMS customization fails, CMS is old #1034

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

wesleyboar
Copy link
Member

@wesleyboar wesleyboar commented Dec 9, 2024

Overview & Changes

  1. Update CMS settings & secrets documentation.
  2. Document CMS customization.
  3. Update CMS sample secrets to mimic TACC/Core-CMS's.
  4. Update CMS image.

Status

Related

Testing & UI

CMS Settings & Secrets

  1. If Core-Portal is running locally, run make stop.

  2. Backup your CMS settings & secrets.
    e.g. cp server/conf/cms/ server/conf/cms-before-WP-813/

  3. Add CMS settings via new instructions e.g.

    curl "https://cdn.jsdelivr.net/gh/TACC/Core-CMS@main/taccsite_cms/secrets.example.py" -o server/conf/cms/settings_custom.py
    cp server/conf/cms/secrets.sample.py server/conf/cms/secrets.py
    curl "https://cdn.jsdelivr.net/gh/TACC/Core-CMS@main/taccsite_cms/settings_local.example.py" -o server/conf/cms/settings_local.py
  4. Run make start.

  5. Verify no errors and these —

    • server/conf/cms/settings_custom.py
    • server/conf/cms/secrets.py
    • server/conf/cms/settings_local.py

    — exist as files not directories.

  6. Verify Core-Portal's Core-CMS loads in browser.

CMS Settings
WP-813 Settings

CMS Customization via Settings

  1. Uncomment these lines in settings_local.py

    # PORTAL_IS_TACC_CORE_PORTAL = False
    # PORTAL_HAS_LOGIN = False
  2. Reload Core-CMS in browser.

  3. Verify "Login" link / Portal nav is absent.

WP-813.mov

CMS Version

  1. Open browser's Developer Tools on CMS page.
  2. In "Network" tab, open core-syles.*.css content.
  3. At top of file, verify version is latest Core-CMS release.
CMS version
WP-813 Image

Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.68%. Comparing base (229d1cb) to head (a4538a0).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1034   +/-   ##
=======================================
  Coverage   72.68%   72.68%           
=======================================
  Files         534      534           
  Lines       33657    33657           
  Branches     2989     2989           
=======================================
  Hits        24464    24464           
  Misses       8995     8995           
  Partials      198      198           
Flag Coverage Δ
javascript 75.40% <ø> (ø)
unittests 60.84% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

server/conf/cms/secrets.sample.py Show resolved Hide resolved
Comment on lines 10 to 11
- ../cms/settings_local.py:/code/taccsite_cms/settings_local.py
- ../cms/settings_custom.py:/code/taccsite_cms/settings_custom.py
Copy link
Member Author

Choose a reason for hiding this comment

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

This allows settings_local.py and settings_custom.py to function. I did not add :ro, because (based on my chat with Docker's AI) that will not prevent directory from showing if files exist.

Details

These are methods to prevent directory from being created if single-file volume is missing:

  • A. Name the volume. Set it as external: true; this causes error instead of empty directory.
  • B. Ensure the files exist before composing the Docker environment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In Production the :ro ensures that when a new portal VM is provisioned and configured if any of the placed files are forgotten (secrets, settings_local) the portal's docker engine will not generate an empty directory and try to mount said empty dir, docker will instead complain about the missing files - which is what we want. You may still want the mount to fail in local dev if the files are not present (ie - were not curled or copied as needed)? Its a quick way of knowing you missed something. Thoughts?

Copy link
Member Author

@wesleyboar wesleyboar Dec 9, 2024

Choose a reason for hiding this comment

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

A. Sounds fine, but adding :ro does not have that effect for me locally. Are my test steps flawed?

Test Steps
  1. Add the :ro to each settings & secrets file volume.
  2. Run make stop.
  3. Deleted my existing settings & secrets files.
  4. Run make start.
  5. ❌ See empty directories added.
b11800a
b11800ab

Copy link
Member Author

@wesleyboar wesleyboar Dec 9, 2024

Choose a reason for hiding this comment

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

B. I tried using verbose syntax, so I could change the mount type to bind. This change, with read_only: true worked i.e. caused error if a file is missing.

Test Steps
  1. Add the :ro to each settings & secrets file volume.
  2. Run make stop.
  3. Deleted my existing settings & secrets directories.
    (from testing method A)
  4. Run make start.
  5. ✅ No empty directories added.
  6. ℹ️ Console reports error about missing file.
59a72f8
59a72f8e

Copy link
Member Author

Choose a reason for hiding this comment

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

C. I investigated again the other method I'd read, a named volume with external: true. It requires manually adding a volume first and an equally verbose docker-compose file change. And I don't think it will work (because how would container tell CMS where file is).

Instructions (Untested)
  1. First, create a named volume manually (if it doesn't already exist):
    docker volume create my_volume
  2. Then, in your Docker Compose file, you can use this volume and mark it as external:
    services:
      your_service:
        image: your_image
        volumes:
          - my_volume:/path/in/container/file.txt
    
    volumes:
      my_volume:
        external: true

Copy link
Member Author

Choose a reason for hiding this comment

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

@rstijerina & @taoteg, I do not want to start Idea D yet.1

This PR, as of latest commit 4c0fb05, would create directories. But, anyone who would customize the CMS, is instructed to delete them, touch the files, restart, and populate the settings as necessary.

Is this sufferable for now?

Footnotes

  1. Because it requires refactor in Core-CMS, clients and developers to move their settings, and Camino to update where it places CMS settings.

Copy link
Member

Choose a reason for hiding this comment

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

How about your verbose method, that doesn't create empty dirs?

Copy link
Member Author

@wesleyboar wesleyboar Dec 10, 2024

Choose a reason for hiding this comment

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

B.2. Ew. Okay. See 985e86a. But that causes an error if file does not exist… I thought new goal was to not create files unless necessary.

E. To avoid error and directory and file content, create empty files. Proposal: I add back "CMS" section to README.md but with new command. See 985e86a...3c0187bb.

I'm fine with [any…] just mentioning drawbacks.

P.S. [Devs have so many commands] to run… couldn't some be moved to a script that Docker runs on up?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, if no rush on this, it can stay open to remind me to do Idea D.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for background again. Idea D is best imo

server/conf/cms/secrets.sample.py Show resolved Hide resolved
server/conf/cms/secrets.sample.py Outdated Show resolved Hide resolved
server/conf/cms/secrets.sample.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Previous attempt to error if files are missing failed:
#1034 (comment)

This method succeeded, an error occurred:
> invalid mount config for type "bind": bind source path does not exist: /host_mnt/[…]/server/conf/cms/secrets.py
server/conf/docker/docker-compose-dev.all.debug.yml Outdated Show resolved Hide resolved
README.md Outdated
Comment on lines 112 to 116
```sh
curl "https://cdn.jsdelivr.net/gh/TACC/Core-CMS@main/taccsite_cms/secrets.example.py" -o server/conf/cms/settings_custom.py
cp server/conf/cms/secrets.sample.py server/conf/cms/secrets.py
curl "https://cdn.jsdelivr.net/gh/TACC/Core-CMS@main/taccsite_cms/settings_local.example.py" -o server/conf/cms/settings_local.py
```
Copy link
Member

Choose a reason for hiding this comment

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

99% of use of the CMS in this repo by devs is just to have a homepage. I think a good goal would be to have a default config (the existing secrets.sample.py) to get up and running immediately, and if need be a dev who needs bespoke CMS settings can set them after the fact. Think we can figure something out?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had thought so, and am fine with minimal working secrets (as it was).

@taoteg reports devs adding CMS non-secret settings to CMS secrets.py. Or maybe I misunderstood. For fear that is happening:

  1. I added support for settings_custom.py and settings_local.py.
  2. To avoid settings_custom.py and settings_local.py being added as directories if they are absent, I added commands to create them.
  3. To avoid needing to keep those files up-to-date, I curled them from TACC/Core-CMS.

Copy link
Member

Choose a reason for hiding this comment

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

Personally I think keeping a working set of default settings committed makes more sense for local dev, and updates as needed can be committed to the repo.

How about this: We commit a set of local settings that are committed with dummy credentials that will be imported into the CMS settings on make start, and if a (untracked) secrets.py happens to exist, then that acts as an override

Copy link
Collaborator

@taoteg taoteg Dec 9, 2024

Choose a reason for hiding this comment

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

I am looking for parity between env setups here. We should be using the same config files (settings, settings_custom, settings_local, secrets) in every env (dev, local, pprd, prod).

By leaving out parts of the default config structure we are not training devs on the expected practice for how these files exist in pprd/prod and why certain settings exist in certain files.

Examples:

  • There is no value for SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error'] in the example settings. This error will creep up in the logging (annoying). [Supposedly this will go away when FP-1728: Remove once servers have RECAPTCHA_..._KEY settings but so far has not for me.. maybe due to the old CMS image?]. This setting should go in settings_local, but how would you do that in the CMS with the current setup? By overloading the secrets file... which is bad practice.

This request is as much about consistency in workflows as it is about having good settings out of the box that use a current CMS image.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, the SILENCED_SYSTEM_CHECKS is in Core-CMS settings_local.py…. Another way to resolve that missing piece is add it to a committed and tracked settings_custom.py (which @rstijerina proposed to us privately).

Copy link
Member Author

@wesleyboar wesleyboar Dec 10, 2024

Choose a reason for hiding this comment

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

New solution available via settings_default.py (which Core-CMS supports in TACC/Core-CMS#904.

Verbose config way to stop creation of empty directories.

Drawback: Error if files do not exist.
Simple manual way to stop creation of empty directories.

Drawback: Manual step… BUT it replaces step that had been here.
@wesleyboar wesleyboar added bug Something isn't working enhancement New feature or request labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants