1
23.7 Legacy Series / Re: gcloud plugin exits with 120 code
« on: January 04, 2024, 03:48:03 pm »
Aha, got to the bottom of it. Proposed a fix here https://github.com/opnsense/plugins/pull/3745
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
LeUtils::run_shell_command("/usr/local/bin/gcloud --verbosity=debug config configurations list 2>&1 >> /tmp/deleteme.log", $proc_env);
LeUtils::run_shell_command("/usr/local/bin/gcloud --verbosity=debug config configurations create ${gcloud_config} 2>&1 >> /tmp/deleteme.log", $proc_env);
LeUtils::run_shell_command("/usr/local/bin/gcloud --verbosity=debug config configurations activate ${gcloud_config} 2>&1 >> /tmp/deleteme.log", $proc_env);
LeUtils::run_shell_command("/usr/local/bin/gcloud --verbosity=debug auth activate-service-account --key-file=${gcloud_key_file} 2>&1 >> /tmp/deleteme.log", $proc_env);
LeUtils::run_shell_command("/usr/local/bin/gcloud --verbosity=debug config set account ${gcloud_account} 2>&1 >> /tmp/deleteme.log", $proc_env);
LeUtils::run_shell_command("/usr/local/bin/gcloud --verbosity=debug config set project ${gcloud_project} 2>&1 >> /tmp/deleteme.log", $proc_env);
David is right. The 120 code was added in Issue 5319, as a way of indicating a problem in the final stages of the interpreter exiting. The two conditions that trigger this are calling the flush() method on sys.stdout and sys.stderr. If you add a dummy flush() implementation, it no longer exits with 120:
2023-10-06T10:21:21 Notice opnsense AcmeClient: certificate must be issued/renewed: router.my.cert
2023-10-06T10:21:21 Notice opnsense AcmeClient: issue certificate: router.my.cert
2023-10-06T10:21:21 Notice opnsense AcmeClient: using CA: letsencrypt
2023-10-06T10:21:21 Notice opnsense AcmeClient: account is registered: Let's Encrypt
2023-10-06T10:21:21 Notice opnsense AcmeClient: Google Cloud DNS project name: my-project-infrastructure
2023-10-06T10:21:22 Error opnsense /usr/local/opnsense/scripts/OPNsense/AcmeClient/lecert.php: AcmeClient: The shell command '/usr/local/bin/gcloud --quiet config configurations create acme-651fd0c54d1f40-20765247' returned exit code '120'
2023-10-06T10:21:23 Error opnsense /usr/local/opnsense/scripts/OPNsense/AcmeClient/lecert.php: AcmeClient: The shell command '/usr/local/bin/gcloud --quiet config configurations activate acme-651fd0c54d1f40-20765247' returned exit code '120'
2023-10-06T10:21:24 Error opnsense /usr/local/opnsense/scripts/OPNsense/AcmeClient/lecert.php: AcmeClient: The shell command '/usr/local/bin/gcloud --quiet auth activate-service-account --key-file=/tmp/acme_dns_gcloud_651fd0c54d1f40-20765247.json' returned exit code '120'
2023-10-06T10:21:24 Error opnsense /usr/local/opnsense/scripts/OPNsense/AcmeClient/lecert.php: AcmeClient: The shell command '/usr/local/bin/gcloud --quiet config set account terraform@my-project-infrastructure.iam.gserviceaccount.com' returned exit code '120'
2023-10-06T10:21:26 Error opnsense /usr/local/opnsense/scripts/OPNsense/AcmeClient/lecert.php: AcmeClient: The shell command '/usr/local/bin/gcloud --quiet config set project my-project-infrastructure' returned exit code '120'
2023-10-06T10:21:26 Notice opnsense AcmeClient: using challenge type: Google Cloud DNS - my.cert
2023-10-06T10:21:32 Error opnsense AcmeClient: domain validation failed (dns01)
2023-10-06T10:21:32 Error opnsense AcmeClient: validation for certificate failed: router.my.cert