Google Cloud Professional Cloud Developer — Question 240
You noticed that your application was forcefully shut down during a Deployment update in Google Kubernetes Engine. Your application didn’t close the database connection before it was terminated. You want to update your application to make sure that it completes a graceful shutdown. What should you do?
Answer options
- A. Update your code to process a received SIGTERM signal to gracefully disconnect from the database.
- B. Configure a PodDisruptionBudget to prevent the Pod from being forcefully shut down.
- C. Increase the terminationGracePeriodSeconds for your application.
- D. Configure a PreStop hook to shut down your application.
Correct answer: A
Explanation
The correct answer is A because handling a SIGTERM signal allows the application to execute cleanup processes, like closing database connections, before termination. Option B does not ensure graceful shutdown; it merely prevents forced shutdowns under certain circumstances. Option C increases the grace period but does not guarantee that the application will handle disconnections properly. Option D allows for a shutdown hook, but without handling SIGTERM directly in the application code, it may not address the database connection issue effectively.