Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when run Rover on Ubuntu and error 404 when checking Terraform Cloud Agent exist #357

Open
hanganhhung123 opened this issue Nov 16, 2023 · 2 comments

Comments

@hanganhhung123
Copy link
Contributor

1. An error occur when I run Rover on Ubuntu 20.04

in tfcloud.sh#539 file, function process_curl_response() has 2 lines to curl the TFE with token and redirect to STDERR by 2> >(tee /dev/stderr)

command="curl -sS -L -w '%{http_code}' --header 'Authorization: Bearer xxxxxx' --header 'Content-Type: application/vnd.api+json' $options -- '"${url}"' 2> >(tee /dev/stderr)"
debug "$(echo "Running command: $command")" >&2
command="curl -sS -L -w '%{http_code}' --header 'Authorization: Bearer  "$REMOTE_ORG_TOKEN"' --header 'Content-Type: application/vnd.api+json' $options -- '"${url}"' 2> >(tee /dev/stderr)"

When I try to do the migration to Terraform Cloud, below is the error I'm face with

tee: /dev/stderr: No such device or address
Error /tf/rover/tfcloud/tfcloud.sh on or near line 543; exiting with status 1

I have made some changes to remove the 2> >(tee /dev/stderr) out of tfcloud.sh and rerun the migration, it's worked.
So I need some help to remove the 2> >(tee /dev/stderr) in the code, or are there any other solution for it?

2. Terraform Cloud Agent Check failure

in tfcloud.sh#43, the function check_terraform_cloud_agent_exist() check if the tfcloud agent exist via url

url="https://${TF_VAR_tf_cloud_hostname}/api/v2/organizations/${TF_VAR_tf_cloud_organization}/agent-pools"

or

url="https://${TF_VAR_tf_cloud_hostname}/api/v2/organizations/${TF_VAR_tf_cloud_organization}/agent-pools/${gitops_agent_pool_id}"

When I run the Terraform Cloud migrate/plan/apply with agent mode, it throw this error:

Gracefully continue on error: HTTP status code is 404 for https://*****.com/api/v2/organizations/*****/agent-pools/apool-*****
apool-*****

Base on the latest api-docs from Harshicorp to list agent, the valid format of the url must not have the suffix /organizations/${TF_VAR_tf_cloud_organization}. It has pass from my testing also.
I need some help to fix it for latest run.

@LaurentLesle
Copy link
Contributor

Can you check the user running the rover has permission to /dev/stderr?

ls -l /dev/stderr

@hanganhhung123
Copy link
Contributor Author

Hi @LaurentLesle, The agent is runing with root user and it can access to /dev/stderr as bellow.
Screenshot 2023-12-18 at 15 31 49
I found out that /dev/stderr is equivalent with &2. On linux, write to &2 works for every user; write to /dev/stderr works only for root users. I don't know why root user cannot write standard error into stderr.
I have make some test to replace 2> >(tee /dev/stderr) by 2> >(tee -a >&2) and the error gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants