rpardini / tinkerbell-action-waitdaemon

Run any Tinkerbell action that will always and immediately report back as successful.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

multiarch image available at

quay.io/tinkerbellrpardini/actions/waitdaemon:latest

waitdaemon

This is a container to be used as a Tinkerbell action. It has the following purposes:

  • Run any arbitrary container image with its accompanying envs, command, volumes, etc.
  • Wait an arbitrary amount of time before running your specified container image.
  • Immediately report back to the Tink server that the action has completed successfully.

waitdaemon's main use cases are kexec-ing and rebooting a machine. Currently, in Tinkerbell, these action generally cause the STATE to never transition to STATE_SUCCESS. This has a few consequences.

  1. If/when the machine runs Tink worker again (via a network boot, for example), this action to be run again. The same issue with STATE not transistioning will continue to occur.
  2. Any entity watching and expecting the STATE_SUCCESS of the action and of the whole workflow will be unable to determine if the kexec or reboot occured or not. CAPT, for example.
  3. Poor user experience. A machine might have successfully kexec'd or rebooted but the STATE is not accurate. (This one is actually not solved by waitdaemon. A STATE_SUCCESS does not guarantee the action was successful.)

NOTE: waitdaemon does not guarantee the action was successful! Using this image means that failures in running your container are not surfaced to Tink server and your workflow. You will need to check the Smee logs for details.

Usage

Here are two example actions:

- name: "reboot"
  image: ghcr.io/jacobweinstock/waitdaemon:latest
  timeout: 90
  pid: host
  command: ["reboot"]
  environment:
    IMAGE: alpine
    WAIT_SECONDS: 10
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
- name: "kexec"
  image: ghcr.io/jacobweinstock/waitdaemon:latest
  timeout: 90
  pid: host
  environment:
    BLOCK_DEVICE: {{ formatPartition ( index .Hardware.Disks 0 ) 1 }}
    FS_TYPE: ext4
    IMAGE: quay.io/tinkerbell-actions/kexec:v1.0.0
    WAIT_SECONDS: 10
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock

Required fields

  • image: ghcr.io/jacobweinstock/waitdaemon:latest
  • This value will tell us the image to run after waiting the duration of WAIT_SECONDS.

    environment:
      IMAGE: <your image>
  • This is needed so we can create Docker containers that the Tink worker doesn't wait on.

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Optional Settings

  • WAIT_SECONDS: This is the number of seconds to wait before running your container.

Details

Under the hood, the waitdaemon is doing something akin to daemonizing or double forking a Linux process but for containers and a Tinkerbell action. All values you specify in your action. command, volumes, pid, environment, etc are propogated to your container image when it's run.

┌──────────────Action Container───────────────┐
│                                             │
│   image: ghcr.io/jacobweinstock/waitdaemon  │
│                                             │
│             ┌────process─────┐              │
│             │   waitdaemon   │              │
│             └────────┬───────┘              │
└──────────────────────┼──────────────────────┘
                       │                       
                 create, exit                  
                       │                       
                       ▼                       
┌──────────────────Container──────────────────┐
│                                             │
│   image: ghcr.io/jacobweinstock/waitdaemon  │
│                                             │
│             ┌────process─────┐              │
│             │   waitdaemon   │              │
│             └────────┬───────┘              │
└──────────────────────┼──────────────────────┘
                       │                       
               wait, create, exit              
                       │                       
                       ▼                       
┌──────────────────Container──────────────────┐
│                                             │
│              image: your image              │
│                                             │
│                                             │
│                                             │
│                                             │
└─────────────────────────────────────────────┘

About

Run any Tinkerbell action that will always and immediately report back as successful.

License:Apache License 2.0


Languages

Language:Go 71.1%Language:Makefile 25.7%Language:Dockerfile 3.2%