Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement health checks and graceful termination #1

Merged
merged 27 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4a4af10
Implement health checks and graceful termination
omus Mar 4, 2024
0b702ce
Add GitHub workflows
omus Mar 4, 2024
3d1b783
Rename endpoint functions
omus Mar 4, 2024
b3cf654
Add docstrings to health check functions
omus Mar 4, 2024
8b04c15
Add badges to README
omus Mar 5, 2024
754f117
Add manual
omus Mar 5, 2024
26a9d9b
Add both stable/dev docs badges
omus Mar 5, 2024
48ba856
Specify YAS formatting
omus Mar 5, 2024
e7b16a3
fixup! Rename endpoint functions
omus Mar 5, 2024
8634d3b
Reference localhost more
omus Mar 5, 2024
bfb54ef
Document keyword `set_entrypoint`
omus Mar 5, 2024
e696698
Comment on dead code
omus Mar 5, 2024
7b40f99
Log invalid graceful terminator requests
omus Mar 5, 2024
75d2a18
Add argument documentation to `K8sDeputy.serve!`
omus Mar 5, 2024
507519c
Add quickstart guide
omus Mar 5, 2024
a0e2670
Use default K8sDeputy.jl port in quickstart
omus Mar 5, 2024
c66f6bb
Formatting
omus Mar 5, 2024
74af1f9
Add LICENSE file
omus Mar 5, 2024
84a32de
fixup! Add LICENSE file
omus Mar 5, 2024
435a121
Documentation corrections
omus Mar 8, 2024
98af4cf
Indicate mutating health functions
omus Mar 8, 2024
351eb9d
Rename `entrypoint_pid(::Integer)` to `set_entrypoint_pid`
omus Mar 8, 2024
b3b9eae
Document custom exit status
omus Mar 8, 2024
59ae13f
fixup! Indicate mutating health functions
omus Mar 8, 2024
4e7ed3c
Fix note syntax
omus Mar 8, 2024
5097c6f
Add test for gracefully terminating multiple Julia processes
omus Mar 8, 2024
7d4c703
Cross reference graceful termination
omus Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style = "yas"
59 changes: 59 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: CI
on:
workflow_dispatch:
push:
branches:
- main
tags: ["*"]
paths:
- "src/**"
- "test/**"
- "Project.toml"
- ".github/workflows/CI.yaml"
pull_request:
paths:
- "src/**"
- "test/**"
- "Project.toml"
- ".github/workflows/CI.yaml"
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.runs-on }} - ${{ matrix.arch }} - ${{ matrix.threads}} threads
# These permissions are needed to:
# - Delete old caches: https://github.com/julia-actions/cache#cache-retention
permissions:
actions: write
contents: read
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
version:
- "1.6" # Earliest version of Julia that the package is compatible with
- "1" # Latest Julia release
runs-on:
- ubuntu-latest
arch:
- x64
threads:
- 1
env:
JULIA_NUM_THREADS: ${{ matrix.threads }}
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
with:
file: lcov.info
39 changes: 39 additions & 0 deletions .github/workflows/DocPreviewCleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
# remove PR previews once they're merged
# <https://juliadocs.github.io/Documenter.jl/dev/man/hosting/#gh-pages-Branch>
name: Doc Preview Cleanup
on:
pull_request:
types: [closed]

# Ensure that only one "Doc Preview Cleanup" workflow is force pushing at a time
concurrency:
group: doc-preview-cleanup
cancel-in-progress: false

