Skip to content

Restart Policies directory with features - #433

Open
grobeert wants to merge 7 commits into
unikraft-cloud:mainfrom
grobeert:main
Open

Restart Policies directory with features#433
grobeert wants to merge 7 commits into
unikraft-cloud:mainfrom
grobeert:main

Conversation

@grobeert

@grobeert grobeert commented Jul 9, 2026

Copy link
Copy Markdown

No description provided.

@grobeert
grobeert marked this pull request as ready for review July 9, 2026 13:55
@razvand
razvand requested a review from Copilot July 11, 2026 06:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Python-based HTTP server example intended to demonstrate Unikraft Cloud restart policies by providing endpoints that can exit with configurable codes, plus deployment/API helper scripts and documentation.

Changes:

  • Introduces a minimal Python HTTP server with /, /health, and /exit?code=N.
  • Adds a walkthrough README for deploying instances with never, always, and on-failure restart policies.
  • Adds a Kraftfile + Dockerfile and simple bash scripts to create/list/interact/delete instances via the API.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
httpserver-python-restartpolicie/server.py New HTTP server implementation used to trigger exits and observe restart behavior.
httpserver-python-restartpolicie/README.md Usage docs for deploying/testing restart policies via CLI and API scripts.
httpserver-python-restartpolicie/Kraftfile.yml New build/runtime configuration for the example.
httpserver-python-restartpolicie/Dockerfile Rootfs definition for packaging the example payload.
httpserver-python-restartpolicie/api/create.sh Creates an instance via the Unikraft Cloud API.
httpserver-python-restartpolicie/api/list.sh Lists instances via the Unikraft Cloud API.
httpserver-python-restartpolicie/api/interact.sh Calls the example’s endpoints via HTTPS.
httpserver-python-restartpolicie/api/delete.sh Deletes an instance via the Unikraft Cloud API.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread httpserver-python-restartpolicie/server.py Outdated
Comment thread httpserver-python-restartpolicie/server.py Outdated
Comment thread httpserver-python-restartpolicie/README.md
Comment thread httpserver-python-restartpolicie/Kraftfile.yml
Comment thread httpserver-python-restartpolicie/Dockerfile
Comment thread httpserver-python-restartpolicie/api/list.sh
Comment thread httpserver-python-restartpolicie/api/delete.sh
Comment thread httpserver-python-restartpolicie/api/create.sh
Comment thread httpserver-python-restartpolicie/api/interact.sh
Comment thread httpserver-python-restartpolicie/server.py
@razvand razvand self-assigned this Jul 11, 2026
@razvand
razvand requested a lite review from Copilot August 21, 2026 20:11
@razvand razvand added the enhancement New feature or request label Aug 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Suppressed comments (6)

httpserver-python-restartpolicie/server.py:22

  • /exit parses the code query parameter with int(...) without validation; a non-integer value (e.g. ?code=foo) raises ValueError and results in an unhandled exception instead of a controlled response.
        elif parsed.path == "/exit":
            code = int(params.get("code", ["0"])[0])
            self._respond(200, f"Exiting with code {code}...\n")
            self.wfile.flush()
            sys.exit(code)

httpserver-python-restartpolicie/README.md:35

  • The README lists server endpoints but omits GET /health, even though the server implements it (returns OK). This can confuse readers trying to verify liveness behavior.
| Endpoint | Description |
|----------|-------------|
| `GET /` | Returns `Hello from restart-demo!` |
| `GET /exit?code=N` | Calls `sys.exit(N)` — simulates crash or clean exit |

httpserver-python-restartpolicie/Kraftfile.yml:5

  • This Kraftfile uses spec: v0.6 and the short-form rootfs: ./Dockerfile, but the rest of the repo’s Kraftfiles consistently use spec: v0.7 with an explicit rootfs.source + rootfs.format (e.g. httpserver-bun/Kraftfile:1-11). Using the consistent format reduces tooling surprises across examples.
spec: v0.6
name: restart-demo
runtime: python:3.12
rootfs: ./Dockerfile
cmd: ["/usr/bin/python3", "/app/server.py"]

