Skip to content

Commit

Permalink
MF-1308 - Use IETF Health Check standard (absmach#1541)
Browse files Browse the repository at this point in the history
* MF-1308 - Use IETF Health Check standard

Signed-off-by: Manuel Imperiale <[email protected]>

* Add nginx health endpoint

Signed-off-by: Manuel Imperiale <[email protected]>

* Rm github.com/nelkinda dependency

Signed-off-by: Manuel Imperiale <[email protected]>

* Check error

Signed-off-by: Manuel Imperiale <[email protected]>

* Replace Version by Health in the CLI and SDK

Signed-off-by: Manuel Imperiale <[email protected]>

* Fix typo

Signed-off-by: Manuel Imperiale <[email protected]>

* Use new build flag go:build

Signed-off-by: Manuel Imperiale <[email protected]>

* Revert wrong renaming

Signed-off-by: Manuel Imperiale <[email protected]>

* sdk health test

Signed-off-by: Manuel Imperiale <[email protected]>

* Add /health endpoint to openapi doc

Signed-off-by: Manuel Imperiale <[email protected]>

* Use const for description message

Signed-off-by: Manuel Imperiale <[email protected]>

* Add version and build time during build

Signed-off-by: Manuel Imperiale <[email protected]>

* Time format

Signed-off-by: Manuel Imperiale <[email protected]>

* Add version and commit using git and build args

Signed-off-by: Manuel Imperiale <[email protected]>

* Add comments

Signed-off-by: Manuel Imperiale <[email protected]>

* Add tests

Signed-off-by: Manuel Imperiale <[email protected]>

* Add missing api properties

Signed-off-by: Manuel Imperiale <[email protected]>

* Fix api

Signed-off-by: Manuel Imperiale <[email protected]>

* Use ./schemas/HealthInfo.yml as

Signed-off-by: Manuel Imperiale <[email protected]>

* Fix example

Signed-off-by: Manuel Imperiale <[email protected]>

* Use content type application/health+json

Signed-off-by: Manuel Imperiale <[email protected]>

* Set Makefile variables only if empty

Signed-off-by: Manuel Imperiale <[email protected]>

* Fix typo

Signed-off-by: Manuel Imperiale <[email protected]>
Signed-off-by: skovacevic <[email protected]>
  • Loading branch information
manuio authored and skovacevic committed Jan 28, 2022
1 parent bd1cc1d commit 094f59d
Show file tree
Hide file tree
Showing 66 changed files with 456 additions and 173 deletions.
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ DOCKERS = $(addprefix docker_,$(SERVICES))
DOCKERS_DEV = $(addprefix docker_dev_,$(SERVICES))
CGO_ENABLED ?= 0
GOARCH ?= amd64
VERSION ?= $(shell git describe --abbrev=0 --tags)
COMMIT ?= $(shell git rev-parse HEAD)
TIME ?= $(shell date +%F_%T)

define compile_service
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) go build -mod=vendor -ldflags "-s -w" -o ${BUILD_DIR}/mainflux-$(1) cmd/$(1)/main.go
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
go build -mod=vendor -ldflags "-s -w \
-X 'github.com/mainflux/mainflux.BuildTime=$(TIME)' \
-X 'github.com/mainflux/mainflux.Version=$(VERSION)' \
-X 'github.com/mainflux/mainflux.Commit=$(COMMIT)'" \
-o ${BUILD_DIR}/mainflux-$(1) cmd/$(1)/main.go
endef

define make_docker
Expand All @@ -23,6 +31,9 @@ define make_docker
--build-arg SVC=$(svc) \
--build-arg GOARCH=$(GOARCH) \
--build-arg GOARM=$(GOARM) \
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
--build-arg TIME=$(TIME) \
--tag=$(MF_DOCKER_IMAGE_NAME_PREFIX)/$(svc) \
-f docker/Dockerfile .
endef
Expand Down
21 changes: 19 additions & 2 deletions api/auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ paths:
summary: Gets all groups.
description: |
Gets all groups up to a max level of hierarchy that can be fetched in one
request ( max level = 5). Result can be filtered by metadata. Groups will
request ( max level = 5). Result can be filtered by metadata. Groups will
be returned as JSON array or JSON tree.
tags:
- auth
Expand Down Expand Up @@ -154,7 +154,7 @@ paths:
summary: Deletes group.
description: |
Deletes group. If group is parent and descendant groups do not have any members
child groups will be deleted. Group cannot be deleted if has members or if
child groups will be deleted. Group cannot be deleted if has members or if
any descendant group has members.
tags:
- auth
Expand Down Expand Up @@ -354,6 +354,17 @@ paths:
description: Missing or invalid content type.
'500':
$ref: "#/components/responses/ServiceError"
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:
schemas:
Key:
Expand Down Expand Up @@ -736,3 +747,9 @@ components:
application/json:
schema:
$ref: "#/components/schemas/MembershipPage"
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
16 changes: 16 additions & 0 deletions api/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,16 @@ paths:
description: Missing or invalid access token provided.
'500':
$ref: "#/components/responses/ServiceError"
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:
schemas:
Expand Down Expand Up @@ -514,3 +524,9 @@ components:
$ref: "#/components/schemas/BootstrapConfig"
ServiceError:
description: Unexpected server-side error occurred.
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
24 changes: 20 additions & 4 deletions api/certs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ paths:
summary: Creates a certificate for thing
description: Creates a certificate for thing
tags:
- Thing to proxy
- certs
parameters:
- $ref: "#/components/parameters/Authorization"
requestBody:
Expand All @@ -28,7 +28,7 @@ paths:
description: |
Retrieves a certificate for a given cert ID.
tags:
- configs
- certs
parameters:
- $ref: "#/components/parameters/Authorization"
- $ref: "#/components/parameters/CertID"
Expand All @@ -45,7 +45,7 @@ paths:
description: |
Revokes a certificate for a given cert ID.
tags:
- configs
- certs
parameters:
- $ref: "#/components/parameters/Authorization"
- $ref: "#/components/parameters/CertID"
Expand All @@ -63,7 +63,7 @@ paths:
description: |
Retrieves a list of certificates' serial IDs for a given thing ID.
tags:
- configs
- certs
parameters:
- $ref: "#/components/parameters/Authorization"
- $ref: "#/components/parameters/ThingID"
Expand All @@ -75,6 +75,16 @@ paths:
Failed to retrieve corresponding certificates.
'500':
$ref: "#/components/responses/ServiceError"
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:
parameters:
Expand Down Expand Up @@ -228,3 +238,9 @@ components:
application/json:
schema:
$ref: "#/components/schemas/Revoke"
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
16 changes: 16 additions & 0 deletions api/consumers-notifiers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ paths:
description: Missing or invalid access token provided.
"500":
$ref: "#/components/responses/ServiceError"
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:
securitySchemes:
Expand Down Expand Up @@ -204,3 +214,9 @@ components:
$ref: "#/components/schemas/Page"
ServiceError:
description: Unexpected server-side error occurred.
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
25 changes: 23 additions & 2 deletions api/http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ paths:
description: Message discarded due to invalid channel id.
"415":
description: Message discarded due to invalid or missing content type.
"500":
description: Unexpected server-side error occurred.
'500':
$ref: "#/components/responses/ServiceError"
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:
schemas:
Expand Down Expand Up @@ -104,6 +114,7 @@ components:
type: apiKey
in: header
name: Authorization

parameters:
ID:
name: id
Expand All @@ -127,3 +138,13 @@ components:
application/json:
schema:
$ref: "#/components/schemas/SenMLArray"

responses:
ServiceError:
description: Unexpected server-side error occurred.
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
17 changes: 16 additions & 1 deletion api/provision.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,18 @@ paths:
description: Unauthorized.
'500':
description: Unexpected server-side error ocurred.
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:

parameters:
Authorization:
name: Authorization
Expand Down Expand Up @@ -78,3 +87,9 @@ components:
application/json:
schema:
type: object
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
17 changes: 16 additions & 1 deletion api/readers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ paths:
description: Missing or invalid access token provided.
'500':
$ref: "#/components/responses/ServiceError"
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:
schemas:
Expand Down Expand Up @@ -210,6 +220,11 @@ components:
application/json:
schema:
$ref: "#/components/schemas/MessagesPage"

ServiceError:
description: Unexpected server-side error occurred.
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
23 changes: 23 additions & 0 deletions api/schemas/HealthInfo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
type: object
properties:
status:
type: string
description: Service status.
enum:
- pass
version:
type: string
description: Service version.
example: 0.0.1
commit:
type: string
description: Service commit hash.
example: 7d6f4dc4f7f0c1fa3dc24eddfb18bb5073ff4f62
description:
type: string
description: Service description.
example: <service_name> service
build_time:
type: string
description: Service build time.
example: 1970-01-01_00:00:00
17 changes: 17 additions & 0 deletions api/things.yml
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ paths:
description: Database can't process request.
'500':
$ref: "#/components/responses/ServiceError"
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:
schemas:
Key:
Expand Down Expand Up @@ -1096,3 +1107,9 @@ components:
schema:
type: string
format: byte
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
16 changes: 16 additions & 0 deletions api/twins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ paths:
description: Twin does not exist.
'500':
$ref: '#/components/responses/ServiceError'
/health:
get:
summary: Retrieves service health check info.
tags:
- health
responses:
'200':
$ref: "#/components/responses/HealthRes"
'500':
$ref: "#/components/responses/ServiceError"

components:
parameters:
Expand Down Expand Up @@ -365,3 +375,9 @@ components:
$ref: '#/components/schemas/StatesPage'
ServiceError:
description: Unexpected server-side error occurred.
HealthRes:
description: Service Health Check.
content:
application/json:
schema:
$ref: "./schemas/HealthInfo.yml"
Loading

0 comments on commit 094f59d

Please sign in to comment.