jobs:
doc-preview-cleanup:
runs-on: ubuntu-latest
permissions:
contents: write
env:
PR: ${{ github.event.number }}
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Delete preview and history + push changes
run: |
preview_dir="previews/PR${PR?}"
if [ -d "${preview_dir}" ]; then
# Delete preview directory created by this PR
git rm -rf "${preview_dir}"
# Commit the removed preview directories and truncate history
git config user.name "Documenter.jl"
git config user.email "[email protected]"
git commit -m "delete preview"
git branch gh-pages-new $(echo "squash history" | git commit-tree HEAD^{tree})
git push --force origin gh-pages-new:gh-pages
fi
58 changes: 58 additions & 0 deletions .github/workflows/Documenter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
name: Documenter
on:
workflow_dispatch:
push:
tags: ["*"]
branches:
- main
paths:
- "docs/**"
- "src/**"
- "Project.toml"
- ".github/workflows/Documenter.yaml"
pull_request:
paths:
- "docs/**"
- "src/**"
- "Project.toml"
- ".github/workflows/Documenter.yaml"
- ".github/workflows/DocPreviewCleanup.yaml"
jobs:
docs:
name: Build
# These permissions are needed to:
# - Delete old caches: https://github.com/julia-actions/cache#usage
permissions:
actions: write
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: "1"
show-versioninfo: true
- uses: julia-actions/cache@v1
- name: Install dependencies
shell: julia --project=docs --color=yes {0}
run: |
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
- name: Build docs
uses: julia-actions/julia-docdeploy@v1
with:
install-package: false # Avoid instantiating twice
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Preview URL
if: ${{ github.event_name == 'pull_request' }}
run: |
repo_owner="${repo%/*}" # e.g. JuliaLang
repo_name="${repo#*/}" # e.g. Example.jl
echo ":books: Documentation preview available at:" | tee -a "$GITHUB_STEP_SUMMARY"
echo "<https://${repo_owner}.github.io/${repo_name}/previews/PR${PR}>" | tee -a "$GITHUB_STEP_SUMMARY"
env:
repo: ${{ github.repository }} # e.g. JuliaLang/Example.jl
PR: ${{ github.event.number }}
46 changes: 46 additions & 0 deletions .github/workflows/FormatCheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
name: Format Check
on:
push:
branches:
- main
tags: ["*"]
paths:
- "**/*.jl"
- ".github/workflows/FormatCheck.yaml"
pull_request:
paths:
- "**/*.jl"
- ".github/workflows/FormatCheck.yml"
jobs:
format-check:
name: Julia
# These permissions are needed to:
# - Delete old caches: https://github.com/julia-actions/cache#usage
# - Post formatting suggestions: https://github.com/reviewdog/action-suggester#required-permissions
permissions:
actions: write
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: "1"
- uses: julia-actions/cache@v1
- name: Install JuliaFormatter
shell: julia --project=@format --color=yes {0}
run: |
using Pkg
Pkg.add(PackageSpec(; name="JuliaFormatter", version="1"))
- name: Check formatting
shell: julia --project=@format --color=yes {0}
run: |
using JuliaFormatter
format("."; verbose=true) || exit(1)
# Add formatting suggestions to non-draft PRs even if when "Check formatting" fails
- uses: reviewdog/action-suggester@v1
if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.draft == false }}
with:
tool_name: JuliaFormatter
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs/build
Manifest.toml
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2024 Beacon Biosignals, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name = "K8sDeputy"
uuid = "2481ae95-212f-4650-bb21-d53ea3caf09f"
authors = ["Beacon Biosignals, Inc"]
version = "0.1.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Mocking = "78c3b35d-d492-501b-9361-3d52fe80e533"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"

[compat]
Aqua = "0.7"
Dates = "1"
HTTP = "1"
Mocking = "0.7"
Sockets = "1"
Test = "1"
julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Test"]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# K8sDeputy.jl
Provides K8s health checks and graceful termination support on behalf of Julia services

[![CI](https://github.com/beacon-biosignals/K8sDeputy.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/beacon-biosignals/K8sDeputy.jl/actions/workflows/CI.yml)
[![Code Style: YASGuide](https://img.shields.io/badge/code%20style-yas-violet.svg)](https://github.com/jrevels/YASGuide)
[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://beacon-biosignals.github.io/K8sDeputy.jl/stable)
[![Dev Documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://beacon-biosignals.github.io/K8sDeputy.jl/dev)

Provides K8s health checks and graceful termination support on behalf of Julia services.
6 changes: 6 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
K8sDeputy = "2481ae95-212f-4650-bb21-d53ea3caf09f"

[compat]
Documenter = "1.0.0"
18 changes: 18 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using K8sDeputy
using Documenter

pages = ["Home" => "index.md",
"Quickstart" => "quickstart.md",
"Health Checks" => "health_checks.md",
"Graceful Termination" => "graceful_termination.md",
"API" => "api.md"]

makedocs(; modules=[K8sDeputy],
format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true"),
sitename="K8sDeputy.jl",
authors="Beacon Biosignals",
pages)

deploydocs(; repo="github.com/beacon-biosignals/K8sDeputy.jl.git",
push_preview=true,
devbranch="main")
10 changes: 10 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# API

```@docs
Deputy
K8sDeputy.serve!
readied!
shutdown!
graceful_terminator
graceful_terminate
```
Loading
Loading