HHS / Head-Start-TTADP

OHS TTA Hub data system. ACF SO, Dana Jones-Quartey. Tech lead: Krys Wisnaskas
Main: https://ttahub.ohs.acf.hhs.gov/
21 stars 7 forks source link

[TTAHUB-3064] Self Service Automation - Deployed Environment: Time Slice - Phase 1: Power down lower environments during off hours #2423

Closed GarrettEHill closed 1 month ago

GarrettEHill commented 1 month ago

Description of Changes

This update enhances the CircleCI configuration, specifically the manual_manage_env_workflow, to streamline the management of application environments by introducing dynamic environment-specific handling. Now, only env_list is required as an argument, with space, username, and password automatically inferred for each environment. Key improvements include flexibility in managing application states with options for start, stop, restart, or restage operations.

Key Changes:

  1. Simplified Workflow Trigger:

    • The manual_manage_env_workflow now relies solely on the env_list parameter, eliminating the need for space_list and cloudgov parameters to manually specify spaces, usernames, or passwords.
    • Environment-specific variables (e.g., CLOUDGOV_DEV_PASSWORD, CLOUDGOV_SANDBOX_SPACE) are dynamically resolved based on each environment in env_list, supporting multiple actions (start, stop, restart, restage).
  2. Parameter Updates:

    • Streamlined workflow by removing space_list and cloudgov parameters, making env_list the primary input to manage environments with corresponding credentials and space names auto-mapped based on the environment value.
  3. Automated Job Execution:

    • The manage_env_apps job now handles each environment's state transition (start, stop, restart, or restage) based on the values in env_list and dynamically retrieved credentials, providing precise, automated management without additional input for each environment.

Example Usage:

Use the following parameters in the CircleCI pipeline to manage specific environments dynamically:

pipeline.parameters:
  manual-manage-env: true           # Ensure manual management is enabled
  env_state: "stop"                 # Specify the desired state (e.g., "start", "stop", "restart", "restage")
  env_list: "tta-smarthub-sandbox"  # Specify the environment (e.g., "tta-smarthub-sandbox" or "tta-smarthub-dev")

With these changes, the workflow manages specified environments effectively based on env_list, enhancing deployment and maintenance for sandbox or production systems.

Benefits:

How to Test

  1. Navigate to CircleCI Dashboard:

    • Go to the CircleCI website.
    • Log in and navigate to your project’s pipeline dashboard.
  2. Trigger a Pipeline Manually:

    • Select the project where the workflow is configured.
    • On the project’s dashboard, click on the "Trigger Pipeline" button.
    • A dialog box will appear for you to input pipeline parameters. Input the following in the UI fields:
      • manual-manage-env: Set this to true.
      • env_state: Set this to 'restart;.
      • env_list: Set this to "tta-smarthub-sandbox".
    • Click "Trigger Pipeline" to start the workflow with the specified parameters.
  3. Monitor Workflow Execution:

    • Observe the workflow's progress on the pipeline dashboard.
    • Click into the workflow to see specific jobs being executed (e.g., manage_env_apps).
    • Confirm that the workflow initializes successfully and targets the specified environment(s) from env_list.
  4. View Job Logs:

    • Click on the manage_env_apps job in the workflow to review detailed logs.
    • Verify that the job processes the environment correctly based on env_list and env_state (e.g., actions on sandbox environment).
    • A successful job will display a green checkmark; errors will be detailed in logs for troubleshooting.
  5. Test Multiple Scenarios:

    • Manually trigger the pipeline again, adjusting env_list to test different environments if applicable.
    • Confirm that the workflow behaves as expected based on the environment selected.
  6. Ensure Expected Behavior:

    • Run multiple tests at different times, modifying env_list to validate the workflow's response to various environment configurations.

Issue(s)

Checklists

Every PR

Before merge to main

Production Deploy

After merge/deploy

thewatermethod commented 1 month ago

I'll try to get this tested out today but we definitely need to add documentation to the repo for this new feature. It might be worth starting a new markdown file with all the self-service automation instructions and linking to it from the main readme.

GarrettEHill commented 1 month ago

@thewatermethod

I'll try to get this tested out today but we definitely need to add documentation to the repo for this new feature. It might be worth starting a new markdown file with all the self-service automation instructions and linking to it from the main readme.

Done

thewatermethod commented 1 month ago

Done

@GarrettEHill Incredible precision, it reads like some kind of robot wrote it