Files
pve-purestorage-plugin/.github/workflows/lint.yml
T
Timur Kumakbayev f9f8eed94b Active Cluster Support, Pod Quota Fixes,Token Cache and CI Improvements (#81)
feat: add Active Cluster support and improve plugin stability

## Major Features

### Active Cluster Support (Experimental) (#42)
- Add support for multiple PureStorage arrays in Active Cluster configuration
- Automatic volume connection on all arrays for high availability
- Configure via comma-separated addresses and tokens

### Pod Quota Limit Support (#69)
- Add proper handling of pod quota_limit parameter
- Use quota_limit when set, fall back to array capacity when unlimited
- Fix capacity reporting for pods with quotas

### Session Token Caching
- Implement session token caching in /etc/pve/priv/purestorage/
- Automatic token refresh at 80% of TTL to prevent expiration
- In-memory and file-based caching with jitter to prevent thundering herd

### Debug Logging
- Add configurable debug logging with 4 levels (0-3)
- Support both config parameter and PURESTORAGE_DEBUG environment variable

## Bug Fixes
- Fix volume deletion when connected to multiple hosts
- Query all connections before destroy
- Disconnect from all hosts on all arrays
- Prevents "Cannot destroy volume because it is currently connected" error

## CI/CD Improvements
- Add workflow_dispatch trigger to checks workflow
- Add option to check all files or only changed files
- Add comprehensive markdown linting with markdownlint-cli2

## Testing
- Add token caching tests (tests/token_cache_test.pl)
- Test token validation, expiration, and race conditions
- Test cleanup of expired cache files

## Refactoring (#72)
- Refactor volume removal logic to handle multiple host connections
- Improve device cleanup sequence (LVM, partitions, multipath)
- Extract connection querying logic before volume destruction
- Refactor CI/CD workflows for better maintainability and flexibility
- Improve error handling and logging throughout the plugin
- Enhance Active Cluster support with proper multi-array operations

## Code Formatting
- Format all Perl files with perltidy using .perltidyrc configuration
- Ensure consistent code style across the codebase
- Fix formatting issues in PureStoragePlugin.pm and test files

## Documentation
- Update README with new functionality
2026-01-17 17:20:28 +05:00

167 lines
5.3 KiB
YAML

name: Lint
run-name: Lint ${{ inputs.enable-perl-lint && 'Perl' || '' }} ${{ inputs.enable-markdown-lint && 'Markdown' || '' }}
on:
workflow_call:
inputs:
enable-perl-lint:
description: 'Enable Perl linting'
required: false
type: boolean
default: false
enable-markdown-lint:
description: 'Enable Markdown linting'
required: false
type: boolean
default: false
perl-files:
description: 'List of changed Perl files'
required: false
type: string
default: ''
markdown-files:
description: 'List of changed Markdown files'
required: false
type: string
default: ''
jobs:
perl-lint:
name: Perl Lint
if: ${{ inputs.enable-perl-lint == true }}
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: '5.34'
- name: Install cpanm
run: |
curl -L https://cpanmin.us | perl - App::cpanminus
- name: Install linting tools
run: |
cpanm --notest Perl::Critic
sudo apt-get update
sudo apt-get install -y perltidy || true
- name: Check code formatting with perltidy
if: inputs.perl-files != ''
run: |
echo "Checking code formatting..."
changed_files="${{ inputs.perl-files }}"
if [ -z "$changed_files" ] || [ "$changed_files" == " " ]; then
echo "No Perl files to check"
exit 0
fi
if [ ! -f ".perltidyrc" ]; then
echo "Warning: .perltidyrc not found, using default perltidy settings"
fi
for file in $changed_files; do
if [[ -n "$file" ]] && ([[ "$file" == *.pm ]] || [[ "$file" == *.pl ]]); then
echo "Checking formatting: $file"
if command -v perltidy >/dev/null 2>&1; then
formatted_file="${file}.formatted"
if [ -f ".perltidyrc" ]; then
perltidy -pro=.perltidyrc "$file" -o "$formatted_file" 2>&1 || true
else
perltidy "$file" -o "$formatted_file" 2>&1 || true
fi
if [ -f "$formatted_file" ]; then
if ! diff -q "$file" "$formatted_file" >/dev/null 2>&1; then
echo "::error file=$file::File is not properly formatted. Run 'perltidy -pro=.perltidyrc $file' to fix."
echo "Differences:"
diff "$file" "$formatted_file" | head -20 || true
rm -f "$formatted_file"
exit 1
fi
rm -f "$formatted_file"
else
echo "Warning: perltidy failed to create formatted file for $file"
fi
else
echo "Warning: perltidy not found, skipping formatting check"
fi
fi
done
find . -name '*.formatted' -delete 2>/dev/null || true
- name: Run Perl::Critic (optional)
if: inputs.perl-files != ''
continue-on-error: true
run: |
echo "Running Perl::Critic static analysis..."
if command -v perlcritic >/dev/null 2>&1; then
changed_files="${{ inputs.perl-files }}"
if [ -z "$changed_files" ] || [ "$changed_files" == " " ]; then
echo "No Perl files to analyze"
exit 0
fi
for file in $changed_files; do
if [[ -n "$file" ]] && [[ "$file" == *.pm ]]; then
echo "Analyzing: $file"
perlcritic --quiet "$file" || true
fi
done
else
echo "Perl::Critic not available, skipping..."
fi
markdown-lint:
name: Markdown Lint
if: ${{ inputs.enable-markdown-lint == true }}
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install markdownlint
run: |
npm install -g markdownlint-cli2 || true
- name: Lint Markdown files
if: inputs.markdown-files != ''
run: |
echo "Linting Markdown files..."
changed_files="${{ inputs.markdown-files }}"
if [ -z "$changed_files" ] || [ "$changed_files" == " " ]; then
echo "No Markdown files to lint"
exit 0
fi
if command -v markdownlint-cli2 >/dev/null 2>&1; then
for file in $changed_files; do
if [[ -n "$file" ]] && [[ "$file" == *.md ]]; then
echo "Linting: $file"
markdownlint-cli2 "$file" "#node_modules" "#.git" || {
echo "::error file=$file::Markdown linting failed"
exit 1
}
fi
done
elif command -v markdownlint >/dev/null 2>&1; then
for file in $changed_files; do
if [[ -n "$file" ]] && [[ "$file" == *.md ]]; then
echo "Linting: $file"
markdownlint "$file" || {
echo "::error file=$file::Markdown linting failed"
exit 1
}
fi
done
else
echo "Markdown linter not available, skipping..."
fi