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

Add monitor backup API endpoint #10418

Merged
merged 3 commits into from
Sep 26, 2022
Merged

Add monitor backup API endpoint #10418

merged 3 commits into from
Sep 26, 2022

Conversation

npepinpe
Copy link
Member

Description

This PR extends the backup management endpoint to add a monitoring API under GET /{id} (e.g. if the actuator is at http://localhost:9600/actuator/backups, then GET http://localhost:9600/actuator/backups/{id}).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old BackupIT tests, those were deleted.

Related issues

closes #9902

Definition of Done

Not all items need to be done depending on the issue and the pull request.

Code changes:

  • The changes are backwards compatibility with previous versions
  • If it fixes a bug then PRs are created to backport the fix to the last two minor versions. You can trigger a backport by assigning labels (e.g. backport stable/1.3) to the PR, in case that fails you need to create backports manually.

Testing:

  • There are unit/integration tests that verify all acceptance criterias of the issue
  • New tests are written to ensure backwards compatibility with further versions
  • The behavior is tested manually
  • The change has been verified by a QA run
  • The impact of the changes is verified by a benchmark

Documentation:

  • The documentation is updated (e.g. BPMN reference, configuration, examples, get-started guides, etc.)
  • New content is added to the release announcement
  • If the PR changes how BPMN processes are validated (e.g. support new BPMN element) then the Camunda modeling team should be informed to adjust the BPMN linting.

Please refer to our review guidelines.

@npepinpe
Copy link
Member Author

This PR is blocked by #10411 - please review that first.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 20, 2022

Test Results

   926 files  +    1     926 suites  +1   2h 2m 45s ⏱️ + 2m 36s
7 227 tests  - 148  7 217 ✔️  - 148  10 💤 ±0  0 ±0 
7 415 runs   - 148  7 405 ✔️  - 148  10 💤 ±0  0 ±0 

Results for commit 2cf33e7. ± Comparison against base commit c7baaf4.

♻️ This comment has been updated with latest results.

@npepinpe
Copy link
Member Author

I'm confused why these changes would cause so many flaky tests that are unrelated to backups.

@npepinpe npepinpe force-pushed the 9901-take-backup branch 4 times, most recently from 6366355 to a9aa867 Compare September 21, 2022 12:45
Base automatically changed from 9901-take-backup to main September 21, 2022 13:36
Copy link
Member

@lenaschoenburg lenaschoenburg left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

I guess as long as we can change the return types in a backwards compatible manner we don't need to do any type conversion 🤷

@npepinpe
Copy link
Member Author

Right now they happen to match. So as long as we don't change them, 👌 This means we should work on improving the API now and not in a year, as the longer we wait the higher the likelihood of us needing to change these internal types. That said, I did look at them, and while they're internal, they're only used for this specific use case, so the likelihood that we change them is probably quite low 😄

@npepinpe
Copy link
Member Author

bors merge

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 21, 2022
10418: Add monitor backup API endpoint r=npepinpe a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



10428: Remove the extra submit from ProcessingScheduleServiceImpl r=Zelldon a=Zelldon

## Description


And another round! 😁 After #10414 and #10390 
I think I found a good way to replace the additional Actor#submit from the production code and move it to where it is necessary in tests.

As described here #10414 (comment) it is not easily possible to create a separate Actor for the ScheduleService, due to concurrency issues and further work we would need to do here.

## Details

In this PR I iterate over the ProcessingScheduleServiceImpl and remove the StreamProcessorContext from the constructor.
The service gets all necessary dependencies injected on the constructor (except the actor), mostly as suppliers. This allows to lazy load dependencies and reduce dependencies for tests. It allowed to write some more unit-test like tests.

The service gets an open method to initialize the service with the actor control and create its own writer. This allows us to no longer share the writer with the StreamProcessor, since this might lead to issues especially if we now run in between (during processing phases).

Due to the later initializing of the writers we reduce resources on followers, if the service is never scheduled we don't need to create a writer.

When the StreamProcessor is in the closing phase it will close the scheduled service as well.
<!-- Please explain the changes you made here. -->

## Related issues

<!-- Which issues are closed by this PR or are related -->

closes #10414
closes #10390 
closes #10291



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed (retrying...):

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 21, 2022
10418: Add monitor backup API endpoint r=npepinpe a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed:

@npepinpe
Copy link
Member Author

bors r+

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 21, 2022
10418: Add monitor backup API endpoint r=npepinpe a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed:

@npepinpe
Copy link
Member Author

bors r+

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 22, 2022
10418: Add monitor backup API endpoint r=npepinpe a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
@npepinpe
Copy link
Member Author

bors r- (networking issues on GitHub hosted runners, cool stuff)
bors r+

@zeebe-bors-camunda
Copy link
Contributor

Canceled.

@npepinpe
Copy link
Member Author

bors r+

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 22, 2022
10418: Add monitor backup API endpoint r=npepinpe a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
@zeebe-bors-camunda
Copy link
Contributor

Already running a review

@zeebe-bors-camunda
Copy link
Contributor

Timed out.

@npepinpe
Copy link
Member Author

bors r+

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 22, 2022
10418: Add monitor backup API endpoint r=npepinpe a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
@npepinpe
Copy link
Member Author

Guess it will time out again

@npepinpe
Copy link
Member Author

Anyway one of the job failed since it couldn't fetch a dependency.

@npepinpe
Copy link
Member Author

bors r-

@zeebe-bors-camunda
Copy link
Contributor

Canceled.

@lenaschoenburg
Copy link
Member

bors r+

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 22, 2022
10412: Add a standalone app that can be used to restore a broker from a backup r=oleschoenburg a=deepthidevaki

## Description

* Added a new module for restore. 
* Adds a RestoreManager that coordinates restoring of all partitions. It first determines which partitions to restore from based on the given `BrokerCfg`. This configuration must be the same one used by the Broker when it is started after the restore. Because of this, restore module depens on broker module. But since it needs access to the configuration and `RaftPartitionGroupFactory`, there is no other way. There is scope of splitting broker to take these shared configs out of it.
* Added a `RestoreApp` in dist. My plan was to add it in restore module. But it needs access to BrokerConfig, which is built in dist. So the app is added to dist module. Alternative is to copy components `BrokerConfiguration` and `WorkerDirectory` to restore module. 
* The backup id to restore from is passed as a command line argument `--backupId=x`. This is parsed by spring boot. I decided to keep it simple for now, since we are planning to release it as experimental feature anyway. If we decide to support this app long term, then I suggest to switch to something like picocli that we use in zdb.

A basic test to verify a broker can be restored is added. More scenarios should be added later.

PS:- App is not added to the distribution yet.

## Related issues

related #10263 



10418: Add monitor backup API endpoint r=oleschoenburg a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



10443: Do not take a backup if it already exists r=oleschoenburg a=deepthidevaki

## Description

After restore, the log is truncated to the checkpoint position. So the checkpoint record is processed again and will trigger a new backup with the same Id of the backup it restored from. With this PR, `BackupService` handles this case gracefully. In addition, we also do not take a new backup if existing backup is failed or in progress. Alternatively, we can delete this backup and take a new one. But chances of it happening (i.e triggering a new backup when one already is in progress/failed) is very low. So we can keep this simple.

## Related issues

closes #10430 



Co-authored-by: Deepthi Devaki Akkoorath <deepthidevaki@gmail.com>
Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed (retrying...):

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 22, 2022
10418: Add monitor backup API endpoint r=oleschoenburg a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



10443: Do not take a backup if it already exists r=oleschoenburg a=deepthidevaki

## Description

After restore, the log is truncated to the checkpoint position. So the checkpoint record is processed again and will trigger a new backup with the same Id of the backup it restored from. With this PR, `BackupService` handles this case gracefully. In addition, we also do not take a new backup if existing backup is failed or in progress. Alternatively, we can delete this backup and take a new one. But chances of it happening (i.e triggering a new backup when one already is in progress/failed) is very low. So we can keep this simple.

## Related issues

closes #10430 



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
Co-authored-by: Deepthi Devaki Akkoorath <deepthidevaki@gmail.com>
@zeebe-bors-camunda
Copy link
Contributor

This PR was included in a batch that timed out, it will be automatically retried

zeebe-bors-camunda bot added a commit that referenced this pull request Sep 22, 2022
10418: Add monitor backup API endpoint r=oleschoenburg a=npepinpe

## Description

This PR extends the backup management endpoint to add a monitoring API under `GET /{id}` (e.g. if the actuator is at `http://localhost:9600/actuator/backups`, then `GET http://localhost:9600/actuator/backups/{id}`).

At the moment we use the internal types provided by the broker client as the response types, but in the future this will be replaced by the OpenAPI generated types. As such, I didn't think it was necessary to create user facing types and write some mapping code, since we will scrape it and replace it. However, I understand that we don't know when that will done, so I'm open to doing it anyway for safety.

The acceptance tests were updated (and renamed to better reflect what they do), and as they overlap with the old `BackupIT` tests, those were deleted.

## Related issues

closes #9902 



Co-authored-by: Nicolas Pepin-Perreault <nicolas.pepin-perreault@camunda.com>
@zeebe-bors-camunda
Copy link
Contributor

Build failed:

@deepthidevaki
Copy link
Contributor

bors merge

@zeebe-bors-camunda
Copy link
Contributor

Merge conflict.

@deepthidevaki deepthidevaki self-assigned this Sep 26, 2022
@deepthidevaki
Copy link
Contributor

I will resolve the conflict and get this PR merged.

Adds a new actuator endpoint to get the status of a backup. This
endpoint is simply `GET /{id}` of the backup under whichever route the
actuator is set up.

Currently we do not do any response mapping and use the gateway types
directly. While this is not a good approach long term (as it exposes
internal types), this is fine for now as we will later use the OpenAPI
spec which will generate models for us, and then we will do the mapping.
Doing the mapping to our custom types now would end up simply creating
busy work we would throw out later.
Adds mapping to get the backup status to the `BackupActuator`. Again we
reuse the same internal types, but later this whole client will be
mostly generated by the OpenAPI generator.

One thing to note, we need to add the `Jdk8Module` to our
`JacksonDecoder` - this is done on the server side automatically
by Spring, but here we have to do it manually to decode `Optional`
types.
Updates the acceptance tests for backups to also make use of the status
API endpoint.
@deepthidevaki
Copy link
Contributor

bors merge

@zeebe-bors-camunda
Copy link
Contributor

Build succeeded:

@zeebe-bors-camunda zeebe-bors-camunda bot merged commit 721b6b4 into main Sep 26, 2022
@zeebe-bors-camunda zeebe-bors-camunda bot deleted the 9902-monitor-backup branch September 26, 2022 10:18
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.

Implement monitor backup api in gateway
3 participants