Skip to content

Commit c6e2f62

Browse files
committed
WL#15166 patch #2 Ndbinfo certificates table
Implement ndb$certificates base table and certificates view. Update results for tests ndbinfo and ndbinfo plans. Change-Id: Iab1b89f5eb82ac1b3e0c049dd55eb7d07394070a
1 parent 434d861 commit c6e2f62

File tree

7 files changed

+60
-6
lines changed

7 files changed

+60
-6
lines changed

mysql-test/suite/ndb/r/ndbinfo.result

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ table_id table_name comment
9494
46 cpudata_50ms Data about CPU usage per 50ms last second
9595
47 cpudata_1sec Data about CPU usage per second last 20 seconds
9696
48 cpudata_20sec Data about CPU usage per 20 sec last 400 seconds
97+
49 certificates Certificates in current use for TLS connections
9798
SELECT COUNT(*) FROM ndb$tables;
9899
COUNT(*)
99-
49
100+
50
100101
SELECT * FROM ndb$tables WHERE table_id = 2;
101102
table_id table_name comment rows_estimate
102103
2 test for testing 8000
@@ -145,6 +146,7 @@ table_id table_name comment
145146
46 cpudata_50ms Data about CPU usage per 50ms last second
146147
47 cpudata_1sec Data about CPU usage per second last 20 seconds
147148
48 cpudata_20sec Data about CPU usage per 20 sec last 400 seconds
149+
49 certificates Certificates in current use for TLS connections
148150
SELECT * FROM ndb$tables WHERE table_name = 'LOGDESTINATION';
149151
table_id table_name comment rows_estimate
150152
SELECT COUNT(*) FROM ndb$tables t, ndb$columns c
@@ -165,6 +167,7 @@ table_id
165167
SELECT table_id, table_name FROM ndb$tables ORDER BY table_name;
166168
table_id table_name
167169
30 acc_operations
170+
49 certificates
168171
1 columns
169172
39 config_nodes
170173
23 config_values
@@ -297,6 +300,7 @@ table_id
297300
46
298301
47
299302
48
303+
49
300304

301305
TRUNCATE ndb$tables;
302306
ERROR HY000: Table 'ndb$tables' is read only

mysql-test/suite/ndb/r/ndbinfo_plans.result

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use ndbinfo;
55
##
66
## ndb$tables
77
select count(*) from ndb$tables;
8-
count(*) 49
8+
count(*) 50
99
explain select count(*) from ndb$tables;
1010
id 1
1111
select_type SIMPLE
@@ -62,7 +62,8 @@ index_columns 20 80
6262
ndb$acc_operations 15 64
6363
ndb$backup_id 1 20
6464
ndb$blocks 29 20
65-
ndb$columns 530 44
65+
ndb$certificates 34 44
66+
ndb$columns 535 44
6667
ndb$config_nodes 34 28
6768
ndb$config_params 167 120
6869
ndb$config_values 330 24
@@ -99,7 +100,7 @@ ndb$table_fragments 344 60
99100
ndb$table_fragments_all 344 60
100101
ndb$table_replicas 344 64
101102
ndb$table_replicas_all 344 64
102-
ndb$tables 49 40
103+
ndb$tables 50 40
103104
ndb$tc_time_track_stats 384 104
104105
ndb$test 8000 24
105106
ndb$threadblocks 124 16

storage/ndb/include/debugger/Ndbinfo.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class Ndbinfo {
9696
CPUDATA_TABLEID = 45,
9797
CPUDATA_50MS_TABLEID = 46,
9898
CPUDATA_1SEC_TABLEID = 47,
99-
CPUDATA_20SEC_TABLEID = 48
99+
CPUDATA_20SEC_TABLEID = 48,
100+
CERTIFICATES_TABLEID = 49
100101
};
101102

102103
enum BufferId {

storage/ndb/include/transporter/TransporterRegistry.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,9 @@ class TransporterRegistry
717717
Uint32 max_trp_ids);
718718

719719
Uint32 get_num_trps();
720+
TlsKeyManager * getTlsKeyManager() { return & m_tls_keys; }
721+
bool hasTlsCert() const { return (bool) m_tls_keys.ctx(); }
722+
720723
private:
721724
/**
722725
* Sum of max transporter memory for each transporter.

storage/ndb/plugin/ha_ndbinfo_sql.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ static struct view {
8686
{"ndbinfo", "blocks",
8787
"SELECT block_number, block_name "
8888
"FROM `ndbinfo`.`ndb$blocks`"},
89+
{"ndbinfo", "certificates",
90+
"SELECT distinct node_id as Node_id, name as Name, "
91+
"from_unixtime(expires, '%d-%b-%Y') as Expires, serial as Serial "
92+
"FROM `ndbinfo`.ndb$certificates"},
8993
{"ndbinfo", "cluster_locks",
9094
"SELECT "
9195
"`ndbinfo`.`ndb$acc_operations`.`node_id` AS `node_id`,"

storage/ndb/src/common/debugger/NdbinfoTables.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,19 @@ DECLARE_NDBINFO_TABLE(CPUDATA_20SEC, 10) =
12831283
}
12841284
};
12851285

1286+
DECLARE_NDBINFO_TABLE(CERTIFICATES, 5) =
1287+
{ { "certificates", 5, 0,
1288+
[] (const Ndbinfo::Counts &c) { return c.data_nodes * c.all_nodes; },
1289+
"Certificates in current use for TLS connections" },
1290+
{
1291+
{ "reporting_node_id", Ndbinfo::Number, "Reporting node" },
1292+
{ "node_id", Ndbinfo::Number, "Peer node" },
1293+
{ "name", Ndbinfo::String, "Certificate subject common name" },
1294+
{ "serial", Ndbinfo::String, "Certificate serial number" },
1295+
{ "expires", Ndbinfo::Number, "Certificate expiration date" }
1296+
}
1297+
};
1298+
12861299
#define DBINFOTBL(x) { Ndbinfo::x##_TABLEID, (const Ndbinfo::Table*)&ndbinfo_##x }
12871300

12881301
static
@@ -1340,7 +1353,8 @@ struct ndbinfo_table_list_entry {
13401353
DBINFOTBL(CPUDATA),
13411354
DBINFOTBL(CPUDATA_50MS),
13421355
DBINFOTBL(CPUDATA_1SEC),
1343-
DBINFOTBL(CPUDATA_20SEC)
1356+
DBINFOTBL(CPUDATA_20SEC),
1357+
DBINFOTBL(CERTIFICATES)
13441358
};
13451359

13461360
static int no_ndbinfo_tables =

storage/ndb/src/kernel/blocks/trpman.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,33 @@ Trpman::execDBINFO_SCANREQ(Signal *signal)
585585
break;
586586
}
587587

588+
case Ndbinfo::CERTIFICATES_TABLEID:
589+
{
590+
TlsKeyManager * keyMgr = globalTransporterRegistry.getTlsKeyManager();
591+
int peer_node_id = cursor->data[0];
592+
cert_table_entry entry;
593+
while(keyMgr->iterate_cert_table(peer_node_id, & entry)) {
594+
595+
jam();
596+
Ndbinfo::Row row(signal, req);
597+
598+
row.write_uint32(getOwnNodeId());
599+
row.write_uint32(peer_node_id);
600+
row.write_string(entry.name);
601+
row.write_string(entry.serial);
602+
row.write_uint32(entry.expires);
603+
604+
ndbinfo_send_row(signal, req, row, rl);
605+
606+
if (rl.need_break(req))
607+
{
608+
jam();
609+
ndbinfo_send_scan_break(signal, req, rl, peer_node_id);
610+
return;
611+
}
612+
}
613+
}
614+
588615
default:
589616
break;
590617
}

0 commit comments

Comments
 (0)