Releases: joon6093/k8s-sigterm-handler
1.3.0
⭐ New Features
-
POSIX Standard Exit Code Validation Added
- Introduced functionality to validate and set exit codes within the range of 0 to 255, as specified by the POSIX standard.
- Docker container exit codes also adhere to the POSIX standard, requiring values between 0-255. If an out-of-range value is provided, it will wrap around into the valid range (e.g., 256 becomes 0, 257 becomes 1).
- An exception message is displayed when an invalid exit code is input, indicating that the value exceeds the permissible range.
-
Handler Initialization Using Spring Application Context Events
- Replaced the use of
@PostConstruct
, which had limitations in defining a clear execution point, withContextRefreshedEvent
from Spring Application Context Events. - This improvement ensures that the handler initialization logic executes reliably at the exact point when the application context is fully refreshed and initialized.
- Replaced the use of
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기
1.2.2
⭐ New Features
-
Added Library Initialization Log Message Feature
- During library initialization, logs now display the configured exit code, termination message path, and termination message to help verify the configuration.
2024-11-30T08:10:12.628+09:00 INFO 35700 --- [ main] i.j.handler.SigtermHandlerConfiguration : Sigterm handler initialized with exitCode: 0, terminationMessagePath: /dev/termination-log, terminationMessage: 'SIGTERM signal received...'
- During library initialization, logs now display the configured exit code, termination message path, and termination message to help verify the configuration.
-
Added SIGTERM Signal Log Message Feature
- When the application receives a SIGTERM signal, it logs a message while the termination handler is triggered. This provides clear visibility into the shutdown process.
2024-11-30T08:10:17.677+09:00 INFO 35700 --- [ SIGTERM handler] i.jeyong.handler.ApplicationTerminator : Received SIGTERM signal. Initiating termination handler.
- When the application receives a SIGTERM signal, it logs a message while the termination handler is triggered. This provides clear visibility into the shutdown process.
🪲 Bug Fixes
- Fixed Test Container Shutdown Timing Issue
- Addressed an issue where tests were verifying values before the container had fully shut down. Adjusted the logic to check the container's shutdown state before running assertions.
- Replaced
Thread.sleep
with thecontainer.isRunning()
method to ensure reliable waiting for container termination.
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기
1.2.1
⭐ New Features
-
Configuration Key Prefix Updated
- The configuration key prefix has been updated from
kubernetes.handler
tokubernetes.sigterm-handler
. - You can now manage handler-related settings using the new prefix in your configuration files.
- The configuration key prefix has been updated from
-
Termination Message Logging Feature Added
- Implemented functionality to log a termination message to a specified path when the application receives a SIGTERM signal.
- This allows Kubernetes environments to record and analyze the Pod's termination state and reason after receiving a SIGTERM signal.
- Termination messages can be configured with the following settings:
kubernetes: sigterm-handler: enabled: true # Enable or disable the handler (default: true) exit-code: 0 # Exit code to use upon termination (default: 0) termination-message-path: /dev/termination-log # Path to log the termination message (default: not set) termination-message: SIGTERM signal received... # Content of the termination message (default: SIGTERM signal received. Application has been terminated successfully.)
- After the application terminates, you can view the Pod's termination message using commands like
kubectl get pod
. Below is an example of the termination message:state: terminated: containerID: containerd://7935f0bcfd27b2d01f900029746261e0cdad8bcdbd5a7 exitCode: 0 finishedAt: "2024-11-29T20:22:26Z" message: SIGTERM signal received. Application has been terminated successfully. reason: Completed startedAt: "2024-11-29T20:20:42Z"
- Note: The default value for
terminationMessagePath
in Kubernetes is/dev/termination-log
. You can customize this path to log the termination message to a desired file location.
🔍 Test Enhancements
- Tests for Termination Message Path and Content Validation Added
- Added tests to verify that the correct termination message is logged to the specified path when the application terminates.
- These tests read and validate the content of the termination message file from within the container.
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기
1.2.0
⭐ New Features
- Added handler activation and exit code configuration
- Users can configure the activation status of the handler and set a custom exit code.
- The handler can be controlled using the following configuration:
kubernetes: handler: enabled: true # Set whether the handler is enabled or disabled (default: true). exit-code: 0 # Set the exit code for graceful application termination (default: 0).
🔍 Test Enhancements
- Added tests for handler activation and deactivation
- Added a test to verify that
SigtermHandlerConfiguration
is properly registered in the Spring context and the exit code is set when the handler is activated. - Added a test to ensure that
SigtermHandlerConfiguration
is not registered in the Spring context when the handler is deactivated.
- Added a test to verify that
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기
1.1.0
⭐ New Features
- Improved Termination Handling as Recommended by Spring
- Replaced
System.exit()
withSpringApplication.exit()
for processing exit codes. - This ensures proper resource cleanup and invocation of lifecycle callbacks by integrating with Spring's lifecycle management during application shutdown.
- Replaced
🔍 Test Enhancements
- Added Tests for Spring Lifecycle Callback Validation
- Added tests to verify proper invocation of lifecycle callbacks, such as
@PreDestroy
,ContextClosedEvent
, andJVM Shutdown Hook
, during application shutdown. - Attempted to share containers across tests for faster test execution but faced instability due to Testcontainers #6420. Resolved this by sharing Docker images between tests, creating a more stable and efficient test environment.
- Added tests to verify proper invocation of lifecycle callbacks, such as
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기
1.0.3
⭐ New Features
- Decoupled Termination Signal Handling Responsibility
- Separated the termination signal handling responsibility into modular components, enhancing maintainability and readability.
- Introduced a flexible structure for defining termination behaviors, enabling adaptability to various termination scenarios.
🔍 Test Enhancements
-
Termination Signal Handler Registration Test
- Added a test to verify that the termination signal handler is correctly registered for the specified signal type.
-
Termination Behavior and Exit Code Test
- Added a test to verify that the termination handler performs the expected termination behavior with the correct exit code.
- Addressed the challenge of testing
System.exit()
calls by leveraging thesystem-lambda
library.
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기
1.0.2
🪲 Bug Fixes
-
Fixed build failure due to test execution in JitPack deployment
- Resolved the build failure during JitPack deployment by modifying the
jitpack.yml
file to skip test execution in the deployment process.
- Resolved the build failure during JitPack deployment by modifying the
-
Replaced deprecated Testcontainers method
- Updated
SigtermListenerTest
to use the non-deprecatedgetExitCodeLong
method instead of the deprecatedgetExitCode
method in Testcontainers.
- Updated
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기
1.0.1
🔍 Test Enhancements
- Added Sigterm Exit Code Verification Test
- Added a test to verify that the application exits with a normal exit code
0
after receiving theSIGTERM
signal, using a Docker container-based simulation. - Verifying exit codes involves testing the application shutdown process, which can be challenging in typical test environments. To address this,
testcontainers
was utilized to simulate the actual shutdown behavior within a Docker container and validate the result.
- Added a test to verify that the application exits with a normal exit code
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기
1.0.0
⭐ New Features
-
Handle SIGTERM signal during Kubernetes Pod termination
- Implemented handling of the
SIGTERM
signal sent during application termination in Kubernetes. - Ensures that the application exits with code
0
, preventing the termination status from being marked as "Error" and avoiding unnecessary alarms.
- Implemented handling of the
-
Support for Spring Auto Configuration
- Configured automatic registration of the required Bean during Spring application startup.
- Users no longer need to manually register Beans, making it easy to handle
SIGTERM
signals in Kubernetes environments with minimal setup.
❤️ Contributors
-
Thank you to all the contributors for this release!
한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기