Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure policies.is_allow_auto_update_schema not null #14409

Merged

Conversation

wangjialing218
Copy link
Contributor

Motivation

Follow code works fine on 2.8.x but get NPE on 2.9.x

Policies policies = pulsarAdmin.namespaces().getPolicies("namespacePath");
boolean allowedAutoupdateSchema = policies.is_allow_auto_update_schema;

Becasue Policies.is_allow_auto_update_schema changed from boolean to Boolean by #12786 and default value is null.
This may cause user's service fail when upgrade pulsar from 2.8.x to 2.9.x

Modifications

Make sure Policies.is_allow_auto_update_schema not null when call getPolicies

Documentation

  • no-need-doc

    Just keep behaviour same between 2.8.x and 2.9.x

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Feb 22, 2022
@wangjialing218
Copy link
Contributor Author

/pulsarbot run-failure-checks

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

We are used to allow getting the configuration merged with the global configuration using 'applied' parameter.

I can't give pointers now, but you can learn learn 'applied' in other APIs

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.

We can add a new interface Policies getPolicies(String namespace, boolean applied) in org.apache.pulsar.client.admin.Namespaces. And set applied as true by default in getPolicies(String namespace).

In broker, add a new parameter @QueryParam("applied") @DefaultValue("true") boolean applied in org.apache.pulsar.broker.admin.v2.Namespaces#getPolicies.

NOTE: you may need to update other policies filed to applied value too.

@codelipenghui
Copy link
Contributor

We can add a new interface Policies getPolicies(String namespace, boolean applied) in org.apache.pulsar.client.admin.Namespaces. And set applied as true by default in getPolicies(String namespace).

the applied option should be false by default? to keep consistent with topic policy does. It's better to start with a PIP, as far as I understand, not all the namespace policies follow the same way, some return null if the namespace doesn't have the policy, some return value from broker level, we need to improve this situation even if the inevitable break change may be introduced, otherwise, we will always be confused by different behaviors.

We should add a release notice for #12786

@Jason918
Copy link
Contributor

the applied option should be false by default?

This default value is just for backward compatible. And we can even deprecate method getPolicies(String namespace).
For user with new version of client and broker, the applied parameter should always be provided by user.
Just one option to keep compatibility.

@codelipenghui
Copy link
Contributor

This default value is just for backward compatible. And we can even deprecate method getPolicies(String namespace).
For user with new version of client and broker, the applied parameter should always be provided by user.
Just one option to keep compatibility.

I see, we have to make tradeoffs here, maybe we should make API follow the same pattern in 3.0

@codelipenghui
Copy link
Contributor

@gaoran10 @michaeljmarshall Please help check this PR, which is fixing a breaking change in the ongoing release 2.8.3, 2.9.2, and 2.10.0. And @wangjialing218 also shared the information under the 2.9.2 VOTE3 email thread, we need to decide as soon as possible whether to start a new round RC.

@michaeljmarshall
Copy link
Member

@codelipenghui - thanks for tagging me. Looking now.

codelipenghui
codelipenghui previously approved these changes Feb 23, 2022
Copy link
Contributor

@codelipenghui codelipenghui left a comment

Choose a reason for hiding this comment

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

The change looks good to me, just left a minor comment.

Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

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

I believe this solution is incomplete. I think we also need to update this method defined on line 517 in the same class:

protected Policies getNamespacePolicies(String tenant, String cluster, String namespace)

@michaeljmarshall
Copy link
Member

I believe this solution is incomplete. I think we also need to update this method defined on line 517 in the same class:

protected Policies getNamespacePolicies(String tenant, String cluster, String namespace)

After looking at the code a bit more, it appears that updating the second getNamespacePolicies method is unnecessary. However, it would probably be appropriate to keep things consistent.

@michaeljmarshall
Copy link
Member

the applied option should be false by default?

This default value is just for backward compatible. And we can even deprecate method getPolicies(String namespace). For user with new version of client and broker, the applied parameter should always be provided by user. Just one option to keep compatibility.

This makes sense to me. Do you think we need to add the applied logic to this PR @Jason918?

@wangjialing218
Copy link
Contributor Author

I believe this solution is incomplete. I think we also need to update this method defined on line 517 in the same class:

protected Policies getNamespacePolicies(String tenant, String cluster, String namespace)

After looking at the code a bit more, it appears that updating the second getNamespacePolicies method is unnecessary. However, it would probably be appropriate to keep things consistent.

@michaeljmarshall Done, the second method was duplicated code from first one.

@michaeljmarshall
Copy link
Member

@wangjialing218 - great, I thought those methods looked similar, but I didn't look closely enough to see the one was a duplicate. Thanks for fixing that.

@codelipenghui codelipenghui added this to the 2.10.0 milestone Feb 23, 2022
codelipenghui
codelipenghui previously approved these changes Feb 23, 2022
Copy link
Member

@michaeljmarshall michaeljmarshall left a comment

Choose a reason for hiding this comment

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

I don't have a strong opinion regarding the applied flag. I think we could probably add it to this endpoint without breaking the API for 2.10. I am interested to know what @eolivelli has to say.

I am +1 on the PR when ignoring the question of the applied flag.

eolivelli
eolivelli previously approved these changes Feb 23, 2022
@eolivelli
Copy link
Contributor

We can go with the current form from my opinion.
I would like to see the 'applied' version of the function some day.

Let's unblock the release.

Jason918
Jason918 previously approved these changes Feb 23, 2022
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.

LGTM

@wangjialing218
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui
Copy link
Contributor

We can go with the current form from my opinion.
I would like to see the 'applied' version of the function some day.

Agree, maybe we can plan to 2.11

@codelipenghui
Copy link
Contributor

@eolivelli @Jason918 @michaeljmarshall Please help review again

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

+1

@eolivelli eolivelli merged commit 7d60795 into apache:master Feb 23, 2022
codelipenghui pushed a commit that referenced this pull request Feb 24, 2022
codelipenghui pushed a commit that referenced this pull request Feb 24, 2022
michaeljmarshall pushed a commit that referenced this pull request Feb 24, 2022
@michaeljmarshall michaeljmarshall added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Feb 24, 2022
nicoloboschi pushed a commit to nicoloboschi/pulsar that referenced this pull request Mar 1, 2022
@gaoran10 gaoran10 added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Mar 2, 2022
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
Technoboy- added a commit to Technoboy-/pulsar that referenced this pull request May 10, 2022
Technoboy- added a commit to Technoboy-/pulsar that referenced this pull request May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/admin cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.3 release/2.9.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants