Skip to content

[pulsar-broker] Support of TopicLifecyclePolicies REST handler.#13195

Closed
ciaocloud wants to merge 3 commits intoapache:masterfrom
ciaocloud:topiclifecyclepolicies
Closed

[pulsar-broker] Support of TopicLifecyclePolicies REST handler.#13195
ciaocloud wants to merge 3 commits intoapache:masterfrom
ciaocloud:topiclifecyclepolicies

Conversation

@ciaocloud
Copy link
Contributor

@ciaocloud ciaocloud commented Dec 8, 2021

Originally authored by @merlimat, fixed for compatibility with 2.10 branch. (Note that with the first commit only, it would adapt to 2.9 branch)

Motivation

Support of TopicLifecyclePolicies REST handler.

Modifications

The added endpoint TopicLifecycle can be used during tenant creation time.
Both InactiveTopicPolicies and TopicLifecycle are fields declared in Policies. The InactiveTopicPolicies has a boolean value deleteWhileInactive which determines whether topics should be automatically deleted when inactive. We ask it to be same as that defined in TopicLifecycle, while TopicLifecycle additionally defines whether topics should be automatically created when there exists producer/consumer connection (which is oppose to being created explicitly with API).

Specifically, our changes include:

  • defined TopicLifecyclePolicies class
  • declared in Policies
  • reset new inactiveTopicPolicies with topicLifecycle info if one exists while initializing and updating PersistentTopic
  • added setter methods in broker-admin Namespaces.

Verifying this change

  • Make sure that the change passes the CI checks.

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

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): ( no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • no-need-doc

@github-actions
Copy link

github-actions bot commented Dec 8, 2021

@ciaocloud: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)

@ciaocloud ciaocloud force-pushed the topiclifecyclepolicies branch from 0235bad to fa9e21c Compare December 8, 2021 22:49
@ciaocloud ciaocloud changed the title Support of TopicLifecyclePolicies REST handler. [pulsar-broker] Support of TopicLifecyclePolicies REST handler. Dec 8, 2021
@ciaocloud ciaocloud force-pushed the topiclifecyclepolicies branch from fa9e21c to db047f1 Compare December 8, 2021 23:43
@Anonymitaet
Copy link
Member

Hi @ciaocloud is this a code cleanup work and do not need to update docs?

when submitting a PR, can you help provide a doc label (tick the box) in the PR template which contains info about doc? This helps others know more about the changes. Thanks
Documentation

Copy link
Contributor

@Jason918 Jason918 left a comment

Choose a reason for hiding this comment

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

I am confused about the relation between InactiveTopicPolicies and TopicLifecycle. Can you bring more details?

private boolean autoCreateTopics;

/**
* Whether topics should be automatically deleted when inactive, or rather or rather explicitly deleted through
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo "or rather or rather"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am confused about the relation between InactiveTopicPolicies and TopicLifecycle. Can you bring more details?

Both InactiveTopicPolicies and TopicLifecycle are fields declared in Policies.
The InactiveTopicPolicies has a boolean value deleteWhileInactive which determines whether topics should be automatically deleted when inactive.
We ask it to be same as that defined in TopicLifecycle, while TopicLifecycle also defines whether topics should be automatically created.
This endpoint is used during tenant creation time.

(Also would update the above in the PR description)

Copy link
Contributor

Choose a reason for hiding this comment

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

We ask it to be same as that defined in TopicLifecycle

How can you guarantee this? Current code clearly missed some part.

And I don't think it's a good design that we have two field defines the same things ( InactiveTopicPolicies#deleteWhileInactive and TopicLifecyclePolicies#autoDeleteTopics )

//If the topic-level policy already exists, the namespace-level policy cannot override the topic-level policy.
Optional<TopicPolicies> topicPolicies = getTopicPolicies();

if (data.topicLifecycle != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should update all topicPolicies values in updateTopicPolicyByNamespacePolicy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can definitely refactor it into the updateTopicPolicyByNamespacePolicy method in AbstractTopic, but as that method would be used by both PersistentTopic and NonPersistentTopic, not sure it is the right thing to do for the non-persistent one to update inactiveTopicPolices with topicLifecycle info. will need to double-check.

@github-actions
Copy link

github-actions bot commented Dec 9, 2021

@ciaocloud:Thanks for providing doc info!

@github-actions github-actions bot added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Dec 9, 2021
@ciaocloud ciaocloud force-pushed the topiclifecyclepolicies branch from db047f1 to 3e195fd Compare December 9, 2021 07:30
@ciaocloud ciaocloud force-pushed the topiclifecyclepolicies branch from 3e195fd to b110960 Compare December 9, 2021 07:45
@ciaocloud ciaocloud force-pushed the topiclifecyclepolicies branch from b110960 to d1434c5 Compare December 9, 2021 08:26
@ciaocloud ciaocloud marked this pull request as draft December 9, 2021 19:30
@ciaocloud ciaocloud force-pushed the topiclifecyclepolicies branch from 074e7ea to d62aba1 Compare December 9, 2021 19:38
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@tisonkun
Copy link
Member

Closed as stale and conflict. Please rebase and resubmit the patch if it's still relevant.

@tisonkun tisonkun closed this Dec 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs lifecycle/stale Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants