Commit Graph
12057 Commits
Author SHA1 Message Date
chrislu cf584a35ef Update server.go 2025-09-13 19:40:17 -07:00
chrislu f5871524be add debug messages 2025-09-13 19:04:17 -07:00
chrislu 8e69446112 fix tests 2025-09-13 18:49:04 -07:00
chrislu 368f526b9f fix Incorrect flexible version mapping 2025-09-13 18:36:39 -07:00
chrislu 93c3e0c784 fix tests 2025-09-13 18:27:35 -07:00
chrislu 2f040a0fe4 fix undefined method errors 2025-09-13 17:34:06 -07:00
chrislu d7e1c83ca8 Update Produce v2+ to store all records from batch to SMQ
Update Produce v2+ to store all records from batch to SMQ
2025-09-13 17:30:05 -07:00
chrislu a8bee174f4 Update fetch.go
Skip long-polling if any requested topic does not exist.
Only long-poll when MinBytes > 0, data isn’t available yet, and all topics exist.
Cap the long-polling wait to 1s in tests to prevent hanging on shutdown.
2025-09-13 17:14:51 -07:00
chrislu 9a4ad5047b Update handler.go
Busy fetch loop: Implemented basic long-polling in Fetch. If no data and min_bytes>0 with max_wait_ms>0, we wait up to max_wait_ms, and populate throttle_time_ms accordingly. This stops the rapid loop for kafka-go on empty partitions.
2025-09-13 16:55:56 -07:00
chrislu bbc8668fd6 Fix kafka-go client infinite polling loop 2025-09-13 16:39:55 -07:00
chrislu 78629d69c5 Delete IMPLEMENTATION_PHASES.md 2025-09-13 15:40:48 -07:00
chrislu 287c323fb6 Update IMPLEMENTATION_PHASES.md 2025-09-13 15:40:08 -07:00
chrislu 297c662191 Phase 7: Comprehensive error handling and edge cases
- Added centralized errors.go with complete Kafka error code definitions
- Implemented timeout detection and network error classification
- Enhanced connection handling with configurable timeouts and better error reporting
- Added comprehensive error handling test suite with 21 test cases
- Unified error code usage across all protocol handlers
- Improved request/response timeout handling with graceful fallbacks
- All protocol and E2E tests passing with robust error handling
2025-09-13 15:30:34 -07:00
chrislu 2e2ccbf488 Phase 6: Add basic flexible versions support
- Added flexible_versions.go with utilities for Kafka flexible versions (v3+)
- Implemented ParseRequestHeader for compact string parsing and tagged fields
- Added fallback mechanism in handler.go for backward compatibility
- Updated handleApiVersions to support flexible version responses
- Added comprehensive tests for flexible version utilities
- All protocol tests passing with robust error handling
2025-09-13 14:29:27 -07:00
chrislu 92d6bbe575 fmt 2025-09-13 14:15:42 -07:00
chrislu 82705a214f Update implementation phases: Phase 5 completed
- Phase 1 : SeaweedMQ record retrieval implemented
- Phase 2 : CreateTopics v0-v5 compliance implemented
- Phase 3 : ApiVersions matrix accuracy fixed
- Phase 4 : Consumer group protocol metadata parsing enhanced
- Phase 5 : Multi-batch Fetch concatenation support implemented (MaxBytes compliance, 17 tests)
- Ready to start Phase 6: Basic flexible versions support
2025-09-13 14:14:48 -07:00
chrislu 8762a1a4af Phase 5: Implement multi-batch Fetch concatenation support
Multi-batch Fetch support completed:

## Core Features
- **MaxBytes compliance**: Respects fetch request MaxBytes limits to prevent oversized responses
- **Multi-batch concatenation**: Properly concatenates multiple record batches in single response
- **Size estimation**: Pre-estimates batch sizes to optimize MaxBytes usage before construction
- **Kafka-compliant behavior**: Always returns at least one batch even if it exceeds MaxBytes (first batch rule)

