You have a Compute Engine managed instance group that adds and removes Compute Engine instances from the group in response to the load on your application. The instances have a shutdown script that removes REDIS database entries associated with the instance. You see that many database entries have not been removed, and you suspect that the shutdown script is the problem. You need to ensure that the commands in the shutdown script are run reliably every time an instance is shut down. You create a Cloud Function to remove the database entries. What should you do next?
Choose an answer
Tap an option to check your answer.
Correct answer: Set up a Cloud Monitoring sink that triggers the Cloud Function after an instance removal log message arrives in Cloud Logging..
Why this is the answer
The correct option is to set up a Cloud Monitoring sink that triggers the Cloud Function. This approach reliably executes the cleanup logic independently of the instance's shutdown process. When an instance is removed, a log entry is generated. A Cloud Monitoring sink can detect this specific log entry and trigger the Cloud Function, ensuring the database entries are removed even if the instance's shutdown script is interrupted or fails. The other options are less reliable: Modifying the shutdown script to wait or restart doesn't guarantee execution if the instance is terminated abruptly (e.g., due to preemption or a hard stop). Publishing to Pub/Sub from the shutdown script still relies on the script completing successfully before the instance is shut down.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed