Skip to content

Adds the bookie cookie service for http api #4541

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

Closed
wants to merge 1 commit into from

Conversation

SongOf
Copy link

@SongOf SongOf commented Dec 30, 2024

Descriptions of the changes in this PR:

Motivation
It would be convenient to support get, or delete the cookie of bookie with REST API, just like what does in the shell command.

Changes
Adds an API to get, delete the cookie of bookie at /api/v1/bookie/cookie.

@congbobo184
Copy link
Contributor

@zymap @eolivelli @hangc0276 @horizonzy please help review this pr, thanks.

@liangyuanpeng
Copy link

liangyuanpeng commented Dec 31, 2024

@SongOf
Copy link
Author

SongOf commented Dec 31, 2024

seems like it is working for BP-68

seems like it is working for BP-68

Yes, there are two http apis. But both are used to delete the decommissioned bookie's cookie information. BP-68 will delete cookie as part of decommission API. This API("/api/v1/bookie/cookie") is invoked by the operation and maintenance platform to delete cookies after detecting that the bookie is decommissioned.

case GET:
Versioned<Cookie> cookie = Cookie.readFromRegistrationManager(registrationManager, bookieId);
return new HttpServiceResponse(cookie.toString(), HttpServer.StatusCode.OK);
case DELETE:
Copy link
Member

Choose a reason for hiding this comment

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

There is nothing wrong with adding new interfaces,

but I think deleting cookies is a bit risky and does not comply with data integrity specifications. Although this is available in the old Command command, I suggest you still go through the node offline process ./bin/bookkeeper shell decommissionbookie [-bookieid <bookieaddress>]

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, the caller should call this api only after bookie decommission is completed.

Copy link
Member

@StevenLuMT StevenLuMT left a comment

Choose a reason for hiding this comment

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

LGTM

case GET:
Versioned<Cookie> cookie = Cookie.readFromRegistrationManager(registrationManager, bookieId);
return new HttpServiceResponse(cookie.toString(), HttpServer.StatusCode.OK);
case DELETE:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not add a method to add a cookie while we have a method to delete a cookie.

Copy link
Author

Choose a reason for hiding this comment

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

Already added

@StevenLuMT
Copy link
Member

ci failed,please check @SongOf

Copy link
Contributor

@dlg99 dlg99 left a comment

Choose a reason for hiding this comment

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

Deleting a cookie without validation that decomm is done can be an expensive operator error. I think the command must check for that (as with node decommission, make sure node is offline). So I fully support this concern https://github.com/apache/bookkeeper/pull/4541/files#r1955442058 and disagree with idea of making it an operator's problem.

Alternatively, we can expose recover command as a sequence of

  • switch target node into the read-only mode
  • run recover command
  • run recover command (double-check) with the cookie delete option

the gotcha here is that only one recover must run at a time in my experience, but I think the same is valid for decomm command.

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.

This PR is adding an API that can execute only if the service is up and running.

It seems dangerous to override the cookies or even deleting it while the service is alive.

What's your usecase?

@SongOf
Copy link
Author

SongOf commented Feb 24, 2025

This PR is adding an API that can execute only if the service is up and running.

It seems dangerous to override the cookies or even deleting it while the service is alive.

What's your usecase?

my user case:
1、bookie A has been decommissioned by /api/v1/autorecovery/decommission.
2、check decommission has been completed by /api/v1/autorecovery/list_under_replicated_ledger. But the cookie of bookie A is not deleted.
3、The new bookie container is expanded, but has the same IP as bookie A. As a result, the new bookie cannot run normally.
Therefore, after bookie A completes decommission, its cookies should also be deleted.

@StevenLuMT
Copy link
Member

I think this may be an abnormal case of decommission, but you want to open the cookie interface now, which is not a good way. Covering up the error will only cover up the problem. It is better to check why decommission did not clean up the cookies and solve the problem from the source.

@StevenLuMT
Copy link
Member

I suggest temporarily closing this PR and reopening it later if necessary.

@StevenLuMT StevenLuMT closed this Apr 16, 2025
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.

7 participants