## Implementation Details
- **MultiBatchFetcher**: New dedicated class for multi-batch operations
- **Intelligent batching**: Adapts record count per batch based on available space (10-50 records)
- **Proper concatenation format**: Each batch maintains independent headers and structure
- **Fallback support**: Graceful fallback to single batch if multi-batch fails

## Advanced Features
- **Compression ready**: Basic support for compressed record batches (GZIP placeholder)
- **Size tracking**: Tracks total response size and batch count across operations
- **Edge case handling**: Handles large single batches, empty responses, partial batches

## Integration & Testing
- **Fetch API integration**: Seamlessly integrated with existing handleFetch pipeline
- **17 comprehensive tests**: Multi-batch scenarios, size limits, concatenation format validation
- **E2E compatibility**: Sarama tests pass with no regressions
- **Performance validation**: Benchmarks for batch construction and multi-fetch operations

## Performance Improvements
- **Better bandwidth utilization**: Fills available MaxBytes space efficiently
- **Reduced round trips**: Multiple batches in single response
- **Adaptive sizing**: Smaller batches when space limited, larger when space available

Ready for Phase 6: Basic flexible versions support
2025-09-13 14:14:05 -07:00
chrislu 95fd10e743 Update implementation phases: Phase 4 completed
- Phase 1 : SeaweedMQ record retrieval implemented
- Phase 2 : CreateTopics v0-v5 compliance implemented
- Phase 3 : ApiVersions matrix accuracy fixed (OffsetFetch v0-v5, CreateTopics v0-v5)
- Phase 4 : Consumer group protocol metadata parsing enhanced (ClientHost, robust parsing)
- Ready to start Phase 5: Multi-batch Fetch concatenation support
2025-09-13 14:02:05 -07:00
chrislu 7149b723ec Phase 4: Implement consumer group protocol metadata parsing
Consumer Group Protocol Metadata completed:

## Core Enhancements
- **ClientHost extraction**: Real client IP/host instead of hardcoded 'unknown'
  - ExtractClientHost() extracts IP from connection context
  - Populates GroupMember.ClientHost with actual remote address
- **Enhanced protocol metadata parsing**: Robust parsing with error handling
  - ParseConsumerProtocolMetadata() with validation and graceful fallbacks
  - Handles malformed metadata, oversized fields, and edge cases
- **Improved assignment strategy selection**: Priority-based protocol selection
  - SelectBestProtocol() prefers sticky > roundrobin > range
  - Considers both client capabilities and existing group protocols

## Implementation Details
- **Connection Context**: Added ConnectionContext to Handler for client info
- **Metadata Analysis**: AnalyzeProtocolMetadata() for detailed debugging
- **Enhanced Subscription Extraction**: ExtractTopicsFromMetadata() with fallbacks
- **Validation**: SanitizeConsumerGroupID() prevents malformed group IDs
- **Graceful Error Handling**: Invalid metadata handled without failures

## New Files
- : Core metadata parsing and client context logic
- : Comprehensive test suite (17 test cases)

## Integration
- **JoinGroup enhancement**: Uses real client host and robust metadata parsing
- **Backward compatibility**: Legacy methods maintained for compatibility
- **Debug improvements**: Enhanced logging shows parsed protocol details

## Testing & Verification
- **17 comprehensive tests**: Protocol parsing, client host extraction, strategy selection
- **Edge case coverage**: Empty metadata, malformed data, oversized fields
- **E2E compatibility**: Sarama tests pass, no regressions
- **Performance validation**: Benchmark tests for parsing operations

