[ 
https://issues.apache.org/jira/browse/CASSSIDECAR-340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18036416#comment-18036416
 ] 

Paulo Motta edited comment on CASSSIDECAR-340 at 11/7/25 10:13 PM:
-------------------------------------------------------------------

This [PR|https://github.com/apache/cassandra-sidecar/pull/277] adds an 
implementation of the {{LifecycleProvider}} interface that runs Cassandra as a 
local unix process, allowing sidecar to start and stop managed instances via 
the lifecycle APIs as native processes.

CircleCI tests: 
[link|https://app.circleci.com/pipelines/circleci/KaZH6B8gKQFCZv6WTtM3yk/7N9zyX9UjY83jRQygcQ3Mf/15/workflows/9e3776a1-afba-4dba-9acc-54d968e7ca3a]

*Usage and Configuration*

The ProcessLifecycleProvider requires a Cassandra tarball distribution to be 
previously installed and configured in the host for each instance it manages. 
The provider has two sets of configurations: global settings and instance-level 
settings, defined in {{{}sidecar.yaml{}}}.

Global settings apply to every hosted instance and are defined in the 
{{lifecycle.provider.parameters}} section of {{{}sidecar.yaml{}}}. The 
following table describe the possible settings:
 * {*}state_dir{*}: The directory where sidecar keeps the state of its managed 
instances, like PID file and startup/shutdown logs.
 * {*}cassandra_home{*}: The default Cassandra install location used by 
instances managed by this sidecar. This setting can be overridable by specific 
instances in the instance-level settings.
 * {*}env.$VARIABLE{*}: Optional runtime environment variable supplied to 
instances managed by this sidecar during startup. Example: {{env.MAX_HEAP_SIZE: 
8G}}
 * {*}{{cassandra.$OPTION}}{*}: Optional JVM option supplied to instances 
managed by this sidecar during startup. Example: {{cassandra.ring_delay_ms: 
30000}}

Instance-level settings are defined in the 
{{cassandra_instances[].lifecycle_options}} section of {{sidecar.yaml}} and 
apply only to a specific instance. The available instance-level settings are:
 * {*}cassandra_conf_dir{*}: The $CASSANDRA_CONF directory where cassandra 
configuration files for this instance are stored. This directory is not managed 
by sidecar, so it has to be previously configured for that particular instance.
 * {*}cassandra_home{*}: Optionally override the global Cassandra install 
location for this instance.
 * {*}cassandra_log_dir{*}: Optionally override the Cassandra log directory to 
this location.

This provider is disabled by default and can be enabled via 
{{lifecycle.enabled}} option set to true and {{lifecycle.provider.class_name}} 
set to {{{}org.apache.cassandra.sidecar.lifecycle.ProcessLifecycleProvider{}}}. 
A disabled example is provided the default {{{}cassandra.yaml{}}}.

*Example Configuration*
{code:yaml}
cassandra_instances:   
  - id: 1
    host: localhost1
    port: 9042
    [...]
    lifecycle_options:
       cassandra_conf_dir: /etc/cassandra
       cassandra_log_dir: /var/log/cassandra
[...]
lifecycle:   
  enabled: true
  provider:     
    class_name: org.apache.cassandra.sidecar.lifecycle.ProcessLifecycleProvider
    parameters:       state_dir: /var/lib/cassandra-sidecar/lifecycle
      cassandra_home: /opt/cassandra
      cassandra.ring_delay_ms: 30000
      env.MAX_HEAP_SIZE: 8G
      env.HEAP_NEWSIZE: 8G
{code}
*How it works?*

The provider start method invokes the Cassandra executable 
({{{}$CASSANDRA_HOME/bin/cassandra{}}}) with the environment configured from 
{{sidecar.yaml}} settings and writes the process ID to a PID file in the 
lifecycle state directory (ie. {{{}$state_dir/cassandra-$hostname.pid{}}}). 
Startup logs are logged to {{$state_dir/cassandra-$hostname.out}} and startup 
errors logged to {{{}$state_dir/cassandra-$hostname.err{}}}. The start method 
is synchronous and will wait until the process is running, but not necessarily 
until the Cassandra process is ready (ie. CQL is up and running).

An instance is considered to be running while a PID file exists for that 
instance in the lifecycle state directory and a process with that PID is 
currently running.

The stop method stops the process via SIGKILL which will trigger an orderly 
shutdown of Cassandra. This method is synchronous, blocking until the Cassandra 
process for the instance is no longer running.

Any unexpected startup or shutdown errors are propagated to the upstream 
{{LifecycleManager}} as runtime exceptions.


was (Author: paulo):
This [PR|https://github.com/apache/cassandra-sidecar/pull/277] adds an 
implementation of the {{LifecycleProvider}} interface that runs Cassandra as a 
local unix process, allowing sidecar to start and stop managed instances via 
the lifecycle APIs as native processes.

CircleCI tests: 
[link|https://app.circleci.com/pipelines/circleci/KaZH6B8gKQFCZv6WTtM3yk/7N9zyX9UjY83jRQygcQ3Mf/15/workflows/9e3776a1-afba-4dba-9acc-54d968e7ca3a]

*Usage and Configuration*

The ProcessLifecycleProvider requires a Cassandra tarball distribution to be 
previously installed and configured in the host for each instance it manages. 
The provider has two sets of configurations: global settings and instance-level 
settings, defined in {{{}sidecar.yaml{}}}.

Global settings apply to every hosted instance and are defined in the 
{{lifecycle.provider.parameters}} section of {{{}sidecar.yaml{}}}. The 
following table describe the possible settings:
 * {*}state_dir{*}: The directory where sidecar keeps the state of its managed 
instances, like PID file and startup/shutdown logs.
 * {*}cassandra_home{*}: The default Cassandra install location used by 
instances managed by this sidecar. This setting can be overridable by specific 
instances in the instance-level settings.
 * {*}env.$VARIABLE{*}: Optional runtime environment variable supplied to 
instances managed by this sidecar during startup. Example: {{env.MAX_HEAP_SIZE: 
8G}}
 * {*}{{cassandra.$OPTION}}{*}: Optional JVM option supplied to instances 
managed by this sidecar during startup. Example: {{cassandra.ring_delay_ms: 
30000}}

Instance-level settings are defined in the 
{{cassandra_instances[].lifecycle_options}} section of {{sidecar.yaml}} and 
apply only to a specific instance. The available instance-level settings are:
 * {*}cassandra_conf_dir{*}: The $CASSANDRA_CONF directory where cassandra 
configuration files for this instance are stored. This directory is not managed 
by sidecar, so it has to be previously configured for that particular instance.
 * {*}cassandra_home{*}: Optionally override the global Cassandra install 
location for this instance.
 * {*}cassandra_log_dir{*}: Optionally override the Cassandra log directory to 
this location.

This provider is disabled by default and can be enabled via 
{{lifecycle.enabled}} option set to true and {{lifecycle.provider.class_name}} 
set to {{{}org.apache.cassandra.sidecar.lifecycle.ProcessLifecycleProvider{}}}. 
A disabled example is provided the default {{{}cassandra.yaml{}}}.

*Example Configuration*
{code:yaml}
cassandra_instances:   - id: 1
    host: localhost1
    port: 9042
    [...]
    lifecycle_options:       cassandra_conf_dir: /etc/cassandra
      cassandra_log_dir: /var/log/cassandra
[...]
lifecycle:   enabled: true
  provider:     class_name: 
org.apache.cassandra.sidecar.lifecycle.ProcessLifecycleProvider
    parameters:       state_dir: /var/lib/cassandra-sidecar/lifecycle
      cassandra_home: /opt/cassandra
      cassandra.ring_delay_ms: 30000
      env.MAX_HEAP_SIZE: 8G
      env.HEAP_NEWSIZE: 8G
{code}
*How it works?*

The provider start method invokes the Cassandra executable 
({{{}$CASSANDRA_HOME/bin/cassandra{}}}) with the environment configured from 
{{sidecar.yaml}} settings and writes the process ID to a PID file in the 
lifecycle state directory (ie. {{{}$state_dir/cassandra-$hostname.pid{}}}). 
Startup logs are logged to {{$state_dir/cassandra-$hostname.out}} and startup 
errors logged to {{{}$state_dir/cassandra-$hostname.err{}}}. The start method 
is synchronous and will wait until the process is running, but not necessarily 
until the Cassandra process is ready (ie. CQL is up and running).

An instance is considered to be running while a PID file exists for that 
instance in the lifecycle state directory and a process with that PID is 
currently running.

The stop method stops the process via SIGKILL which will trigger an orderly 
shutdown of Cassandra. This method is synchronous, blocking until the Cassandra 
process for the instance is no longer running.

Any unexpected startup or shutdown errors are propagated to the upstream 
{{LifecycleManager}} as runtime exceptions.

> Add default process-based lifecycle provider to support the lifecycle API
> -------------------------------------------------------------------------
>
>                 Key: CASSSIDECAR-340
>                 URL: https://issues.apache.org/jira/browse/CASSSIDECAR-340
>             Project: Sidecar for Apache Cassandra
>          Issue Type: Sub-task
>          Components: Rest API
>            Reporter: Paulo Motta
>            Assignee: Paulo Motta
>            Priority: Normal
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> CASSSIDECAR-266 added APIs to control the lifecycle of locally managed 
> Cassandra instances. That API supports pluggable lifecycle provider to start 
> and stop Cassandra processes, allowing to potentially support different 
> runtimes.
> This ticket will add a default Unix process-based lifecycle provider 
> implementation to ship by default with sidecar. This provider will use 
> Cassandra scripts provided in the tarball distribution to start and stop the 
> Cassandra process.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to