Skip to content

Commit 2dd5c19

Browse files
committed
Bucket Notifications - doc
Signed-off-by: Amit Prinz Setter <[email protected]>
1 parent 7bc814b commit 2dd5c19

File tree

3 files changed

+122
-0
lines changed

3 files changed

+122
-0
lines changed

Diff for: docs/NooBaaNonContainerized/ConfigFileCustomizations.md

+12
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,18 @@ Warning: After setting this configuration, NooBaa will skip schema validations a
449449
"LOG_TO_STDERR_ENABLED": false
450450
3. systemctl restart noobaa
451451
```
452+
### 30. Notification log directory
453+
* <u>Key</u> `NOTIFICATION_LOG_DIR`
454+
* <u>Type</u> String
455+
* <u>Default</u> empty
456+
* <u>Description</u> Path to directory that will hold pending notifications to be sent,
457+
* <u>Steps</u>
458+
```
459+
1. Open /path/to/config_dir/config.json file.
460+
2. Set the config key -
461+
Example:
462+
"NOTIFICATION_LOG_DIR": "/etc/notif"
463+
3. systemctl restart noobaa
452464
453465
## Config.json File Examples
454466
The following is an example of a config.json file -

Diff for: docs/bucket-notifications.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Bucket Notifications
2+
3+
## Bucket Notification Configuration
4+
5+
Bucket's notifications can be configured with the s3api operation [put-bucket-notification-configuration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/put-bucket-notification-configuration.html).
6+
Specify notifications under the "TopicConfigurations" field, which is an array of jsons, one for each notification.
7+
A notification json has these fields:
8+
- Id: Mandatory. A unique string identifying the notification configuration.
9+
- Events: Optional. An array of [events](https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-how-to-event-types-and-destinations.html) for which the notification is relevant.
10+
If not specified, the notification is relevant for all events.
11+
- TopicArn: The connection file name. (To specify a Kafka target topic, see "Kafka Connection Fields" below).
12+
13+
Example for a bucket's notification configuration, in a file:
14+
{
15+
"TopicConfigurations": [
16+
{
17+
"Id": "created_from_s3op",
18+
"TopicArn": "connect.json",
19+
"Events": [
20+
"s3:ObjectCreated:*"
21+
]
22+
}
23+
]
24+
}
25+
26+
27+
## Connection File
28+
A connection file contains some fields that specify the target notification server.
29+
The connection file name is specified in TopicArn field of the [notification configuration](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3api/put-bucket-notification-configuration.html)
30+
In a containerized environment, the operator will mount the secrets as file in the core pod (see operator doc for more info).
31+
In a non-containerized system, you must create the relevant file manually and place it in 'connect' config sub-directory.
32+
Connect file contains a single json with the fields specified below.
33+
34+
### Common Connection Fields
35+
- name: A string identifying the connection (mandatory).
36+
- notification_protocol: One of: http, https, kafka (mandatory).
37+
38+
### Http(s) Connection Fields
39+
- agent_request_object: Value is a JSON that is passed to to nodejs' http(s) agent (mandatory).
40+
Any field supported by nodejs' http(s) agent can be used, specifically 'host' and 'port'.
41+
A full list of options is [here](https://nodejs.org/docs/latest-v22.x/api/http.html#new-agentoptions).
42+
43+
- request_options_object: Value is a JSON that is passed to nodejs' http(s) request (optional).
44+
Any field supported by nodejs' http(s) request option can be used, specifically:
45+
- 'path': used to specify the url path
46+
- 'auth': used for http simple auth. Value for 'auth' is of the syntax: <name>:<passowrd>.
47+
48+
A full list of options is [here](https://nodejs.org/docs/latest-v22.x/api/http.html#httprequesturl-options-callback).
49+
50+
### Kafka Connection Fields
51+
- metadata.broker.list: A CSV list of Kafka brokers (mandatory).
52+
- topic: A topic for the Kafka message (mandatory).
53+
54+
## Event Types
55+
S3 spec lists several events and "sub events".
56+
57+
The list of supported events are:
58+
59+
- s3:ObjectCreated:*
60+
- s3:ObjectCreated:Put
61+
- s3:ObjectCreated:Post
62+
- s3:ObjectCreated:Copy
63+
- s3:ObjectCreated:CompleteMultipartUpload
64+
- s3:ObjectRemoved:*
65+
- s3:ObjectRemoved:Delete
66+
- s3:ObjectRemoved:DeleteMarkerCreated
67+
- s3:ObjectRestore:*
68+
- s3:ObjectRestore:Post
69+
- s3:ObjectRestore:Completed
70+
- s3:ObjectRestore:Delete
71+
- s3:ObjectTagging:*
72+
- s3:ObjectTagging:Put
73+
- s3:ObjectTagging:Delete
74+
- s3:LifecycleExpiration:*
75+
- s3:LifecycleExpiration:Delete
76+
- s3:LifecycleExpiration:DeleteMarkerCreated
77+
78+
## Event Processing and Failure Handling
79+
Once NooBaa finds an event with a relevant notification configuration, the notification
80+
is written to a persistent file.
81+
Location of persistent files is determined by-
82+
- For containerized, the pvc specified in NooBaa Bucket Notification spec (see Operator docs for more info).
83+
- For NC, the env variable NOTIFICATION_LOG_DIR (see NC docs for more info).
84+
85+
Files are processed by-
86+
- For containerized, files are contantly being processed in the background of the core pod.
87+
- For NC, files are processed by running manage_nsfs with 'notification' action.
88+
89+
If a notification fails to be sent to the external server, it will be re-written to a persistent file.
90+
Once this new file is processed, NooBaa will try to re-send the failed notification.

Diff for: src/manage_nsfs/manage_nsfs_help_utils.js

+20
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,19 @@ Usage:
452452
453453
`;
454454

455+
const NOTIFICATION_OPTIONS = `
456+
Help:
457+
458+
'notification' is a noobaa-cli command that will process pending event notifications in the NOTIFICATION_LOG_DIR directory.
459+
It will attempt to send each notification to its respective external server.
460+
Note notifications that fail to be sent will be re-written in NOTIFICATION_LOG_DIR.
461+
462+
Usage:
463+
464+
noobaa-cli notification
465+
466+
`;
467+
455468

456469
/**
457470
* print_usage would print the help according to the arguments that were passed
@@ -481,6 +494,9 @@ function print_usage(type, action) {
481494
case TYPES.UPGRADE:
482495
print_help_upgrade(action);
483496
break;
497+
case TYPES.NOTIFICATION:
498+
print_help_notification();
499+
break;
484500
default:
485501
process.stdout.write(HELP + '\n');
486502
process.stdout.write(USAGE.trimStart() + '\n');
@@ -600,6 +616,10 @@ function print_help_upgrade(action) {
600616
}
601617
}
602618

619+
function print_help_notification(action) {
620+
process.stdout.write(NOTIFICATION_OPTIONS);
621+
}
622+
603623

604624
// EXPORTS
605625
exports.print_usage = print_usage;

0 commit comments

Comments
 (0)