Error: The remote "xxx" doesn't exist with lxc file push

Hi, I encounterd the following problem, namely when I issued the command:

for instance in worker-0 worker-1 worker-2; do
     lxc file push ca.pem ${instance}-key.pem ${instance}.pem ${instance}/root/
done

I got the following:

Error: The remote “worker-0” doesn’t exist
Error: The remote “worker-1” doesn’t exist
Error: The remote “worker-2” doesn’t exist

Details:

lxc version
Client version: 4.18
Server version: 4.18

lxc info

config:
core.https_address: ‘[::]:8443’
core.trust_password: true
api_status: stable
api_version: “1.0”
auth: trusted
public: false
auth_methods:
- tls
environment:
addresses:
- 192.168.80.130:8443
- 192.168.122.1:8443
- 10.82.140.1:8443
architectures:
- x86_64
- i686
certificate: |

driver: lxc | qemu
driver_version: 4.0.10 | 6.1.0
firewall: xtables
kernel: Linux
kernel_architecture: x86_64
kernel_features:
netnsid_getifaddrs: “true”
seccomp_listener: “false”
seccomp_listener_continue: “false”
shiftfs: “false”
uevent_injection: “true”
unpriv_fscaps: “true”
kernel_version: 4.18.0-305.19.1.el8_4.x86_64
lxc_features:
cgroup2: “true”
devpts_fd: “true”
idmapped_mounts_v2: “true”
mount_injection_file: “true”
network_gateway_device_route: “true”
network_ipvlan: “true”
network_l2proxy: “true”
network_phys_macvlan_mtu: “true”
network_veth_router: “true”
pidfd: “true”
seccomp_allow_deny_syntax: “true”
seccomp_notify: “true”
seccomp_proxy_send_notify_fd: “true”
os_name: CentOS Linux
os_version: “8”
project: default
server: lxd
server_clustered: false
server_name: lab.example.com
server_pid: 11530
server_version: “4.18”
storage: lvm
storage_version: 2.03.07(2) (2019-11-30) / 1.02.167 (2019-11-30) / 4.43.0
storage_supported_drivers:
- name: btrfs
version: 5.4.1
remote: false
- name: cephfs
version: 15.2.13
remote: true
- name: dir
version: “1”
remote: false
- name: lvm
version: 2.03.07(2) (2019-11-30) / 1.02.167 (2019-11-30) / 4.43.0
remote: false
- name: ceph
version: 15.2.13
remote: true

> lxc list                                                                                                                                                                                                        
> +--------------+---------+----------------------+------+-----------+-----------+                                                                                                                                  
> |     NAME     |  STATE  |         IPV4         | IPV6 |   TYPE    | SNAPSHOTS |
> +--------------+---------+----------------------+------+-----------+-----------+
> | controller-0 | RUNNING | 10.82.140.178 (eth0) |      | CONTAINER | 0         |
> +--------------+---------+----------------------+------+-----------+-----------+
> | controller-1 | RUNNING | 10.82.140.60 (eth0)  |      | CONTAINER | 0         |
> +--------------+---------+----------------------+------+-----------+-----------+
> | controller-2 | RUNNING | 10.82.140.94 (eth0)  |      | CONTAINER | 0         |
> +--------------+---------+----------------------+------+-----------+-----------+
> | haproxy      | RUNNING | 10.82.140.5 (eth0)   |      | CONTAINER | 0         |
> +--------------+---------+----------------------+------+-----------+-----------+
> | worker-0     | RUNNING | 10.82.140.253 (eth0) |      | CONTAINER | 0         |
> +--------------+---------+----------------------+------+-----------+-----------+
> | worker-1     | RUNNING | 10.82.140.200 (eth0) |      | CONTAINER | 0         |
> +--------------+---------+----------------------+------+-----------+-----------+
> | worker-2     | RUNNING | 10.82.140.8 (eth0)   |      | CONTAINER | 0         |
> +--------------+---------+----------------------+------+-----------+-----------+


> lxc remote list
> +-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
> |      NAME       |                   URL                    |   PROTOCOL    |  AUTH TYPE  | PUBLIC | STATIC | GLOBAL |
> +-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
> | images          | https://images.linuxcontainers.org       | simplestreams | none        | YES    | NO     | NO     |
> +-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
> | local (current) | unix://                                  | lxd           | file access | NO     | YES    | NO     |
> +-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
> | ubuntu          | https://cloud-images.ubuntu.com/releases | simplestreams | none        | YES    | YES    | NO     |
> +-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+
> | ubuntu-daily    | https://cloud-images.ubuntu.com/daily    | simplestreams | none        | YES    | YES    | NO     |
> +-----------------+------------------------------------------+---------------+-------------+--------+--------+--------+s

If you run the lxc file push command manually outside of the script does it work?

Also this is an invalid invocation of the command.

lxc file push help shows:

 lxc file push
Description:
  Push files into instances

Usage:
  lxc file push <source path> [<remote>:]<instance>/<path> [[<remote>:]<instance>/<path>...] [flags]

So you can only provide 1 source file path, not multiple. You can specify multiple destinations for the file.

This is likely the problem.

Although now I’m not so sure, just tried it with multiple source files and it worked fine, suggesting the documentation is invalid.

I just tried your script and couldn’t recreate the issue.

I’ve opened:

to clarify this issue.

I’ve got confirmation that the documentation is at fault and the command works as you originally expected it to. (i.e multiple source files, a single target)

As for the original problem, I’d like to see the exact command fail when run manually outside of the script.

Can confirm that outside of the loop when I type it manually it works.

@tomp Could you please clarify if the script(for loop) works on your end?

Alright, appologise for bothering you. Now I just noticed that script which I was using had additonal colon:

for instance in worker-0 worker-1 worker-2; do
lxc file push ca.pem ${instance}-key.pem ${instance}.pem ${instance}:/root/
done

That’ll do it :slight_smile:
Don’t worry, it allowed me to find the documentation issue.