Skip to content

Conversation

@asithade
Copy link
Contributor

@asithade asithade commented Dec 18, 2025

Summary

This PR introduces administrative scripts to simplify LFX v2 development environment setup and data management.

Changes

New Scripts

  1. setup-env.sh - Automated environment configuration

    • Retrieves and exports NATS_URL, OPENFGA_STORE_ID, and JWT_RSA_SECRET
    • Eliminates manual environment variable setup
    • Can be sourced or eval'd for direct shell integration
  2. reset-data.sh - Comprehensive data reset utility

    • Clears all NATS KV buckets (projects, committees, meetings, etc.)
    • Deletes and recreates OpenSearch indices
    • Restarts query service and project service pod to clear caches
    • Preserves authentication data (authelia-users, authelia-email-otp)

Safety & Quality Improvements

reset-data.sh enhancements:

  • User confirmation prompt - Requires typing 'RESET' to proceed
  • Dynamic mapping retrieval - Captures current OpenSearch mapping before deletion
  • Error handling - Aborts on critical operation failures
  • Variable quoting - All variables properly quoted (shellcheck compliant)
  • Code quality - Formatted with shfmt for consistent style

Documentation Updates

  • Added Quick Setup section with automated script usage
  • Documented safety features and script capabilities
  • Updated data wipe instructions to use reset script
  • Clarified ROOT project recreation behavior

Benefits

  • Faster development environment setup
  • Prevents accidental data loss with confirmation prompt
  • Maintains index structure with dynamic mapping
  • Production-quality scripts (shellcheck validated)
  • Comprehensive documentation for all workflows

This script resets all data in NATS KV buckets and OpenSearch, clearing projects, committees, meetings, and search indices. It also restarts the query service and deletes the project service pod to clear caches.

Signed-off-by: Asitha de Silva <adesilva@linuxfoundation.org>
Copilot AI review requested due to automatic review settings December 18, 2025 06:15
Added copyright and license information to the script.

Signed-off-by: Asitha de Silva <adesilva@linuxfoundation.org>
Copy link

Copilot AI left a comment

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 adds a new administrative script to reset all application data for development/testing purposes. The script provides a comprehensive cleanup mechanism by clearing NATS KV buckets, OpenSearch indices, and restarting relevant services.

Key changes:

  • Adds reset-data.sh script that clears all NATS KV buckets (excluding auth-related buckets)
  • Deletes and recreates OpenSearch indices with proper mapping for the resources index
  • Restarts query service and deletes project service pod to clear application caches

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add setup-env.sh script to automate environment variable configuration
- Add confirmation prompt to reset-data.sh requiring 'RESET' input
- Add error handling with abort on critical operation failures
- Add dynamic OpenSearch mapping retrieval before index deletion
- Fix variable quoting throughout scripts (shellcheck compliant)
- Format scripts with shfmt for consistent style
- Update README with quick setup instructions and safety features
- Update README to reference new reset script capabilities

Signed-off-by: Asitha de Silva <asithade@gmail.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Make reset-data.sh executable to pass bash-exec linter
- Update urllib3 from 2.5.0 to 2.6.2 to fix HIGH severity vulnerabilities:
  - CVE-2025-66418: Unbounded decompression chain
  - CVE-2025-66471 (GHSA-gm62-xv2j-4w53)
- Add now_utc() Jinja2 helper function for datetime calculations in meeting templates

Signed-off-by: Asitha de Silva <asithade@gmail.com>
- Quote NAMESPACE and OPENSEARCH_POD in all kubectl commands
- Ensure full shellcheck compliance across both scripts
- Address Copilot review comments about variable quoting consistency

Signed-off-by: Asitha de Silva <asithade@gmail.com>
@asithade asithade requested a review from andrest50 December 29, 2025 22:58
env.globals["environ"] = dict(os.environ)
env.globals["fake"] = fake
env.globals["timedelta"] = datetime.timedelta
env.globals["now_utc"] = lambda: datetime.datetime.now(datetime.UTC)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something you were using for future stuff like mailing list? I don't see it used in this commit. Actually, since python Faker has date-time generation which can include "now", we don't really need "now_z" either ... I've just opened #15 to demonstrate replacing the single instance of now_z with faker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was using this in my local for creating future meetings based on the current time -- we can switch to using faker instead.

Removed the now_utc global function from the environment.

Signed-off-by: Asitha de Silva <adesilva@linuxfoundation.org>
@asithade asithade requested a review from emsearcy January 6, 2026 19:12
@emsearcy
Copy link
Contributor

emsearcy commented Jan 6, 2026

These are great! I'd also suggest we add export TZ=UTC to setup-env to help with fake date generation for easy mapping of "zoneless" Faker times to UTC by simply appending "Z" suffix.

Andres will be adding a public copy of "current" OpenSearch indexer spec to our indexer repo.

Copy link
Contributor

@emsearcy emsearcy left a comment

Choose a reason for hiding this comment

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

looks good, maybe we can add TZ=UTC to setup-env on the next update. Thanks!

@asithade asithade merged commit c66e471 into main Jan 6, 2026
3 checks passed
@asithade asithade deleted the chore/reset-data-script branch January 6, 2026 19:29
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