Skip to content

XMover: Improve watermark percentage parsing with edge case handling #541

@coderabbitai

Description

@coderabbitai

Description

The watermark parsing logic in _parse_watermark_percentage method within cratedb_toolkit/admin/xmover/analysis/shard.py needs improvement to handle edge cases properly.

Problem

Currently, the function doesn't handle:

  • Negative percentage values
  • Percentage values greater than 100%
  • Invalid input that could cause parsing errors

This could lead to incorrect watermark calculations and potential issues in shard analysis.

Proposed Solution

Add validation to:

  1. Clamp values to valid range (0.0-100.0%)
  2. Log warnings for invalid values
  3. Return sensible defaults (85.0%) for invalid input
  4. Handle ValueError exceptions from float conversion

Context

This improvement was identified during code review of PR #523.

References:

Files to modify

  • cratedb_toolkit/admin/xmover/analysis/shard.py (lines ~682-700)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions