I am unable to upload/download files to/from a CHI@Edge container.
python-chi==1.1.0
python-blazarclient==3.7.0
python-cinderclient==8.3.0
python-glanceclient==3.6.0
python-ironicclient==5.11.0
python-keystoneclient==5.6.0
python-manilaclient==5.5.0
python-neutronclient==7.8.0
python-novaclient==18.9.0
python-openstackclient==5.8.1
python-swiftclient==4.7.0
python-zunclient==5.2.1
websocket-client==1.8.0
from chi import lease, container
if __name__ == "__main__":
user = "alpha"
elease = f"{user}-edge"
ereservations = []
try:
el = lease.get_lease(elease)
if el["status"] == "TERMINATED":
lease.delete_lease(el["id"])
raise ValueError("Lease is not active")
except Exception:
lease.add_device_reservation(
ereservations, count=1, machine_name="raspberrypi4-64"
)
start_date, end_date = lease.lease_duration(hours=1)
print("Creating lease")
el = lease.create_lease(elease, ereservations)
lease.wait_for_active(elease)
ename = "a-edge-1"
reservation_id = lease.get_device_reservation(elease)
print("Lease Id:", el["id"])
print("Reservation Id:", reservation_id)
try:
c = container.get_container(ename)
except:
c = container.create_container(
ename,
image="rockylinux:8",
reservation_id=reservation_id,
platform_version=2,
interactive=True,
)
container.wait_for_active(ename)
print("Container:", c.uuid)
print(container.execute(c.uuid, "ls"))
print(
container.upload(
c.uuid,
"./apptainer.sh",
"/tmp/abc",
)
)
print(
container.download(
c.uuid,
"/tmp/ks-script-zhnv9x4d",
"./abc",
)
)
Output
Lease Id: 6cfbb91e-8e98-41d4-ae82-b0b2a732dd14
Reservation Id: 6ce571d7-f7c3-4dfb-9362-dd7ab96da113
Waiting for container a-edge-1 status to turn to Running. This can take a while depending on the image
Container: 77edd532-2c81-463e-8197-7c60bbbf9594
{'output': 'bin\ndev\netc\nhome\nlib\nlib64\nlost+found\nmedia\nmnt\nopt\nproc\nroot\nrun\nsbin\nsrv\nsys\ntmp\nusr\nvar\n', 'exit_code': 0, 'exec_id': None, 'proxy_url': None}
(<Response [200]>, None)
Traceback (most recent call last):
File "/Volumes/data/workspace/pegasus/kiso/cham.py", line 57, in <module>
container.download(
File "/Users/alpha/.pyenv/versions/oac/lib/python3.9/site-packages/chi/container.py", line 581, in download
with tarfile.open(fileobj=fd, mode="r") as tar:
File "/Users/alpha/.pyenv/versions/3.9.16/lib/python3.9/tarfile.py", line 1625, in open
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully
Even though the upload shows 200 OK response the file /tmp/abc doesn’t exist on the container.
For download, I added a print step to chi.container python source to show the received data, all I see is
b''