support topic compaction#331
Merged
Merged
Conversation
Contributor
|
@freeznet:Thanks for your contribution. For this PR, do we need to update docs? |
…ings - Added logging for creation and policy errors during topic application in `reconcile_topic.go`. - Increased timeout settings in tests for resource updates to ensure stability and reliability.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for the compactionThreshold field on PulsarTopic, enabling automatic topic compaction based on size.
- Added
CompactionThresholdto the API types, CRD schema, deep-copy logic, and sample. - Integrated
CompactionThresholdin admin interface, reconciliation logic, and live tests. - Enabled topic-level policies in the CI cluster configuration.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/utils/spec.go | Added MakePulsarTopicWithCompactionThreshold test helper |
| tests/operator/resources_test.go | New tests for create/update/remove of compaction threshold |
| pkg/connection/reconcile_topic.go | Include CompactionThreshold in TopicParams and log action |
| pkg/admin/interface.go | Exposed CompactionThreshold in TopicParams interface |
| pkg/admin/impl.go | Implemented SetCompactionThreshold policy call |
| config/samples/resource_v1alpha1_pulsartopic.yaml | Documented compactionThreshold in sample YAML |
| config/crd/bases/resource.streamnative.io_pulsartopics.yaml | Added CRD schema entry for compactionThreshold |
| api/v1alpha1/zz_generated.deepcopy.go | Generated deep-copy logic for CompactionThreshold |
| api/v1alpha1/pulsartopic_types.go | Defined optional CompactionThreshold field in spec |
| .ci/clusters/values.yaml | Enabled topicLevelPoliciesEnabled in broker config |
Comments suppressed due to low confidence (3)
tests/operator/resources_test.go:375
- The import alias
v1alphav1here is inconsistent with the rest of the code (which usesv1alpha1). Consider renaming tov1alpha1for clarity and consistency.
compactionTopic *v1alphav1.PulsarTopic
tests/operator/resources_test.go:412
- After updating the compaction threshold, add an assertion to verify
topic.Spec.CompactionThresholdequalsnewThresholdto ensure the field was persisted correctly.
topic.Spec.CompactionThreshold = &newThreshold
tests/operator/resources_test.go:431
- Add a test assertion after setting
CompactionThresholdtonilto confirm that the field has been removed from the spec.
topic.Spec.CompactionThreshold = nil
jiangpengcheng
approved these changes
Jul 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(If this PR fixes a github issue, please add
Fixes #<xyz>.)Fixes #56
(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
(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:)
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)