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

bucket notification - ignore failure if notification was removed #8709

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

alphaprinz
Copy link
Contributor

Explain the changes

  1. Before this PR, failed notifications were always re-written to persistent log.
    Now they are re-written only if they are still configured on the bucket.

Issues: Fixed #xxx / Gap #xxx

  1. Remove unwanted notification from persistent logs.

Testing Instructions:

  1. Configure notification to an unavailable external connection.
  2. Upload a file to the bucket.
  3. Remove notification configuration from bucket.
  4. Run notifications (if in NC).
  5. Notification fails, but is not re-written to persistent logs.
  • Doc added/updated
  • Tests added

if (this.nc_config_fs) {
bucket = await this.nc_config_fs.get_bucket_by_name(notif.meta.bucket);
} else {
const system = this.system_store.data.systems[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Line number 71 and 72 suggest that system could be null. So better check it here also?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If system is null, then _can_run() will return false and bg worker will not run (and we will not get to handle_failed_notification() where I don't check is system is not null).

if (send_promise) send_promises.push(send_promise);
if (send_promises.length > this.batch_size) {
await Promise.all(send_promises);
send_promises = [];
}
} catch (err) {
dbg.error("Failed to notify. err = ", err, ", str =", str);
await failure_append(str);
//re-write the failed notification if it's still configured on the bucket
if (notif) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need of this check.
"notif" will not be null at this point. If it could be, then we should have checked it before line no 124.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

notif can be null in case json parsing fails (currently line 123).
If json parsing is ok, notif will not be null on 124 and forward.

@alphaprinz alphaprinz requested a review from aspandey January 22, 2025 17:22
@alphaprinz alphaprinz merged commit 73cd009 into noobaa:master Jan 23, 2025
11 checks passed
alphaprinz added a commit to alphaprinz/noobaa-core that referenced this pull request Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants