Kcr19 / mender_gcp_ota_demo

Demo scripts for a GCP+Mender demo.
Apache License 2.0
0 stars 1 forks source link

mender agent pem not available when activation agent runs #18

Closed ptone closed 5 years ago

ptone commented 5 years ago

We may need some condition wait on mender agent setting the pem:

Jan 01 00:00:12 raspberrypi3 python[240]: projects/kcr-iot-demo/locations/us-central1/registries/mender-demo/devices/g-bab1376ca1fb481595b4fedf169a1f97
Jan 01 00:00:12 raspberrypi3 python[240]: Traceback (most recent call last):
Jan 01 00:00:12 raspberrypi3 python[240]:   File "/opt/gcp/usr/bin/activate_agent.py", line 290, in <module>
Jan 01 00:00:12 raspberrypi3 python[240]:     main()
Jan 01 00:00:12 raspberrypi3 python[240]:   File "/opt/gcp/usr/bin/activate_agent.py", line 255, in main
Jan 01 00:00:12 raspberrypi3 python[240]:     client = make_client()
Jan 01 00:00:12 raspberrypi3 python[240]:   File "/opt/gcp/usr/bin/activate_agent.py", line 253, in make_client
Jan 01 00:00:12 raspberrypi3 python[240]:     "443")
Jan 01 00:00:12 raspberrypi3 python[240]:   File "/opt/gcp/usr/bin/activate_agent.py", line 174, in get_client
Jan 01 00:00:12 raspberrypi3 python[240]:     pw = create_jwt(project_id, private_key_file, algorithm)
Jan 01 00:00:13 raspberrypi3 python[240]:   File "/opt/gcp/usr/bin/activate_agent.py", line 70, in create_jwt
Jan 01 00:00:13 raspberrypi3 python[240]:     with open(private_key_file, 'r') as f:
Jan 01 00:00:13 raspberrypi3 python[240]: IOError: [Errno 2] No such file or directory: '/var/lib/mender/mender-agent.pem'
Jan 01 00:00:13 raspberrypi3 systemd[1]: [[0;1;39mmender-google-activation-agent.service: Main process exited, code=exited, status=1/FAILURE[[0m
Jan 01 00:00:13 raspberrypi3 systemd[1]: [[0;1;39mmender-google-activation-agent.service: Unit entered failed state.[[0m
Jan 01 00:00:13 raspberrypi3 systemd[1]: [[0;1;39mmender-google-activation-agent.service: Failed with result 'exit-code'.[[0m
ptone commented 5 years ago

there is a chance this is an artifact from my using an image from a mis-matched project

and having to update /opt/gcp/etc/gcp-config.sh

nope - was able to clean and recreate the issue even with an accurate gcp-config.sh

Is there an easy way to make this a condition in the systemd service file, or should the python script just while loop with sleep until that file exists?? (a quick look indicates ConditionPathExists for systemd is only checked once, and does not loop - so I'm guessing we bake more of this into the python activator)