httpserver-python-restartpolicie/api/list.sh:8

  • The API endpoint is hardcoded to the fra metro. Since the README instructs users to set UKC_METRO, hardcoding the region makes the script fail for other metros.
curl -s \
  -H "Authorization: Bearer $UKC_TOKEN" \
  https://api.fra.unikraft.cloud/v1/instances \
  | jq .

httpserver-python-restartpolicie/api/create.sh:23

  • The instance-create script hardcodes the fra metro in the API URL, which contradicts the README’s UKC_METRO setup and breaks usage in other regions.
curl -s \
  -X POST \
  -H "Authorization: Bearer $UKC_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{
    \"name\": \"$NAME\",
    \"image\": \"$IMAGE\",
    \"memory_mb\": $MEMORY,
    \"restart_policy\": \"$POLICY\",
    \"autostart\": true
  }" \
  https://api.fra.unikraft.cloud/v1/instances \
  | jq .

httpserver-python-restartpolicie/api/delete.sh:12

  • The delete script hardcodes the fra metro in the API URL. Using UKC_METRO (with a sensible default) makes it consistent with the README and usable across regions.
curl -s \
  -X DELETE \
  -H "Authorization: Bearer $UKC_TOKEN" \
  https://api.fra.unikraft.cloud/v1/instances/$UUID \
  | jq .

Comment thread httpserver-python-restartpolicie/README.md
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: grobeert <grobeert@gmail.com>

@grobeert grobeert left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change metro from hardcoded FRA to user's metro

@grobeert grobeert left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example coverd by CI

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are correctness/convention issues that can impact usability (mixed \r characters in server.py, incomplete endpoint docs, and a non-standard Kraftfile name/spec compared to the rest of the repo).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (6)

Previously missed (1) — in code that hasn't changed since the last review.

httpserver-python-restartpolicie/server.py:37

  • address_string() can trigger reverse-DNS lookups per request, which can add latency. Logging the raw client IP avoids that overhead.

httpserver-python-restartpolicie/README.md:35

  • The README’s endpoint table is missing GET /health, but the server implements it (server.py:15-16). This makes the documented interface incomplete.
| Endpoint | Description |
|----------|-------------|
| `GET /` | Returns `Hello from restart-demo!` |
| `GET /exit?code=N` | Calls `sys.exit(N)` — simulates crash or clean exit |

httpserver-python-restartpolicie/Kraftfile.yml:5

  • This repository consistently uses Kraftfile (no extension) with spec: v0.7 (e.g., httpserver-python3.12/Kraftfile:1). Using Kraftfile.yml with spec: v0.6 is a convention deviation and may not be picked up by tooling expecting Kraftfile. Consider renaming to Kraftfile and updating to the v0.7 schema used elsewhere.
spec: v0.6
name: restart-demo
runtime: python:3.12
rootfs: ./Dockerfile
cmd: ["/usr/bin/python3", "/app/server.py"]

httpserver-python-restartpolicie/api/list.sh:7

  • The setup section asks users to set UKC_METRO, but this script always calls the FRA API endpoint. Using UKC_METRO here makes the script work across metros without edits.
  -H "Authorization: Bearer $UKC_TOKEN" \
  https://api.fra.unikraft.cloud/v1/instances \

httpserver-python-restartpolicie/api/create.sh:22

  • This script hard-codes the FRA API endpoint, so it won’t work if the user’s metro differs from fra. Parameterize the base URL using UKC_METRO to match the README setup.
  }" \
  https://api.fra.unikraft.cloud/v1/instances \

httpserver-python-restartpolicie/api/delete.sh:11

  • This script hard-codes the FRA API endpoint, so it won’t work if the user’s metro differs from fra. Parameterize the base URL using UKC_METRO to match the README setup.
  -H "Authorization: Bearer $UKC_TOKEN" \
  https://api.fra.unikraft.cloud/v1/instances/$UUID \
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread httpserver-python-restartpolicie/server.py
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: grobeert <grobeert@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants