Initial commit for new logging output #3150
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds an output to the Packer module that prints a custom gcloud logging command of the format
gcloud logging --project read 'logName=("projects//logs/GCEMetadataScripts" OR "projects//logs/google_metadata_script_runner") AND resource.labels.instance_id=<instance #>' --format="table(timestamp, resource.labels.instance_id, jsonPayload.message)" --order=asc
when Packer fails during the startup scripts. It also updates packer to create a instance name variable for the instance so that can be more easily tracked in the module. It varies from the command in the README in that it should not need the freshness option as it is specific to one instance. It also does not look for "^startup-script: " as that can be a bit too specific of a query.
This PR also updates the golden copies.
This was tested on a simple Packer blueprint that introduced an script that only ran exit 1 and cause the Packer module to end with an error. It was also tested with a clean build to confirm no new issues were introduced.