Skip to content

Commit

Permalink
feat(deployment): adds support for exposing healthcheck for deployments
Browse files Browse the repository at this point in the history
This commit adds support for defining liveness probe. You can set HTTP, EXEC or TCP liveness probe
  • Loading branch information
RomilShah committed Aug 4, 2023
1 parent ca67437 commit 611dbc6
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 3 deletions.
19 changes: 19 additions & 0 deletions riocli/apply/manifests/package-nonros-device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -31,6 +40,16 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.

docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down
18 changes: 18 additions & 0 deletions riocli/apply/manifests/package-ros-device-no-rosbag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -32,6 +41,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down
18 changes: 18 additions & 0 deletions riocli/apply/manifests/package-ros-device-rosbag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -32,6 +41,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down
90 changes: 90 additions & 0 deletions riocli/apply/manifests/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ spec:
limits:
cpu: 0.025 # Unit: Core Options: [Multiple of 0.025, <= 8]
memory: 128 # Unit: MB Options: [Multiple of 128, <= 32768]
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -32,6 +41,15 @@ spec:
limits:
cpu: 0.025 # Unit: Core Options: [Multiple of 0.025, <= 8]
memory: 128 # Unit: MB Options: [Multiple of 128, <= 32768]
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
pullSecret:
Expand Down Expand Up @@ -166,6 +184,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -177,6 +204,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down Expand Up @@ -299,6 +335,15 @@ spec:
limits:
cpu: 0.025 # Unit: Core Options: [Multiple of 0.025, <= 8]
memory: 128 # Unit: MB Options: [Multiple of 128, <= 32768]
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -311,6 +356,15 @@ spec:
limits:
cpu: 0.025 # Unit: Core Options: [Multiple of 0.025, <= 8]
memory: 128 # Unit: MB Options: [Multiple of 128, <= 32768]
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
pullSecret:
Expand Down Expand Up @@ -377,6 +431,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -388,6 +451,15 @@ spec:
limits: # Optional
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down Expand Up @@ -431,6 +503,15 @@ spec:
limits:
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
build:
depends:
kind: build
Expand All @@ -442,6 +523,15 @@ spec:
limits:
cpu: 0.025 # Unit: Core (Optional)
memory: 128 # Unit: MB (Optional)
livenessProbe: # Optional
exec:
command:
- "shell-cmd"
initialDelaySeconds: 5 # Number of seconds after the container has started before liveness probes are initiated.
periodSeconds: 10 # How often (in seconds) to perform the probe.
failureThreshold: 1 # Minimum consecutive failures for the probe to be considered failed after having succeeded.
successThreshold: 3 # Minimum consecutive successes for the probe to be considered successful after having failed.
timeoutSeconds: 1 # Number of seconds after which the probe times out.
docker:
image: "busybox:latest"
imagePullPolicy: "Always" # Always, Never, IfNotPresent(default)
Expand Down
56 changes: 54 additions & 2 deletions riocli/jsonschema/schemas/package-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ definitions:
- docker
- build
- preInstalled
command:
type: string
command:
type: string
runAsBash:
type: boolean
default: True
Expand All @@ -137,6 +137,58 @@ definitions:
memory:
type: number
minimum: 0
livenessProbe:
type: object
properties:
http:
type: object
properties:
path:
type: string
description: Path to access for the HTTP probe.
port:
type: integer
description: Port number for the HTTP probe.
required:
- path
- port
exec:
type: object
properties:
command:
type: array
items:
type: string
description: Command to execute for the Exec probe.
required:
- command
tcp:
type: object
properties:
port:
type: integer
description: Port number for the TCP probe.
required:
- port
initialDelaySeconds:
type: integer
description: Number of seconds after the container has started before liveness probes are initiated.
timeoutSeconds:
type: integer
default: 1
description: Number of seconds after which the probe times out.
periodSeconds:
type: integer
default: 1
description: How often (in seconds) to perform the probe.
successThreshold:
type: integer
default: 3
description: Minimum consecutive successes for the probe to be considered successful after having failed.
failureThreshold:
type: integer
default: 3
description: Minimum consecutive failures for the probe to be considered failed after having succeeded.
required:
- type
dependencies:
Expand Down
5 changes: 4 additions & 1 deletion riocli/package/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def create_object(self, client: Client, **kwargs):
component_obj.rosBagJobDefs = self.spec.rosBagJobs

pkg_object.plans[0].components = [component_obj]

return client.create_package(pkg_object)

def update_object(self, client: Client, obj: typing.Any) -> typing.Any:
Expand Down Expand Up @@ -198,6 +197,10 @@ def _map_executable(self, exec):
'memory': exec.limits.get('memory', 0)
}

if 'livenessProbe' in exec:
if exec.livenessProbe.get("http") or exec.livenessProbe.get("tcp") or exec.livenessProbe.get("exec"):
exec_object.livenessProbe = exec.livenessProbe

if exec.get('runAsBash'):
if 'command' in exec:
exec_object.cmd = ['/bin/bash', '-c', exec.command]
Expand Down

0 comments on commit 611dbc6

Please sign in to comment.