Skip to content

feat: enhance Namespace with missing policies#336

Merged
freeznet merged 6 commits into
mainfrom
freeznet/align-namespace-policy
Jul 24, 2025
Merged

feat: enhance Namespace with missing policies#336
freeznet merged 6 commits into
mainfrom
freeznet/align-namespace-policy

Conversation

@freeznet
Copy link
Copy Markdown
Member

(If this PR fixes a github issue, please add Fixes #<xyz>.)

Fixes #

(or if this PR is one task of a github issue, please add Master Issue: #<xyz> to link to the master issue.)

Master Issue: #

Motivation

Explain here the context, and why you're making that change. What is the problem you're trying to solve.

Modifications

Describe the modifications you've done.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@freeznet freeznet self-assigned this Jul 22, 2025
@freeznet freeznet requested review from a team as code owners July 22, 2025 15:27
@github-actions
Copy link
Copy Markdown
Contributor

@freeznet:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions github-actions Bot added the doc-info-missing This pr needs to mark a document option in description label Jul 22, 2025
@labuladong labuladong requested a review from Copilot July 23, 2025 07:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request enhances the PulsarNamespace resource with comprehensive policy configuration capabilities for rate limiting, storage management, security, and advanced features. The changes significantly expand the namespace configuration options available in the Pulsar operator.

  • Rate Limiting Support: Adds comprehensive rate limiting controls for dispatch, publish, and subscribe operations
  • Storage & Persistence Policies: Introduces BookKeeper persistence policies, compaction thresholds, and inactive topic management
  • Security Enhancements: Adds encryption requirements, producer validation, and subscription authentication modes

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/utils/spec.go Adds three new helper functions for creating PulsarNamespace test objects with different policy configurations
tests/operator/resources_test.go Comprehensive test coverage for new namespace policies including rate limiting, storage, and security configurations
pkg/connection/reconcile_namespace.go Updates namespace reconciliation to include all new policy fields
pkg/admin/interface.go Extends NamespaceParams interface with new policy configuration fields
pkg/admin/impl.go Implements actual Pulsar admin API calls for applying the new namespace policies
go.work.sum Updates Go module dependencies
go.mod Updates k8s.io/api dependency version
docs/pulsar_namespace.md Extensive documentation updates covering all new namespace policy options
config/crd/bases/resource.streamnative.io_pulsarnamespaces.yaml CRD definition updates with new fields and validation rules
api/v1alpha1/zz_generated.deepcopy.go Auto-generated deepcopy functions for new types
api/v1alpha1/pulsarnamespace_types.go Type definitions for new namespace policy structures

Comment thread tests/utils/spec.go
},
ReplicatorDispatchRate: &v1alpha1.DispatchRate{
DispatchThrottlingRateInMsg: ptr.To[int32](800),
DispatchThrottlingRateInByte: ptr.To[int64](838860), // ~800KB
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment '~800KB' is imprecise. The actual value 838860 bytes is approximately 819KB. Consider using a more accurate comment or adjusting the value to exactly 800KB (819200 bytes) for clarity.

Suggested change
DispatchThrottlingRateInByte: ptr.To[int64](838860), // ~800KB
DispatchThrottlingRateInByte: ptr.To[int64](838860), // ~819KB

Copilot uses AI. Check for mistakes.
Comment thread tests/utils/spec.go
retentionSize := resource.MustParse("50Gi")
bundle := int32(32)
var retentionTime rsutils.Duration = "48h"
var backlogQuotaTime rsutils.Duration = "24h" // Must be less than retentionTime to avoid conflicts
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment indicates backlogQuotaTime 'Must be less than retentionTime to avoid conflicts', but retentionTime is 48h and backlogQuotaTime is 24h, which satisfies this constraint. However, this business rule should be enforced through validation rather than relying on comments and manual verification.

Suggested change
var backlogQuotaTime rsutils.Duration = "24h" // Must be less than retentionTime to avoid conflicts
var backlogQuotaTime rsutils.Duration = "24h"
if backlogQuotaTime >= retentionTime {
panic("backlogQuotaTime must be less than retentionTime to avoid conflicts")
}

Copilot uses AI. Check for mistakes.
Comment thread pkg/admin/impl.go
Comment on lines +679 to +680
} else {
// Remove anti-affinity group if not specified
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically removing the anti-affinity group when not specified could be unexpected behavior. Consider making this behavior explicit or configurable, as users might expect the existing anti-affinity group to be preserved when the field is omitted from updates.

Suggested change
} else {
// Remove anti-affinity group if not specified
} else if params.RemoveAntiAffinityGroup {
// Explicitly remove anti-affinity group if the flag is set

Copilot uses AI. Check for mistakes.
Comment thread pkg/admin/impl.go
Comment on lines +682 to +683
if err != nil && !IsNotFound(err) {
return err
Copy link

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling silently ignores 'not found' errors when removing anti-affinity groups, but other errors are returned without context. Consider adding logging or more descriptive error messages to help with debugging anti-affinity group management issues.

Suggested change
if err != nil && !IsNotFound(err) {
return err
if err != nil {
if IsNotFound(err) {
fmt.Printf("Anti-affinity group not found for namespace %s: %v\n", completeNSName, err)
} else {
return fmt.Errorf("failed to delete anti-affinity group for namespace %s: %w", completeNSName, err)
}

Copilot uses AI. Check for mistakes.
@freeznet freeznet merged commit 3a13e37 into main Jul 24, 2025
5 checks passed
@freeznet freeznet deleted the freeznet/align-namespace-policy branch July 24, 2025 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-info-missing This pr needs to mark a document option in description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants