ccx-notification-service

command module
v0.0.0-...-4dfe32f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

README

ccx-notification-service

CCX Notification Service

forthebadge made-with-go

GoDoc GitHub Pages Go Report Card Build Status Build Status GitHub go.mod Go version License

Description

The purpose of this service is to enable sending automatic email notifications and ServiceLog events to users for all serious issues found in their OpenShift clusters. The "instant" mode of this service runs as a cronjob every fifteen minutes, and it sends a sequence of events to the configured Kafka topic so that the notification-backend can process them and create email notifications based on the provided events. Additionally ServiceLog events are created, these can be displayed on cluster pages. Currently the events are only created for the important and critical issues found in the new_reports table of the configured PostgreSQL database. Once the reports are processed, the DB is updated with info about sent events by populating the reported table with the corresponding information. For more info about initialising the database and perform migrations, take a look at the ccx-notification-writer repository.

In the instant notification mode, one email will be received for each cluster with important or critical issues.

Additionally this service exposes several metrics about consumed and processed messages. These metrics can be aggregated by Prometheus and displayed by Grafana tools.

Architecture

Overall architecture and integration of this service is described in this document

Building

Use make build to build executable file with this service.

Makefile targets

All Makefile targets:

Usage: make <OPTIONS> ... <TARGETS>

Available targets are:

clean                Run go clean
build                Build binary containing service executable
build-cover          Build binary with code coverage detection support
fmt                  Run go fmt -w for all sources
lint                 Run golint
vet                  Run go vet. Report likely mistakes in source code
cyclo                Run gocyclo
ineffassign          Run ineffassign checker
shellcheck           Run shellcheck
errcheck             Run errcheck
goconst              Run goconst checker
gosec                Run gosec checker
abcgo                Run ABC metrics checker
json-check           Check all JSONs for basic syntax
style                Run all the formatting related commands (fmt, vet, lint, cyclo) + check shell scripts
run                  Build the project and executes the binary
test                 Run the unit tests
build-test           Build native binary with unit tests and benchmarks
profiler             Run the unit tests with profiler enabled
benchmark            Run benchmarks
benchmark.csv        Export benchmark results into CSV
cover                Generate HTML pages with code coverage
coverage             Display code coverage on terminal
bdd_tests            Run BDD tests (needs real dependencies)
bdd_tests_mock       Run BDD tests with mocked dependencies
before_commit        Checks done before commit
function_list        List all functions in generated binary file
help                 Show this help screen

Configuration

Configuration is described in this document

Usage

Provided a valid configuration, you can start the service with ./ccx-notification-service --instant-reports

All command line options

List of all available command line options:

  -instant-reports
        create instant reports
  -cleanup-on-startup
        perform database clean up on startup
  -show-authors
        show authors and exit
  -show-configuration
        show configuration
  -show-version
        show version and exit
  -max-age string
        max age for displaying/cleaning old records
  -new-reports-cleanup
        perform new reports clean up
  -old-reports-cleanup
        perform old reports clean up
  -print-new-reports-for-cleanup
        print new reports to be cleaned up
  -print-old-reports-for-cleanup
        print old reports to be cleaned up

Database

PostgreSQL database is used as a storage.

Please look at detailed schema description for more details about tables, indexes, and keys defined in this database.

Schema description

DB schema description can be generated by generate_db_schema_doc.sh script. Output is written into directory docs/db-description/. Its content can be viewed at this address.

Notification templates

Notification templates used to send e-mails etc. to customers are stored in different repository: https://github.com/RedHatInsights/notifications-backend/

Templates used by this notification service are available at: https://github.com/RedHatInsights/notifications-backend/tree/master/backend/src/main/resources/templates/AdvisorOpenshift

Definition of Done for new features and fixes

Please look at DoD.md document for definition of done for new features and fixes.

Testing

Tests and its configuration is described in this document

BDD tests

Behaviour tests for this service are included in Insights Behavioral Spec repository. In order to run these tests, the following steps need to be made:

  1. clone the Insights Behavioral Spec repository
  2. go into the cloned subdirectory insights-behavioral-spec
  3. run the notification_service_tests.sh from this subdirectory

List of all test scenarios prepared for this service is available at https://redhatinsights.github.io/insights-behavioral-spec/feature_list.html#ccx-notification-service

Package manifest

Package manifest is available at docs/manifest.txt.

Documentation

Overview

Entry point to the notification service.

The purpose of this service is to enable sending automatic email notifications and ServiceLog events to users for all serious issues found in their OpenShift clusters. The "instant" mode of this service runs as a cronjob every fifteen minutes, and it sends a sequence of events to the configured Kafka topic so that the notification backend can process them and create email notifications based on the provided events.

Additionally ServiceLog events are created, these can be displayed on cluster pages. Currently the events are only created for the *important* and *critical* issues found in the new_reports table of the configured PostgreSQL database. Once the reports are processed, the DB is updated with info about sent events by populating the reported table with the corresponding information. For more info about initialising the database and perform migrations, take a look at the https://github.com/RedHatInsights/ccx-notification-writer.

In the instant notification mode, one email will be received for each cluster with important or critical issues.

Additionally this service exposes several metrics about consumed and processed messages. These metrics can be aggregated by Prometheus and displayed by Grafana tools.

Directories

Path Synopsis
Package conf contains definition of data type named ConfigStruct that represents configuration of Notification service.
Package conf contains definition of data type named ConfigStruct that represents configuration of Notification service.
Package differ contains core of CCX Notification Service.
Package differ contains core of CCX Notification Service.
Package ocmclient contains implementation of OCMClient interface.
Package ocmclient contains implementation of OCMClient interface.
Package producer contains interface that can be used to produce (that is send) messages to properly configured Kafka broker.
Package producer contains interface that can be used to produce (that is send) messages to properly configured Kafka broker.
disabled
Package disabled contains an empty implementation of Producer interface.
Package disabled contains an empty implementation of Producer interface.
kafka
Package kafka contains an implementation of Producer interface that can be used to produce (that is send) messages to properly configured Kafka broker.
Package kafka contains an implementation of Producer interface that can be used to produce (that is send) messages to properly configured Kafka broker.
servicelog
Package servicelog contains an implementation of Producer interface that can be used to produce (that is send) messages to Service Log.
Package servicelog contains an implementation of Producer interface that can be used to produce (that is send) messages to Service Log.
tests
mocks
Package mocks contains various mock objects used by unit test: Producer mock, Storage mock, and OCMClient mock.
Package mocks contains various mock objects used by unit test: Producer mock, Storage mock, and OCMClient mock.
Package types contains declaration of various data types (usually structures) used elsewhere in the CCX Notification Service code.
Package types contains declaration of various data types (usually structures) used elsewhere in the CCX Notification Service code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL