Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 1, 2025

When creating a cluster with --install-dir=path/to/build/dev, the build mode was extracted but not persisted. Nodes added later via ccm add defaulted to release mode instead of the original dev mode.

# Create cluster with dev build
./ccm create t1 --scylla --vnodes -n 1 --install-dir=`pwd`/../scylla/build/dev

# Later, added nodes would incorrectly use release build
ccm add node2 --scylla

Changes

  • ccmlib/scylla_cluster.py: Save scylla_mode to cluster.conf in _update_config()
  • ccmlib/cluster_factory.py: Restore scylla_mode when loading cluster via ClusterFactory.load()
  • tests/test_common.py: Add unit test for scylla_mode persistence

Fixes #164

Original prompt

This section details on the original issue you should resolve

<issue_title>add command forgets which build mode we use</issue_title>
<issue_description>If I use

./ccm create t1 --scylla --vnodes -n 1 --install-dir=`pwd`/../scylla/build/dev

then nodes will be created using dev mode builds. However, further nodes lauched via ccm add / ccm start will launch from the release build. This can be quite confusing.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix ccm add command to remember build mode Fix: Persist scylla_mode to cluster.conf for ccm add to remember build mode Dec 1, 2025
Copilot AI requested a review from fruch December 1, 2025 21:51
@fruch fruch requested a review from Copilot December 2, 2025 06:16
@fruch fruch marked this pull request as ready for review December 2, 2025 06:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes issue #164 where the ccm add command would incorrectly use the release build mode instead of the original build mode (e.g., dev or debug) specified during cluster creation. The root cause is that when a cluster is created with --install-dir=/path/to/scylla/build/dev, the install directory is normalized to /path/to/scylla and the build mode information is lost when the cluster is reloaded.

Key Changes

  • Persists the scylla_mode field to cluster.conf in ScyllaCluster._update_config()
  • Restores scylla_mode when loading clusters via ClusterFactory.load()
  • Adds a unit test to verify YAML serialization/deserialization of scylla_mode

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ccmlib/scylla_cluster.py Saves scylla_mode to cluster.conf following the same pattern as scylla_version
ccmlib/cluster_factory.py Restores scylla_mode attribute after loading ScyllaCluster instances
tests/test_common.py Adds unit test for YAML persistence of scylla_mode field

Comment on lines +102 to +153
def test_scylla_mode_persistence():
"""Test that scylla_mode is properly saved to and loaded from cluster.conf.
This test verifies the fix for issue #164 where `ccm add` command would forget
which build mode was used during cluster creation (e.g., dev vs release).
"""
with tempfile.TemporaryDirectory() as tmpdir:
# Create a mock cluster.conf file with scylla_mode
cluster_conf = os.path.join(tmpdir, 'cluster.conf')
config_data = {
'name': 'test_cluster',
'nodes': ['node1'],
'seeds': ['node1'],
'partitioner': None,
'install_dir': '/path/to/scylla',
'config_options': {},
'log_level': 'INFO',
'use_vnodes': False,
'id': 0,
'ipprefix': None,
'scylla_mode': 'dev', # This is what we're testing
}

with open(cluster_conf, 'w') as f:
YAML().dump(config_data, f)

# Read back and verify scylla_mode is preserved
with open(cluster_conf, 'r') as f:
loaded_data = YAML().load(f)

assert 'scylla_mode' in loaded_data
assert loaded_data['scylla_mode'] == 'dev'

# Also test with 'debug' mode
config_data['scylla_mode'] = 'debug'
with open(cluster_conf, 'w') as f:
YAML().dump(config_data, f)

with open(cluster_conf, 'r') as f:
loaded_data = YAML().load(f)

assert loaded_data['scylla_mode'] == 'debug'

# Test with 'release' mode
config_data['scylla_mode'] = 'release'
with open(cluster_conf, 'w') as f:
YAML().dump(config_data, f)

with open(cluster_conf, 'r') as f:
loaded_data = YAML().load(f)

assert loaded_data['scylla_mode'] == 'release'
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test only verifies that YAML can serialize/deserialize the scylla_mode field, but doesn't test the actual issue reported in #164. The test should verify:

  1. That ScyllaCluster._update_config() actually saves scylla_mode to cluster.conf
  2. That ClusterFactory.load() correctly restores the scylla_mode when loading the cluster
  3. That when a new node is added to the cluster (the actual use case from add command forgets which build mode we use #164), it uses the correct build mode

Consider adding an integration test that:

  • Creates a ScyllaCluster instance with a specific scylla_mode (e.g., 'dev')
  • Calls _update_config() to persist it
  • Uses ClusterFactory.load() to reload the cluster
  • Verifies that the loaded cluster has the correct scylla_mode set

Copilot uses AI. Check for mistakes.
@fruch
Copy link
Contributor

fruch commented Dec 2, 2025

I've tried to compile scylla and try it out, but with zero luck (it's OOMing on linking)
@avikivity as the reporter of the issue, care to try it out ?

…ild mode

When creating a cluster with `--install-dir=path/to/build/dev`, the build
mode (dev/debug/release) was being extracted but not saved to cluster.conf.
This caused nodes added later via `ccm add` to use the wrong build mode
(defaulting to release).

This fix:
1. Saves `scylla_mode` to cluster.conf in ScyllaCluster._update_config()
2. Restores `scylla_mode` from cluster.conf in ClusterFactory.load()
3. Adds a unit test to verify scylla_mode persistence

Fixes #164

Co-authored-by: fruch <[email protected]>
@fruch fruch force-pushed the copilot/fix-ccm-add-build-mode branch from 98986ce to c65e0d5 Compare December 25, 2025 12:52
@avikivity
Copy link
Member

I'm not able to test:

$ ./ccm start
Error starting node node1: unable to connect to scylla-jmx port 127.0.0.1:7199

There's no jmx, so I don't see why it tries to connect.

@fruch
Copy link
Contributor

fruch commented Dec 28, 2025

I'm not able to test:

$ ./ccm start
Error starting node node1: unable to connect to scylla-jmx port 127.0.0.1:7199

There's no jmx, so I don't see why it tries to connect.

./ccm node1 showlog ?

@avikivity
Copy link
Member

I'm not able to test:

$ ./ccm start
Error starting node node1: unable to connect to scylla-jmx port 127.0.0.1:7199

There's no jmx, so I don't see why it tries to connect.

./ccm node1 showlog ?

$ ./ccm node1 showlog
Traceback (most recent call last):
  File "/home/avi/scylla-ccm/./ccm", line 6, in <module>
    main()
    ~~~~^^
  File "/home/avi/scylla-ccm/ccmlib/bin/__init__.py", line 75, in main
    cmd.run()
    ~~~~~~~^^
  File "/home/avi/scylla-ccm/ccmlib/cmds/node_cmds.py", line 105, in run
    os.execvp(pager, (pager, log))
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "<frozen os>", line 604, in execvp
  File "<frozen os>", line 646, in _execvpe
  File "<frozen os>", line 637, in _execvpe
FileNotFoundError: [Errno 2] No such file or director

Guessing the problem is that I do have a tools/jmx directory. Need to improve detection.

@avikivity
Copy link
Member

I reproduced the original complaint, and confirm that it is solved with the patch.

@fruch
Copy link
Contributor

fruch commented Dec 28, 2025

I reproduced the original complaint, and confirm that it is solved with the patch.

at least that something,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add command forgets which build mode we use

3 participants