Ready for Phase 5: Multi-batch Fetch concatenation support
2025-09-13 14:01:28 -07:00
chrislu 1bfb261836 Update implementation phases: Phase 3 completed
- Phase 1 : SeaweedMQ record retrieval implemented
- Phase 2 : CreateTopics v0-v5 compliance implemented
- Phase 3 : ApiVersions matrix accuracy fixed (OffsetFetch v0-v5, CreateTopics v0-v5)
- Ready to start Phase 4: Consumer group protocol metadata parsing
2025-09-13 13:50:41 -07:00
chrislu 71769da3b4 Phase 3: Fix ApiVersions matrix accuracy and version validation
ApiVersions Matrix Accuracy completed:

## Critical Fixes
- **OffsetFetch API**: Updated advertised from v0-v2 to v0-v5 (MAJOR fix)
  - Implementation already supported v3+ throttle_time_ms and v5+ leader_epoch
  - Clients can now use advanced OffsetFetch features
- **CreateTopics API**: Updated advertised from v0-v4 to v0-v5 (minor fix)
  - Implementation already routed v5 requests to v2+ handler
  - Better client compatibility for v5 CreateTopics requests

## Implementation
- **handleApiVersions()**: Corrected advertised max versions
- **validateAPIVersion()**: Updated validation ranges to match advertisements
- **Consistency**: Eliminated mismatch between advertised vs implemented versions

## Testing & Verification
- **Comprehensive test suite**: 6 new tests in api_versions_test.go
- **Version validation tests**: OffsetFetch v3-v5 and CreateTopics v5 now accepted
- **End-to-end verification**: E2E tests still pass, no regressions
- **API audit documentation**: Complete version matrix in API_VERSION_MATRIX.md

## Impact
- **Client compatibility**: Higher-version clients can now connect properly
- **Feature utilization**: Advanced features like leader epoch, throttle time accessible
- **Protocol compliance**: Advertised versions now match actual implementation
- **Future-proofing**: Clear process for managing API version accuracy

Ready for Phase 4: Consumer group protocol metadata parsing
2025-09-13 13:50:10 -07:00
chrislu bd8f57f2bb Update implementation phases: Phase 1 & 2 completed
- Phase 1 : SeaweedMQ record retrieval implemented
- Phase 2 : CreateTopics v0-v5 compliance implemented
- Ready to start Phase 3: ApiVersions matrix accuracy
2025-09-13 13:19:30 -07:00
chrislu 5d0c45c9dc Phase 2: Implement CreateTopics protocol compliance for v0/v1
CreateTopics Protocol Compliance completed:

## Implementation
- Implement handleCreateTopicsV0V1() with proper v0/v1 request parsing
- Support regular array/string format (not compact) for v0/v1
- Parse topic name, partitions, replication factor, assignments, configs
- Handle timeout_ms and validate_only fields correctly
- Maintain existing v2+ compact format support
- Wire to SeaweedMQ handler for actual topic creation

## Key Features
- Full v0-v5 CreateTopics API version support
- Proper error handling (TOPIC_ALREADY_EXISTS, INVALID_PARTITIONS, etc.)
- Partition count validation and enforcement
- Compatible with existing SeaweedMQ topic management

## Tests
- Comprehensive unit tests for v0/v1/v2+ parsing
- Error condition testing (duplicate topics, invalid partitions)
- Multi-topic creation support
- Integration tests across all API versions
- Performance benchmarks for CreateTopics operations

## Verification
- All protocol tests pass (v0-v5 CreateTopics)
- E2E Sarama tests continue to work
- Real topics created with specified partition counts
- Proper error responses for edge cases

Ready for Phase 3: ApiVersions matrix accuracy
2025-09-13 13:18:54 -07:00
chrislu c9f3935e7b Phase 1: Implement SeaweedMQ record retrieval in GetStoredRecords
Core SeaweedMQ Integration completed:

## Implementation
- Implement SeaweedMQHandler.GetStoredRecords() to retrieve actual records from SeaweedMQ
- Add SeaweedSMQRecord wrapper implementing offset.SMQRecord interface
- Wire Fetch API to use real SMQ records instead of synthetic batches
- Support both agent and broker client connections for record retrieval

