README ¶
insights-results-aggregator-mock
Mock service mimicking Insights Results Aggregator
- Description
- Howto build the service
- Howto start the service
- Generate the image for Docker
- Running in Docker
- Makefile targets
- Usage
- Accessing results
- List of cluster IDs that can be accesses by this service
- List of clusters hitting specified rule
- Endpoint to ack rule
- List of acked rules
- Ack rule with specified justification
- Ack rule
- Update rule
- Delete rule
- Upgrade risks prediction results
- Clusters that return valid data
- Cluster returning "no content" because the cluster is managed
- Cluster returning unavailable service due to AMS is not available
- Cluster returning unavailable service due to Upgrade Risks Prediction is not available
- Cluster returning 404 due to no data in RHOBS for this cluster
- Endpoints for On Demand Data Gathering
- Endpoints to retrieve information about DVO namespaces
- Debug endpoints
- Definition of Done for new features and fixes
- BDD tests
- Package manifest
Description
Mock service mimicking Insights Results Aggregator / SmartProxy REST API
Howto build the service
make build
Howto start the service
make run
Generate the image for Docker
docker build -t insights-results-aggregator-mock:latest .
Running in Docker
docker run --rm insights-results-aggregator-mock:latest
Makefile targets
Usage: make <OPTIONS> ... <TARGETS>
Available targets are:
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
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
cover Generate HTML pages with code coverage
coverage Display code coverage on terminal
integration_tests Run all integration tests
local_integration_tests Run all integration tests locally
help Show this help screen
function_list List all functions in generated binary file
Usage
Usage:
./insights-results-aggregator-mock [command]
The commands are:
<EMPTY> starts content service
start-service starts content service
help print-help prints help
config print-config prints current configuration set by files & env variables
version print-version-info prints version info
authors print-authors prints authors
Note: it is possible to use single dash or double dashes for all commands.
Accessing results
Settings for localhost
ADDRESS=localhost:8080/api/insights-results-aggregator/v2
Basic endpoints
curl -k -v $ADDRESS/
curl -k -v $ADDRESS/groups
curl -k -v $ADDRESS/content
curl -k -v $ADDRESS/organizations
curl -k -v $ADDRESS/clusters
Rule content
Returns rule content and also group info:
curl -k -v $ADDRESS/content
An example of response (shortened):
{
"content": [
{
"plugin": {
"name": "",
"node_id": "",
"product_code": "",
"python_module": "foo.bar.baz"
},
],
"groups": [
{
"title": "Performance",
"description": "High utilization, proposed tuned profiles, storage issues",
"tags": [
"performance"
]
},
],
"status": "ok"
}
Groups
curl -k -v $ADDRESS/groups
An example of response (further formatted by jq
):
{
"groups": [
{
"title": "Security",
"description": "Issues related to certificates, user management, security groups, specific port usage, storage permissions, usage of kubeadmin account, exposed keys etc.",
"tags": [
"security"
]
},
{
"title": "Fault Tolerance",
"description": "Load balancer issues, machine api and autoscaler issues, failover issues, nodes down, cluster api/cluster provider issues.",
"tags": [
"fault_tolerance"
]
},
{
"title": "Performance",
"description": "High utilization, proposed tuned profiles, storage issues",
"tags": [
"performance"
]
},
{
"title": "Service Availability",
"description": "Operator degraded, missing functionality due to misconfiguration or resource constraints.",
"tags": [
"service_availability"
]
}
],
"status": "ok"
}
Clusters per organization
curl -k -v $ADDRESS/organizations/11789772/clusters
curl -k -v $ADDRESS/organizations/11940171/clusters
Report for organization + cluster
curl -k -v $ADDRESS/report/11789772/34c3ecc5-624a-49a5-bab8-4fdc5e51a266
or alternatively
curl -k -v $ADDRESS/clusters/11789772/34c3ecc5-624a-49a5-bab8-4fdc5e51a266/report
In this case 11789772
is organization ID and 34c3ecc5-624a-49a5-bab8-4fdc5e51a266
is cluster ID
Report for one particular cluster
curl -k -v $ADDRESS/report/34c3ecc5-624a-49a5-bab8-4fdc5e51a266
Getting report for several clusters
List of clusters has to be provided in payload in JSON format:
curl -k -v $ADDRESS/clusters -d @cluster_list.json
Format of the payload:
{
"clusters" : [
"34c3ecc5-624a-49a5-bab8-4fdc5e51a266",
"74ae54aa-6577-4e80-85e7-697cb646ff37",
"a7467445-8d6a-43cc-b82c-7007664bdf69",
"ee7d2bf4-8933-4a3a-8634-3328fe806e08"
]
}
Format of response:
{
"clusters": [
"34c3ecc5-624a-49a5-bab8-4fdc5e51a266",
"74ae54aa-6577-4e80-85e7-697cb646ff37",
"a7467445-8d6a-43cc-b82c-7007664bdf69",
"ee7d2bf4-8933-4a3a-8634-3328fe806e08"
],
"errors": null,
"reports": {
"34c3ecc5-624a-49a5-bab8-4fdc5e51a266": {
"report": {
// ...
// ...
// ...
}
}
},
"generated_at": "2020-08-11T10:17:29Z"
}
Response format in case it is not possible to return result for some cluster:
{
"clusters": [
"ee7d2bf4-8933-4a3a-8634-3328fe806e08"
],
"errors": [
"00000000-0000-0000-0000-000000000000"
],
"reports": {
"ee7d2bf4-8933-4a3a-8634-3328fe806e08": {
"report": {
"data": [
// ...
// ...
// ...
]
},
"status": "ok"
}
},
"generated_at": "2020-08-11T10:17:29Z"
}
List of cluster IDs that can be accesses by this service
Clusters that return 'static' rule results
Organization ID 11789772
34c3ecc5-624a-49a5-bab8-4fdc5e51a266
34c3ecc5-624a-49a5-bab8-4fdc5e51a267
34c3ecc5-624a-49a5-bab8-4fdc5e51a268
34c3ecc5-624a-49a5-bab8-4fdc5e51a269
34c3ecc5-624a-49a5-bab8-4fdc5e51a26a
34c3ecc5-624a-49a5-bab8-4fdc5e51a26b
34c3ecc5-624a-49a5-bab8-4fdc5e51a26c
34c3ecc5-624a-49a5-bab8-4fdc5e51a26d
34c3ecc5-624a-49a5-bab8-4fdc5e51a26e
34c3ecc5-624a-49a5-bab8-4fdc5e51a26f
74ae54aa-6577-4e80-85e7-697cb646ff37
a7467445-8d6a-43cc-b82c-7007664bdf69
ee7d2bf4-8933-4a3a-8634-3328fe806e08
Organization ID 1
00000001-624a-49a5-bab8-4fdc5e51a266
00000001-624a-49a5-bab8-4fdc5e51a267
00000001-624a-49a5-bab8-4fdc5e51a268
00000001-624a-49a5-bab8-4fdc5e51a269
00000001-624a-49a5-bab8-4fdc5e51a26a
00000001-624a-49a5-bab8-4fdc5e51a26b
00000001-624a-49a5-bab8-4fdc5e51a26c
00000001-624a-49a5-bab8-4fdc5e51a26d
00000001-624a-49a5-bab8-4fdc5e51a26e
00000001-624a-49a5-bab8-4fdc5e51a26f
00000001-6577-4e80-85e7-697cb646ff37
00000001-8933-4a3a-8634-3328fe806e08
00000001-8d6a-43cc-b82c-7007664bdf69
Organization ID 2
00000002-624a-49a5-bab8-4fdc5e51a266
00000002-6577-4e80-85e7-697cb646ff37
00000002-8933-4a3a-8634-3328fe806e08
Organization ID 3
00000003-8933-4a3a-8634-3328fe806e08
00000003-8d6a-43cc-b82c-7007664bdf69
Cluster that returns no results (ie just empty report)
eeeeeeee-eeee-eeee-eeee-000000000001
00000001-eeee-eeee-eeee-000000000001
00000003-eeee-eeee-eeee-000000000001
Mnemotechnic: e
means "empty"
Clusters that return rules that change every 15 minutes
Cluster ID Returns results that are similar to:
cccccccc-cccc-cccc-cccc-000000000001 34c3ecc5-624a-49a5-bab8-4fdc5e51a266
74ae54aa-6577-4e80-85e7-697cb646ff37
a7467445-8d6a-43cc-b82c-7007664bdf69
cccccccc-cccc-cccc-cccc-000000000002 74ae54aa-6577-4e80-85e7-697cb646ff37
a7467445-8d6a-43cc-b82c-7007664bdf69
ee7d2bf4-8933-4a3a-8634-3328fe806e08
cccccccc-cccc-cccc-cccc-000000000003 ee7d2bf4-8933-4a3a-8634-3328fe806e08
ee7d2bf4-8933-4a3a-8634-3328fe806e08
34c3ecc5-624a-49a5-bab8-4fdc5e51a266
cccccccc-cccc-cccc-cccc-000000000004 eeeeeeee-eeee-eeee-eeee-000000000001
eeeeeeee-eeee-eeee-eeee-000000000001
34c3ecc5-624a-49a5-bab8-4fdc5e51a266
Mnemotechnic: c
means "changing"
List of clusters that return improper results and/or failure
ffffffff-ffff-ffff-ffff-000000000xxx'
Returns HTTP code xxx taken directly from the last three digits of cluster ID. It means that devels/testers could use this functionality to check the behaviour on client side.
Mnemotechnic: f
means "failure"
Example:
ADDRESS=localhost:8080/api/insights-results-aggregator/v2
clusters="ffffffff-ffff-ffff-ffff-000000000200
ffffffff-ffff-ffff-ffff-000000000201
ffffffff-ffff-ffff-ffff-000000000404
ffffffff-ffff-ffff-ffff-000000000405
ffffffff-ffff-ffff-ffff-000000000201"
for cluster in $clusters
do
curl -k -v $ADDRESS/report/${cluster}
done
List of clusters hitting specified rule
curl 'localhost:8080/api/insights-results-aggregator/v2/rule/ccx_rules_ocp.external.rules.nodes_requirements_check.report|NODES_MINIMUM_REQUIREMENTS_NOT_MET/clusters_detail/'
An example of response:
{
"meta": {
"count": 24,
"component": "ccx_rules_ocp.external.rules.nodes_requirements_check.report",
"error_key": "NODES_MINIMUM_REQUIREMENTS_NOT_MET",
"generated_at": "2021-08-27T12:12:18Z"
},
"data": [
"00000001-624a-49a5-bab8-4fdc5e51a266",
"00000001-6577-4e80-85e7-697cb646ff37",
"00000001-8933-4a3a-8634-3328fe806e08",
"00000001-8d6a-43cc-b82c-7007664bdf69",
"00000001-0000-0000-0000-000000000000",
"00000001-1111-1111-1111-000000000000",
"00000001-2222-2222-2222-000000000000",
"00000001-3333-3333-3333-000000000000",
"00000001-4444-4444-4444-000000000000",
"00000001-5555-5555-5555-000000000000",
"00000001-6666-6666-6666-000000000000",
"00000001-7777-7777-7777-000000000000",
"00000001-8888-8888-8888-000000000000",
"00000001-9999-9999-9999-000000000000",
"00000001-aaaa-aaaa-aaaa-000000000000",
"00000001-bbbb-bbbb-bbbb-000000000000",
"00000001-cccc-cccc-cccc-000000000000",
"00000001-dddd-dddd-dddd-000000000000",
"00000001-ffff-ffff-ffff-000000000000",
"00000001-ffff-ffff-ffff-000000000000",
"34c3ecc5-624a-49a5-bab8-4fdc5e51a266",
"74ae54aa-6577-4e80-85e7-697cb646ff37",
"a7467445-8d6a-43cc-b82c-7007664bdf69",
"ee7d2bf4-8933-4a3a-8634-3328fe806e08"
]
}
Endpoint to ack rule
List of acked rules
List acks from this account where the rule is active. Will return an empty list if this account has no acks.
Request to the service:
curl localhost:8080/api/insights-results-aggregator/v2/ack
Response from the service:
{
"meta": {
"count": 5
},
"data": [
{
"rule": "ccx_rules_ocp.external.rules.nodes_kubelet_version_check.report|NODE_KUBELET_VERSION",
"justification": "Justification3",
"created_by": "tester3",
"created_at": "2021-09-04T17:11:35.130Z",
"updated_at": "2021-09-04T17:11:35.130Z"
},
{
"rule": "ccx_rules_ocp.external.rules.samples_op_failed_image_import_check.report|SAMPLES_FAILED_IMAGE_IMPORT_ERR",
"justification": "Justification4",
"created_by": "tester4",
"created_at": "2021-09-04T17:11:35.130Z",
"updated_at": "2021-09-04T17:11:35.130Z"
},
{
"rule": "ccx_rules_ocp.external.rules.cluster_wide_proxy_auth_check.report|AUTH_OPERATOR_PROXY_ERROR",
"justification": "Justification5",
"created_by": "tester5",
"created_at": "2021-09-04T17:11:35.130Z",
"updated_at": "2021-09-04T17:11:35.130Z"
},
{
"rule": "ccx_rules_ocp.external.rules.nodes_requirements_check.report|NODES_MINIMUM_REQUIREMENTS_NOT_MET",
"justification": "Justification1",
"created_by": "tester1",
"created_at": "2021-09-04T17:11:35.130Z",
"updated_at": "2021-09-04T17:11:35.130Z"
},
{
"rule": "ccx_rules_ocp.external.bug_rules.bug_1766907.report|BUGZILLA_BUG_1766907",
"justification": "Justification2",
"created_by": "tester2",
"created_at": "2021-09-04T17:11:35.130Z",
"updated_at": "2021-09-04T17:11:35.130Z"
}
]
}
Ack rule with specified justification
Acknowledges (and therefore hides) a rule from view in an account. If there's already an acknowledgement of this rule by this account, then return that. Otherwise, a new ack is created.
Ack new rule
Request to the service:
curl -v -X POST -H "Content-Type: application/json" --data '{"rule_id":"foo|bar", "justification":"xyzzy"}' "localhost:8080/api/insights-results-aggregator/v2/ack"
Response from the service:
< HTTP/1.1 201 Created
< Content-Type: application/json; charset=utf-8
< Date: Sun, 05 Sep 2021 14:29:33 GMT
< Content-Length: 168
<
{
"rule": "foo|bar",
"justification": "xyzzy",
"created_by": "onlineTester",
"created_at": "2021-09-05T16:29:33+02:00",
"updated_at": "2021-09-05T16:29:33+02:00"
}
Ack existing rule
Request to the service:
curl -v -X POST -H "Content-Type: application/json" --data '{"rule_id":"existing|rule", "justification":"xyzzy"}' "localhost:8080/api/insights-results-aggregator/v2/ack"
Response from the service:
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Sun, 05 Sep 2021 14:35:51 GMT
< Content-Length: 168
<
{
"rule": "foo|bar",
"justification": "xyzzy",
"created_by": "onlineTester",
"created_at": "2021-09-05T16:35:25+02:00",
"updated_at": "2021-09-05T16:35:25+02:00"
}
Ack rule
Acks acknowledge (and therefore hide) a rule from view in an account. This view handles listing, retrieving, creating and deleting acks. Acks are created and deleted by Insights rule ID, not by their own ack ID.
Ack new rule
Request to the service:
curl -v "localhost:8080/api/insights-results-aggregator/v2/ack/new|rule"
Response from the service:
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Sat, 04 Sep 2021 18:46:20 GMT
< Content-Length: 165
<
{
"rule": "new|rule",
"justification": "?",
"created_by": "onlineTester",
"created_at": "2021-09-04T20:46:20+02:00",
"updated_at": "2021-09-04T20:46:20+02:00"
}
Ack existing rule
Request to the service:
curl -v "localhost:8080/api/insights-results-aggregator/v2/ack/ccx_rules_ocp.external.rules.cluster_wide_proxy_auth_check.report|AUTH_OPERATOR_PROXY_ERROR"
Response from the service:
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Sat, 04 Sep 2021 18:32:58 GMT
< Content-Length: 260
<
{
"rule": "ccx_rules_ocp.external.rules.cluster_wide_proxy_auth_check.report|AUTH_OPERATOR_PROXY_ERROR",
"justification": "Justification5",
"created_by": "onlineTester",
"created_at": "2021-09-04T17:11:35.130Z",
"updated_at": "2021-09-04T20:32:58+02:00"
Please note that just updated_at
attribute is changed in this situation.
Update rule
Update existing rule
Request to the service:
curl -v-X PUT -H "Content-Type: application/json" --data '{"justification":"xyzzy"}' "localhost:8080/api/insights-results-aggregator/v2/ack/existing|rule"
Response from the service:
< HTTP/1.1 200 OK
< Date: Sun, 05 Sep 2021 05:47:46 GMT
< Content-Length: 169
< Content-Type: text/plain; charset=utf-8
<
{
"rule": "existing|rule",
"justification": "xyzzy",
"created_by": "onlineTester",
"created_at": "2021-09-05T07:45:00+02:00",
"updated_at": "2021-09-05T07:47:46+02:00"
}
Update non existing rule
Update an acknowledgement for a rule, by rule ID. A new justification can be supplied. The username is taken from the authenticated request. The updated ack is returned.
Request to the service:
curl -v -X PUT -H "Content-Type: application/json" --data '{"justification":"xyzzy"}' "localhost:8080/api/insights-results-aggregator/v2/ack/new|rule"
Response from the service:
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Sun, 05 Sep 2021 06:13:27 GMT
< Content-Length: 51
<
rule not found -> justification can not be changed
Delete rule
Delete an acknowledgement for a rule, by its rule ID. If the ack existed, it is deleted and a 204 is returned. Otherwise, a 404 is returned.
Delete existing rule
Request to the service:
curl -v -X DELETE "localhost:8080/api/insights-results-aggregator/v2/ack/ccx_rules_ocp.external.rules.cluster_wide_proxy_auth_check.report|AUTH_OPERATOR_PROXY_ERROR"
Response from the service:
< HTTP/1.1 204 No Content
< Date: Sat, 04 Sep 2021 17:44:32 GMT
<
Delete nonexisting rule
Request to the service:
curl -v -X DELETE "localhost:8080/api/insights-results-aggregator/v2/ack/foobar|foobar"
Response from the service:
< HTTP/1.1 404 Not Found
< Date: Sat, 04 Sep 2021 17:44:35 GMT
< Content-Length: 0
<
Upgrade risks prediction results
To use the Upgrade Risks Prediction endpoint:
curl "localhost:8080/api/insights-results-aggregator/v2/cluster/{cluster_id}/upgrade-risks-prediction
Response from the service:
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=utf-8
< Date: Thu, 13 Apr 2023 12:38:44 GMT
< Content-Length: 186
<
{"meta":{"last_checked_at":"2023-04-13T12:38:44Z"},"status":"ok","upgrade_recommendation":{"upgrade_recommended":true,"upgrade_risks_predictors":{"alerts":[],"operator_conditions":[]}}}
Clusters that return valid data
For the clusters not listed in the sections bellow, a 404 will be returned.
00000001-624a-49a5-bab8-4fdc5e51a266
00000003-eeee-eeee-eeee-000000000001
Cluster returning "no content" because the cluster is managed
6cab9726-c2be-438e-af11-db846a678abb
Cluster returning unavailable service due to AMS is not available
c60ba611-6af4-4d62-9b9e-36344da5e7bc
Cluster returning unavailable service due to Upgrade Risks Prediction is not available
897ec1a1-4679-4122-aacb-f0ae9f9e1a5f
Cluster returning 404 due to no data in RHOBS for this cluster
234ec1a1-4679-4122-aacb-f0ae9f9e1a56
Endpoints for On Demand Data Gathering
List of all rule hits
List of all rule hits (all identified by x-rh-insights-request-id) for given cluster (the list also contain timestamps).
Request to the service
GET variant
curl -v localhost:8080/api/insights-results-aggregator/v2/cluster/34c3ecc5-624a-49a5-bab8-4fdc5e51a267/requests/
POST variant
curl -v -X POST -d @requests.json localhost:8080/api/insights-results-aggregator/v2/cluster/34c3ecc5-624a-49a5-bab8-4fdc5e51a267/requests/
Where requests.json
looks like:
[
"1duzaoao0l1b230ipv0rb4sqe8",
"1yjdje758zgyy3ksfr732yb1cl",
"eeeeeeeeeeeeeeeeeeeeeeeeee",
"2ukce6u74rm9e12mplu6liqzsv"
]
Response from the service
{
"cluster": "34c3ecc5-624a-49a5-bab8-4fdc5e51a267",
"requests": [
{
"requestID": "1duzaoao0l1b230ipv0rb4sqe8",
"valid": true,
"received": "2000-11-01T01:00:00.000000999Z",
"processed": "2023-05-29T06:44:20.210989121Z"
},
{
"requestID": "1yjdje758zgyy3ksfr732yb1cl",
"valid": true,
"received": "2000-11-01T01:00:00.000000999Z",
"processed": "2023-05-29T06:44:20.210989913Z"
},
{
"requestID": "2drtvjlisiqww1c93kugqyboyc",
"valid": true,
"received": "2000-11-01T01:00:00.000000999Z",
"processed": "2023-05-29T06:44:20.210994822Z"
}
],
"status": "ok"
}
Response for improper request (bad cluster name)
- HTTP code 400 is set in HTTP header
{
"status": "invalid UUID length: 37"
}
Check status of given request-id
Check status of given request-id
(original name x-rh-insights-request-id
).
Request to the service:
curl -v localhost:8080/api/insights-results-aggregator/v2/cluster/34c3ecc5-624a-49a5-bab8-4fdc5e51a267/request/1yjdje758zgyy3ksfr732yb1cl/status
Response from the service
{
"cluster": "34c3ecc5-624a-49a5-bab8-4fdc5e51a267",
"requestID": "1yjdje758zgyy3ksfr732yb1cl",
"status": "processed"
}
or
{
"cluster": "34c3ecc5-624a-49a5-bab8-4fdc5e51a267",
"requestID": "1yjdje758zgyy3ksfr732yx1cl",
"status": "unknown"
}
For not known request-id or cluster:
{
"status": "Requests for cluster not found"
}
For improper request (bad cluster ID etc.)
- HTTP code 400 is set in HTTP header
{
"status": "invalid UUID length: 35"
}
For improper request ID
- HTTP code 400 is set in HTTP header
{
"status": "invalid request ID: '1yjdje758zgyy3ksf_r732yb1cl'"
}
Retrieve simplified results for given request-id
Request to the service:
curl -v localhost:8080/api/insights-results-aggregator/v2/cluster/34c3ecc5-624a-49a5-bab8-4fdc5e51a267/request/1yjdje758zgyy3ksfr732yb1cl/report
Response from the service
{
"cluster": "34c3ecc5-624a-49a5-bab8-4fdc5e51a267",
"requestID": "38584huk209q82uhl8md5gsdxr",
"status": "processed",
"report": [
{
"rule_fqdn": "ccx_rules_ocp.external.rules.nodes_requirements_check.report",
"error_key": "NODES_MINIMUM_REQUIREMENTS_NOT_MET",
"description": "Lorem ipsum...",
"total_risk": 1
},
{
"rule_fqdn": "samples_op_failed_image_import_check.report",
"error_key": "SAMPLES_FAILED_IMAGE_IMPORT_ERR",
"description": "Lorem ipsum...",
"total_risk": 2
},
{
"rule_fqdn": "ccx_rules_ocp.external.bug_rules.bug_1766907.report",
"error_key": "BUGZILLA_BUG_1766907",
"description": "Lorem ipsum...",
"total_risk": 3
},
{
"rule_fqdn": "ccx_rules_ocp.external.rules.nodes_kubelet_version_check.report",
"error_key": "NODE_KUBELET_VERSION",
"description": "Lorem ipsum...",
"total_risk": 4
},
{
"rule_fqdn": "ccx_rules_ocp.external.rules.samples_op_failed_image_import_check.report",
"error_key": "SAMPLES_FAILED_IMAGE_IMPORT_ERR",
"description": "Lorem ipsum...",
"total_risk": 5
}
]
}
Response in case of empty result set
{
"cluster": "34c3ecc5-624a-49a5-bab8-4fdc5e51a267",
"requestID": "1yjdje758zgyy3ksfr732yb1cl",
"status": "processed",
"report": null
}
Response in case of improper request
- HTTP code 400 is set in HTTP header
{
"status": "invalid UUID length: 35"
}
{
"status": "invalid request ID: '38584huk209q82uhl8md5gsdxr_'"
}
Endpoints to retrieve information about DVO namespaces
List of all DVO namespaces
Returns the list of all DVO namespaces (i.e. array of objects) to which this particular account has access. Each object contains the namespace ID, the namespace display name if available, the cluster ID under which this namespace is created, and the number of affecting recommendations for this namespace as well.
Request to the service
curl -v localhost:8080/api/insights-results-aggregator/v2/namespaces/dvo
Response from the service
{
"status": "ok",
"workloads": [
{
"cluster": {
"uuid": "00000001-0001-0001-0001-000000000002",
"display_name": "Cluster name 00000001-0001-0001-0001-000000000002"
},
"namespace": {
"uuid": "d00b47da-fc6f-4c72-abc1-94f525441c75",
"name": "Namespace name d00b47da-fc6f-4c72-abc1-94f525441c75"
},
"metadata": {
"recommendations": 3,
"objects": 3,
"reported_at": "2023-10-05T07:37:59+02:00",
"last_checked_at": "2023-10-05T07:37:59+02:00",
"highest_severity": 5
}
},
{
"cluster": {
"uuid": "00000001-0001-0001-0001-000000000002",
"display_name": "Cluster name 00000001-0001-0001-0001-000000000002"
},
"namespace": {
"uuid": "0fab74ee-61ce-498d-bcd4-070ad950b0d7",
"name": "Namespace name 0fab74ee-61ce-498d-bcd4-070ad950b0d7"
},
"metadata": {
"recommendations": 1,
"objects": 2,
"reported_at": "2023-10-05T07:37:59+02:00",
"last_checked_at": "2023-10-05T07:37:59+02:00",
"highest_severity": 5
}
},
...
...
...
]
}
DVO Recommendations for selected cluster and namespace
Returns recommendations for selected cluster and namespace. Please note that there are two REST API variants with different selector order, but the same results.
Request to the service
First variant:
curl localhost:8080/api/insights-results-aggregator/v2/namespaces/dvo/{namespace_uuid}/cluster/{cluster_uuid}
Second variant:
curl localhost:8080/api/insights-results-aggregator/v2/cluster/{cluster_name}/namespaces/dvo/{namespace}
Example with data:
curl localhost:8080/api/insights-results-aggregator/v2/namespaces/dvo/fbcbe2d3-e398-4b40-9d5e-4eb46fe8286f/cluster/00000001-0001-0001-0001-000000000002
Response from the service
{
"status": "ok",
"cluster": {
"uuid": "00000001-0001-0001-0001-000000000002",
"display_name": "Cluster name 00000001-0001-0001-0001-000000000002"
},
"namespace": {
"uuid": "fbcbe2d3-e398-4b40-9d5e-4eb46fe8286f",
"name": "Namespace name fbcbe2d3-e398-4b40-9d5e-4eb46fe8286f"
},
"metadata": {
"recommendations": 2,
"objects": 3,
"reported_at": "2023-10-05T07:38:51+02:00",
"last_checked_at": "2023-10-05T07:38:51+02:00",
"highest_severity": 5
},
"recommendations": [
{
"check": "host_network",
"description": "Alert on pods/deployment-likes with sharing host's network namespace",
"remediation": "Ensure the host's network namespace is not shared.",
"objects": [
{
"kind": "DaemonSet",
"uid": "be466de5-12fb-4710-bf70-62deb38ae563"
}
]
},
{
"check": "non_isolated_pod",
"description": "Alert on deployment-like objects that are not selected by any NetworkPolicy.",
"remediation": "Ensure pod does not accept unsafe traffic by isolating it with a NetworkPolicy. See https://cloud.redhat.com/blog/gUID:e-to-kubernetes-ingress-network-policies for more details.",
"objects": [
{
"kind": "DaemonSet",
"uid": "be466de5-12fb-4710-bf70-62deb38ae563"
},
{
"kind": "DaemonSet",
"uid": "b51716a3-886b-4a67-b153-ce092fc91047"
}
]
}
]
}
Debug endpoints
The following endpoints needs to be enabled via configuration file by setting debug
option to true
.
Exit HTTP server gracefully
Request to the service:
curl -X PUT -v localhost:8080/api/insights-results-aggregator/v2/exit
Response from the service:
None, the server will stop immediatelly.
Definition of Done for new features and fixes
Please look at DoD.md document for definition of done for new features and fixes.
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:
- clone the Insights Behavioral Spec repository
- go into the cloned subdirectory
insights-behavioral-spec
- run the
insights-results-aggregator-mock.sh
from this subdirectory
List of all test scenarios prepared for this service is available at https://github.com/RedHatInsights/insights-behavioral-spec#insights-results-aggregator-mock
Package manifest
Package manifest is available at docs/manifest.txt.
Directories ¶
Path | Synopsis |
---|---|
Package conf contains definition of data type named ConfigStruct that represents configuration of the mock service.
|
Package conf contains definition of data type named ConfigStruct that represents configuration of the mock service. |
Package groups contains definition of data structure that represents the relative information about a group and a set of functions to handle that data structure.
|
Package groups contains definition of data structure that represents the relative information about a group and a set of functions to handle that data structure. |
Package metrics contains all metrics that needs to be exposed to Prometheus and indirectly to Grafana.
|
Package metrics contains all metrics that needs to be exposed to Prometheus and indirectly to Grafana. |
Package server contains implementation of REST API server (HTTPServer) for the Insights content service.
|
Package server contains implementation of REST API server (HTTPServer) for the Insights content service. |
Package storage contains an implementation of interface between Go code and (almost any) SQL database like PostgreSQL, SQLite, or MariaDB.
|
Package storage contains an implementation of interface between Go code and (almost any) SQL database like PostgreSQL, SQLite, or MariaDB. |
Implementation of REST API tests that checks all REST API endpoints of Insights aggregator mock service.
|
Implementation of REST API tests that checks all REST API endpoints of Insights aggregator mock service. |
rest
Package tests contains REST API tests for following endpoints:
|
Package tests contains REST API tests for following endpoints: |
Package types contains declaration of various data types (usually structures) used elsewhere in the aggregator code.
|
Package types contains declaration of various data types (usually structures) used elsewhere in the aggregator code. |