ansible/receptor

Receptor can't be started with pre-defined pod specification

kurokobo opened this issue ยท 0 comments

Description

Defining work-kubernetes with pre-defined pod without allowruntimecommand or allowruntimepod causes following error on startup.

$ ./receptor -c ./receptor.yml 
Error: must specify a container image to run

Version

Using Receptor built by make receptor on upstream devel branch.

$ receptorctl --socket /tmp/receptor.sock version
Warning: receptorctl and receptor are different versions, they may not be compatible
receptorctl  1.3.0
receptor     v1.3.0+g8f8481c

Steps to reproduce

Start Receptor with following configuration file.

---
- local-only:
- node:
    id: demo
- log-level:
    level: debug
- control-service:
    service: control
    filename: /tmp/receptor.sock
- work-kubernetes:
    worktype: demo
    authmethod: kubeconfig
    kubeconfig: /etc/rancher/k3s/k3s.yaml
    pod: /tmp/pod.yml
$ ./receptor -c ./receptor.yml 
Error: must specify a container image to run

Appending allowruntimecommand: true or allowruntimepod: true which do not actually make sense to the configuration file solves the issue.

...
- work-kubernetes:
    worktype: demo
    authmethod: kubeconfig
    kubeconfig: /etc/rancher/k3s/k3s.yaml
    pod: /tmp/pod.yml
    allowruntimecommand: true     ๐Ÿ‘ˆ๐Ÿ‘ˆ๐Ÿ‘ˆ
$ ./receptor -c ./receptor.yml 
INFO 2022/12/20 06:50:45 Running control service control
INFO 2022/12/20 06:50:45 Initialization complete
...

Additional information

Following validation for cfg.Image == "" should trigger only when cfg.Pod is empty.

if cfg.Pod != "" && (cfg.Image != "" || cfg.Command != "" || cfg.Params != "") {
return fmt.Errorf("can only provide Pod when Image, Command, and Params are empty")
}
if cfg.Image == "" && !cfg.AllowRuntimeCommand && !cfg.AllowRuntimePod {
return fmt.Errorf("must specify a container image to run")
}