Skip to content

Latest commit

 

History

History
95 lines (76 loc) · 3.53 KB

File metadata and controls

95 lines (76 loc) · 3.53 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Repository Overview

This is the OpenShift Dedicated managed-scripts repository, containing scripts executed by the Backplane system for cluster operations and troubleshooting.

Development Commands

Build and Validation

  • make build - Build the container image with validation, shellcheck, and pyflakes
  • make validation - Validate all metadata.yaml files against the JSON schema
  • make validation SCRIPTS="script1 script2" - Validate specific scripts only
  • make shellcheck - Run shellcheck on all .sh files
  • make pyflakes - Run pyflakes on all .py files

Testing with Backplane

The testjob create, get, and logs subcommands are deprecated. Use ocm backplane testjob render to generate Kubernetes YAML (ServiceAccount, RBAC, and Pod) locally, then apply it with oc on a non-production cluster where you have cluster-admin access:

# Log in to a non-production cluster with cluster-admin (normal IDP login; no backplane login needed)
# Replace the API URL with your cluster's.
oc login https://api.example.openshift.com:6443

# Render the test job YAML from the script directory (contains metadata.yaml + the script)
# If the script requires parameters, add them with -p (repeatable), e.g. -p var1=value
cd scripts/CEE/new-script
ocm backplane testjob render > test-job.yaml

# Review, then apply
oc apply -f test-job.yaml

# Watch / inspect with standard oc (replace the pod name with the one from the previous step)
oc -n openshift-backplane-managed-scripts get pods
oc -n openshift-backplane-managed-scripts logs example-test-job-pod

# Clean up
oc delete -f test-job.yaml

Architecture and Structure

Script Organization

Scripts are organized by team/category under scripts/:

  • alerting/ - Alerting and monitoring scripts
  • config/ - Configuration management
  • health/ - Health checking utilities
  • kafka/ - Kafka-specific operations
  • lib/ - Shared libraries and utilities
  • maintenance/ - Maintenance operations
  • networking/ - Network troubleshooting
  • node/ - Node operations
  • operators-lifecycle/ - Operator management
  • security/ - Security-related scripts
  • storage-registry/ - Storage and registry operations
  • troubleshooting/ - General troubleshooting

Script Structure

Each script directory must contain:

  • script.sh or script.py - The executable script
  • metadata.yaml - Script metadata conforming to hack/metadata.schema.json
  • Optional: README.md - Additional documentation

Metadata Schema

The metadata.yaml file defines:

  • Script metadata (name, description, author)
  • Language (bash or python)
  • RBAC permissions required
  • Allowed groups (CEE, SREP, etc.)
  • Environment variables
  • Customer data access declaration
  • Cluster version requirements

Container Environment

Scripts run in a UBI8-based container with pre-installed tools:

  • OpenShift CLI (oc)
  • AWS CLI (aws)
  • OCM CLI (ocm)
  • OSDCTL (osdctl)
  • Hypershift CLI (hypershift)
  • YQ (yq)
  • Standard utilities (jq, ssh, python3.11)

Release Process

  • Staging: Automatically deploys from main branch
  • Production: Released every 3 weeks
  • For urgent production releases, contact @managed-scripts in #sd-ims-backplane

Key Files

  • hack/metadata.schema.json - JSON schema for metadata validation
  • hack/schema_validation.sh - Validation script for metadata files
  • template/ - Template for new script creation
  • Dockerfile - Container build definition with all required tools