Skip to content

Releases: joon6093/k8s-sigterm-handler

1.3.0

19 Dec 10:19
0ca0592
Compare
Choose a tag to compare

⭐ 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, with ContextRefreshedEvent 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.

❤️ Contributors

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기

1.2.2

01 Dec 10:29
f55f1c1
Compare
Choose a tag to compare

⭐ 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...'
      
  • 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.
      

🪲 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 the container.isRunning() method to ensure reliable waiting for container termination.

❤️ Contributors

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기

1.2.1

29 Nov 11:44
d96c899
Compare
Choose a tag to compare

⭐ New Features

  • Configuration Key Prefix Updated

    • The configuration key prefix has been updated from kubernetes.handler to kubernetes.sigterm-handler.
    • You can now manage handler-related settings using the new prefix in your configuration files.
  • 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

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기

1.2.0

28 Nov 05:24
04d20dd
Compare
Choose a tag to compare

⭐ 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.

❤️ Contributors

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기

1.1.0

26 Nov 08:05
d3c27e1
Compare
Choose a tag to compare

⭐ New Features

  • Improved Termination Handling as Recommended by Spring
    • Replaced System.exit() with SpringApplication.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.

🔍 Test Enhancements

  • Added Tests for Spring Lifecycle Callback Validation
    • Added tests to verify proper invocation of lifecycle callbacks, such as @PreDestroy, ContextClosedEvent, and JVM 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.

❤️ Contributors

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기

1.0.3

24 Nov 16:46
abbd94f
Compare
Choose a tag to compare

⭐ 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 the system-lambda library.

❤️ Contributors

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기

1.0.2

23 Nov 15:39
67ca896
Compare
Choose a tag to compare

🪲 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.
  • Replaced deprecated Testcontainers method

    • Updated SigtermListenerTest to use the non-deprecated getExitCodeLong method instead of the deprecated getExitCode method in Testcontainers.

❤️ Contributors

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기

1.0.1

23 Nov 15:11
a81b37e
Compare
Choose a tag to compare

🔍 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 the SIGTERM 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.

❤️ Contributors

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기

1.0.0

22 Nov 18:08
92fef5d
Compare
Choose a tag to compare

⭐ 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.
  • 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

  • @joon6093

    Thank you to all the contributors for this release!

한국어 버전은 다음 링크에서 확인할 수 있습니다: 한국어 릴리스 노트 보기