## Key Features
- Proper Kafka offset mapping from SeaweedMQ records
- Respects maxRecords limit and batch size constraints
- Graceful error handling for missing topics/partitions
- High water mark boundary checking

## Tests
- Unit tests for SMQRecord interface compliance
- Edge case testing (empty topics, offset boundaries, limits)
- Integration with existing end-to-end Kafka tests
- Benchmark tests for record accessor performance

## Verification
- All integration tests pass
- E2E Sarama test shows 'Found X SMQ records' debug output
- GetStoredRecords now returns real data instead of TODO placeholder

Ready for Phase 2: CreateTopics protocol compliance
2025-09-13 13:12:32 -07:00
chrislu dec63c22e4 Add Kafka gateway implementation phases roadmap
- Document 7 phases of implementation from high to low priority
- Phase 1: Core SeaweedMQ integration for real message retrieval
- Phase 2: CreateTopics protocol compliance
- Phase 3: ApiVersions matrix accuracy
- Phase 4: Consumer group protocol metadata parsing
- Phase 5: Multi-batch Fetch support
- Phase 6: Flexible versions support
- Phase 7: Error handling and edge cases

Ready to start Phase 1 implementation.
2025-09-13 13:09:44 -07:00
chrislu c0b15ed489 refactoring 2025-09-13 13:03:51 -07:00
chrislu 964d1d06e4 fix TestSaramaProduceConsume 2025-09-13 11:06:29 -07:00
chrislu 42aea1dc68 align package decoding 2025-09-13 10:23:14 -07:00
chrislu ba48ea9c4c fix samara 2025-09-13 09:58:53 -07:00
chrislu 445d7343d7 fix v7 samara 2025-09-13 09:06:02 -07:00
chrislu 4f0dd2e527 fix kafka tests 2025-09-13 08:55:18 -07:00
chrislu 6eafc87413 fix remaining tests 2025-09-13 08:47:46 -07:00
chrislu ba1599b1e9 fix tests 2025-09-13 08:31:16 -07:00
chrislu 8743c5453a clean up connections 2025-09-13 08:17:20 -07:00
chrislu 9ea6ef0bf8 fix tests 2025-09-13 08:06:36 -07:00
chrislu ccd48feefb fix test errors 2025-09-13 00:17:54 -07:00
chrislu cce9d8a365 Remove s3tests patches - upstream repo now fixed
- Remove _create_objects patches since upstream s3-tests resolved NameError
- SeaweedFS strong consistency should eliminate 404 errors
- Let tests run naturally to detect real issues
2025-09-12 23:52:01 -07:00
chrislu c67e3255d9 Revert "Update s3tests.yml"
This reverts commit 117bcaa4b1.
2025-09-12 23:51:07 -07:00
chrislu e6f7e7efb5 fix in-memory variables 2025-09-12 23:50:07 -07:00
chrislu 78382b380e Merge branch 'master' into feature/mq-kafka-gateway-m1 2025-09-12 23:14:14 -07:00
chrislu 56aa5278af single mode 2025-09-12 23:13:41 -07:00
chrislu 3fa024479e remove TestMode 2025-09-12 23:04:41 -07:00
chrislu ba73939ca2 fixes 2025-09-12 23:02:10 -07:00
chrislu 16e014f360 start tests 2025-09-12 22:45:06 -07:00
chrislu 30b21abab9 fix kafka tests 2025-09-12 22:44:56 -07:00
chrislu c951fc03c1 Update smq_mapping_test.go 2025-09-12 22:44:36 -07:00
chrislu a342ede4cd Update go.sum 2025-09-12 22:11:04 -07:00
chrislu 117bcaa4b1 Update s3tests.yml 2025-09-12 22:10:08 -07:00
chrislu a424bfa3ce docker compose 2025-09-12 22:08:00 -07:00
chrislu e21c89d062 fix tests 2025-09-12 22:04:18 -07:00