
Answer-first summary for fast verification
Answer: Set up a Cloud Monitoring sink that triggers the Cloud Function after an instance removal log message arrives in Cloud Logging.
The correct answer is C: Set up a Cloud Monitoring sink that triggers the Cloud Function after an instance removal log message arrives in Cloud Logging. This method ensures that the Cloud Function is triggered reliably when an instance is shut down. Relying on the shutdown script alone is not recommended because shutdown scripts are executed on a best-effort basis in Compute Engine, which cannot guarantee that they will complete. By setting up a Cloud Monitoring sink to trigger the Cloud Function upon the instance removal log message, you eliminate the dependency on the successful execution of the shutdown script, ensuring that your database clean-up tasks are performed consistently.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
You have a Compute Engine managed instance group that dynamically scales by adding and removing Compute Engine instances based on the load on your application. Each instance in this group runs a shutdown script intended to clean up by removing REDIS database entries associated with that instance when it is terminated. However, you've noticed that many of these database entries remain uncleared, suggesting that the shutdown script isn't reliably executing. To address this, you decide to use a Cloud Function to handle the removal of the database entries. What should you do next to ensure that the database clean-up is performed reliably every time an instance is shut down?
A
Modify the shutdown script to wait for 30 seconds before triggering the Cloud Function.
B
Do not use the Cloud Function. Modify the shutdown script to restart if it has not completed in 30 seconds.
C
Set up a Cloud Monitoring sink that triggers the Cloud Function after an instance removal log message arrives in Cloud Logging.
D
Modify the shutdown script to wait for 30 seconds and then publish a message to a Pub/Sub queue.