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

Fix is Instance enabled #2972

Merged
merged 4 commits into from
Dec 5, 2024
Merged

Fix is Instance enabled #2972

merged 4 commits into from
Dec 5, 2024

Conversation

xyuanlu
Copy link
Contributor

@xyuanlu xyuanlu commented Nov 26, 2024

Issues

  • My PR addresses the following Helix issues and references them in the PR description:

#2975

Description

  • Here are some details about my PR, including screenshots of any UI changes:

Helix deprecated the HELIX_ENABLED and added a new InstanceOperation field.
If an instance is disabled using InstanceOperation but enabled using setting HELIX_ENABLED to true (by helix lib with old version), IsInstanceEnabled will return false.
When HELIX_ENABLED is true, but InstanceOperation is DISABLED, IsInstanceEnabled returns false. Where it should return true.

Tests

  • The following tests are written for this issue:

testEnabledInstanceBackwardCompatibility

  • The following is the result of the "mvn test" command on the appropriate module:

(If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)

Changes that Break Backward Compatibility (Optional)

  • My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:

(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)

Documentation (Optional)

  • In case of new functionality, my PR adds documentation in the following wiki page:

(Link the GitHub wiki you added)

Commits

  • My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Code Quality

  • My diff has been formatted using helix-style.xml
    (helix-style-intellij.xml if IntelliJ IDE is used)

Comment on lines 661 to 662
// it is not likely that instanceEnabled is unset, because when we set operation to disable,
// we always set instanceEnabled to false
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please clarify the comments? Does 'InstanceEnabled' refer to 'HELIX_ENABLED'?

@xyuanlu xyuanlu marked this pull request as ready for review December 2, 2024 23:05
// If instance is enabled by old version helix (not having instance operation), the instance config
// will have HELIX_ENABLED set to true. In this case, we should override the instance operation to ENABLE
if ("true".equals(_record.getSimpleField(InstanceConfigProperty.HELIX_ENABLED.name()))) {
return new InstanceOperation.Builder().setOperation(InstanceConstants.InstanceOperation.ENABLE).build();
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we write it back?

Copy link
Contributor Author

@xyuanlu xyuanlu Dec 3, 2024

Choose a reason for hiding this comment

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

good point. But it is a bit hard to write back. We do not have access to ZK client or data accessor here. It adds too much complexity. As long as all new/old reader honor the HELIX_ENABLED then I think we are good.

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 think it might be dangerous to write back as client may update the config while we write back. It could overwrite the current value. (Unlike the batch enable/disable one as that field is deprecated and we just need to clean it out)

Since the getter will use the HELIX_ENABLED and is compatible with both new/old client before instance operation, I think it is safe to keep it the current way.

@xyuanlu
Copy link
Contributor Author

xyuanlu commented Dec 5, 2024

This change is approved by @junkaixue
Commit message:
Fix IsInstanceEnabled for backward compatibility

@xyuanlu xyuanlu merged commit bde8ff8 into apache:master Dec 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants