Skip to content

Commit

Permalink
feat(agent): fill consistent_cluster_management in NodeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal-Leszczynski committed Feb 22, 2024
1 parent b344c8e commit c69be7a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
13 changes: 13 additions & 0 deletions pkg/scyllaclient/config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ func (c *ConfigClient) UUIDSStableIdentifiers(ctx context.Context) (bool, error)
return resp.Payload, err
}

// ConsistentClusterManagement returns true if node uses RAFT for cluster management and DDL.
func (c *ConfigClient) ConsistentClusterManagement(ctx context.Context) (bool, error) {
resp, err := c.client.Config.FindConfigConsistentClusterManagement(config.NewFindConfigConsistentClusterManagementParamsWithContext(ctx))
if isStatusCode400(err) {
return false, nil
}
if err != nil {
return false, err
}
return resp.Payload, err
}

// AlternatorEnforceAuthorization returns whether alternator requires authorization.
func (c *ConfigClient) AlternatorEnforceAuthorization(ctx context.Context) (bool, error) {
resp, err := c.client.Config.FindConfigAlternatorEnforceAuthorization(config.NewFindConfigAlternatorEnforceAuthorizationParamsWithContext(ctx))
Expand Down Expand Up @@ -278,6 +290,7 @@ func (c *ConfigClient) NodeInfo(ctx context.Context) (*NodeInfo, error) {
{Field: &ni.CqlPasswordProtected, Fetcher: c.CQLPasswordProtectionEnabled},
{Field: &ni.AlternatorEnforceAuthorization, Fetcher: c.AlternatorEnforceAuthorization},
{Field: &ni.SstableUUIDFormat, Fetcher: c.UUIDSStableIdentifiers},
{Field: &ni.ConsistentClusterManagement, Fetcher: c.ConsistentClusterManagement},
}

for i, ff := range ffb {
Expand Down
12 changes: 11 additions & 1 deletion pkg/scyllaclient/config_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestClientConfigReturnsResponseFromScylla(t *testing.T) {
Name: "Alternator requires authorization",
ResponseFilePath: "testdata/scylla_api/v2_config_alternator_enforce_authorization.json",
BindClientFunc: func(client *scyllaclient.ConfigClient) configClientFunc {
return convertBool(client.UUIDSStableIdentifiers)
return convertBool(client.AlternatorEnforceAuthorization)
},
Golden: true,
},
Expand All @@ -132,6 +132,14 @@ func TestClientConfigReturnsResponseFromScylla(t *testing.T) {
},
Golden: true,
},
{
Name: "Raft schema enabled",
ResponseFilePath: "testdata/scylla_api/v2_config_consistent_cluster_management.json",
BindClientFunc: func(client *scyllaclient.ConfigClient) configClientFunc {
return convertBool(client.ConsistentClusterManagement)
},
Golden: true,
},
}

for i := range table {
Expand Down Expand Up @@ -174,6 +182,7 @@ func TestConfigClientPullsNodeInformationUsingScyllaAPI(t *testing.T) {
scyllaclienttest.PathFileMatcher("/v2/config/alternator_address", "testdata/scylla_api/v2_config_alternator_address.json"),
scyllaclienttest.PathFileMatcher("/v2/config/alternator_enforce_authorization", "testdata/scylla_api/v2_config_alternator_enforce_authorization.json"),
scyllaclienttest.PathFileMatcher("/v2/config/uuid_sstable_identifiers_enabled", "testdata/scylla_api/v2_config_uuid_sstable_identifiers_enabled.json"),
scyllaclienttest.PathFileMatcher("/v2/config/consistent_cluster_management", "testdata/scylla_api/v2_config_consistent_cluster_management.json"),
),
)
defer closeServer()
Expand Down Expand Up @@ -222,6 +231,7 @@ func TestConfigOptionIsNotSupported(t *testing.T) {
scyllaclienttest.PathFileMatcher("/v2/config/alternator_address", "testdata/scylla_api/v2_config_alternator_disabled.400.json"),
scyllaclienttest.PathFileMatcher("/v2/config/alternator_enforce_authorization", "testdata/scylla_api/v2_config_alternator_disabled.400.json"),
scyllaclienttest.PathFileMatcher("/v2/config/uuid_sstable_identifiers_enabled", "testdata/scylla_api/v2_config_uuid_sstable_identifiers_enabled.400.json"),
scyllaclienttest.PathFileMatcher("/v2/config/consistent_cluster_management", "testdata/scylla_api/v2_config_consistent_cluster_management.400.json"),
),
)
defer closeServer()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"message": "No such config entry: consistent_cluster_management", "code": 400}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"prometheus_port":"9180",
"rpc_address":"192.168.100.101",
"rpc_port":"9160",
"sstable_uuid_format":true
"sstable_uuid_format":true,
"consistent_cluster_management":true
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"prometheus_port":"9180",
"rpc_address":"192.168.100.101",
"rpc_port":"9160",
"sstable_uuid_format":false
"sstable_uuid_format":false,
"consistent_cluster_management":false
}

0 comments on commit c69be7a

Please sign in to comment.