prehistoric-account-60014
12/31/2019, 6:09 PMcould not get cloud url: unmarshalling credentials file: unexpected end of JSON input
? Specifically after calling gcloud auth activate-service-account --key-file "$KEY_FILE"
successfully?error: could not deserialize deployment: constructing secrets manager of type "service": getting access token: unmarshalling credentials file: unexpected end of JSON input
white-balloon-205
~/.pulumi
folder got corrupted and is no longer valid JSON. Likely a credentials.json
?prehistoric-account-60014
12/31/2019, 9:45 PMpulumi login
before each command and then the second issue came upcurl -fsSL <https://get.pulumi.com/> | bash
export PATH=$PATH:$HOME/.pulumi/bin
pulumi login
#!/bin/sh
set -e
if [ -z ${PULUMI_STACK+x} ]; then
echo PULUMI_STACK is not set. Exiting...
exit 1
fi
pulumi login
pulumi stack init "$PULUMI_STACK" || true
if [[ "$PULUMI_STACK" != "production" ]] || [[ "$PULUMI_STACK" != "staging" ]]; then
pulumi config refresh --stack development || true
json="$(pulumi config --stack development --show-secrets --json)"
keys="$(echo $json | jq -r 'keys[]')"
for key in $(echo $keys | tr '\n' ' ')
do
value="$(echo $json | jq -r '.["'"$key"'"].value')"
is_secret="$(echo $json | jq -r '.["'"$key"'"].secret')"
pulumi config --stack "$PULUMI_STACK" set "$key" "$value" $(if [ $is_secret = 'true' ]; then echo '--secret'; fi)
done
fi
pulumi login
I added after seeing the first error but then I subsequently got the other one.curl <https://sdk.cloud.google.com> | bash > /dev/null
export PATH=$PATH:/root/google-cloud-sdk/bin
KEY_FILE="$(mktemp)"
echo "$GCP_SERVICE_ACCOUNT" > "$KEY_FILE"
gcloud auth activate-service-account --key-file "$KEY_FILE"
mammoth-elephant-55302
02/03/2020, 7:30 PMprehistoric-account-60014
02/04/2020, 12:58 AMmammoth-elephant-55302
02/04/2020, 2:42 AMprehistoric-account-60014
02/04/2020, 2:43 AMcat "$KEY_FILE"
to see if the JSON was malformed and it seems fine. This time everything worked, though, so it’s possible it wasn’t before.mktemp
so instead I saved the keyfile in "$HOME/key.json"
but that didn’t help.cat
in there to make sure the key file is not malformed…white-balloon-205
prehistoric-account-60014
02/04/2020, 8:53 PMerror: could not get cloud url: unmarshalling credentials file: unexpected end of JSON input
white-balloon-205
~/.pulumi/credentials.json
. What OS are you on? Are you doing anything you think could possibly lead to corrupting the contents of that file?prehistoric-account-60014
02/05/2020, 3:31 PMnode:10-alpine
image. As for what I’m doing, I don’t think there’s anything that would result in a malformed credentials file. I basically do the two things I linked towards the beginning of the thread, install Pulumi once and then deploy a stack for each service.cat "$HOME/.pulumi/credentials.json
before running pulumi up
and see if the JSON is somehow malformed.{
"current": "<https://api.pulumi.com>",
"accessTokens": {
"<https://api.pulumi.com>": "[MASKED]"
},
"accounts": {
"<https://api.pulumi.com>": {
"accessToken": "[MASKED]",
"username": "miguel",
"lastValidatedAt": "2020-02-05T17:15:45.14108518Z"
}
}
cat "$HOME/.pulumi/credentials.json" | jq -c
to see if it’s all there or if there’s something weird with a file descriptor staying open causing the error{
"current": "<https://api.pulumi.com>",
"accessTokens": {
"<https://api.pulumi.com>": "[MASKED]"
},
"accounts": {
"<https://api.pulumi.com>": {
"accessToken": "[MASKED]",
"username": "miguel",
"lastValidatedAt": "2020-02-05T20:01:08.004514991Z"
}
}
error: stack 'review-mo-pulumi-pzf6a4' already exists
error: no previous deployment
error: could not get cloud url: unmarshalling credentials file: unexpected end of JSON input
}
cat "$HOME/.pulumi/credentials.json"
just before calling pulumi up
cat "$HOME/.pulumi/credentials.json"
pulumi stack init "$PULUMI_STACK" || true
pulumi config refresh --stack makeswift/development || true
json="$(pulumi config --stack makeswift/development --show-secrets --json)"
|| true
but the pulumi config
needs the credentials to show the secrets and that’s where it fails.white-balloon-205
prehistoric-account-60014
02/05/2020, 11:12 PMpulumi config
. Another observation is that there are multiple scripts running in parallel configuring different stacks and reading the credentials file. I don’t know if Pulumi modifies the file while this is happening, but if it does it might mean that running Pulumi commands concurrently isn’t safe as one command might attempt to read the file while another one is modifying it. Does this ring any bells?white-balloon-205
prehistoric-account-60014
02/06/2020, 2:29 PM