Skip to content

Commit f088b53

Browse files
committed
Fix support for multiurl CCDB backends
1 parent 9cda446 commit f088b53

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

CCDB/src/CcdbApi.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,8 +1363,15 @@ bool CcdbApi::isHostReachable() const
13631363
curl = curl_easy_init();
13641364
curl_easy_setopt(curl, CURLOPT_USERAGENT, mUniqueAgentID.c_str());
13651365
if (curl) {
1366+
// Each host in turn, not mUrl: mUrl holds whatever was passed to init(),
1367+
// which for a failover setup is the whole comma-separated list. curl
1368+
// rejects that as malformed (CURLE_URL_MALFORMAT), so every multi-host
1369+
// instance reported itself unreachable no matter how healthy its hosts
1370+
// were -- and testCcdbApiMultipleUrls, whose cases are gated on this,
1371+
// silently skipped instead of running.
13661372
for (size_t hostIndex = 0; hostIndex < hostsPool.size() && res != CURLE_OK; hostIndex++) {
1367-
curl_easy_setopt(curl, CURLOPT_URL, mUrl.data());
1373+
std::string url = getHostUrl(hostIndex);
1374+
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
13681375
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
13691376
curlSetSSLOptions(curl);
13701377
res = CURL_perform(curl);

CCDB/test/testCcdbApiMultipleUrls.cxx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "CCDB/CCDBTimeStampUtils.h"
1818
#include <boost/test/unit_test.hpp>
1919
#include <cstdio>
20+
#include <cstdlib>
2021
#include <TH1F.h>
2122

2223
using namespace std;
@@ -35,7 +36,13 @@ struct Fixture {
3536
Fixture()
3637
{
3738
CcdbApi api;
38-
ccdbUrl = "https://localhost:22,https://localhost:8080,http://ccdb-test.cern.ch:8080";
39+
// This suite uploads, so it needs a WRITABLE instance -- ccdb-test by
40+
// default, not the official CCDB. Only the LAST entry is configurable:
41+
// what is under test here is the failover, so the two dead endpoints in
42+
// front of it are part of the fixture and stay hardcoded.
43+
const char* host = std::getenv("ALICEO2_CCDB_HOST");
44+
ccdbUrl = "https://localhost:22,https://localhost:8080,";
45+
ccdbUrl += host ? host : "http://ccdb-test.cern.ch:8080";
3946
api.init(ccdbUrl);
4047
cout << "ccdb url: " << ccdbUrl << endl;
4148
hostReachable = api.isHostReachable();

0 commit comments

Comments
 (0)