Skip to content

Commit

Permalink
Fixed a bug in the result file URL generator
Browse files Browse the repository at this point in the history
Using worker's "vnid" (virtual netvork identifier) instead of
the worker's host name for the XROOT protocol option. Using FQND
of the worker's host name for the HTTP protocol option. The changes
allow running the application in the Kubernetes environment.
  • Loading branch information
iagaponenko committed Sep 14, 2023
1 parent 110f6ee commit ba520b1
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/wbase/Task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

// Third-party headers
#include <boost/algorithm/string/replace.hpp>
#include "boost/asio.hpp"
#include "boost/filesystem.hpp"

// LSST headers
Expand All @@ -51,6 +50,7 @@
#include "proto/TaskMsgDigest.h"
#include "proto/worker.pb.h"
#include "util/Bug.h"
#include "util/common.h"
#include "util/HoldTrack.h"
#include "util/IterableFormatter.h"
#include "util/TimeUtils.h"
Expand All @@ -69,18 +69,6 @@ namespace {

LOG_LOGGER _log = LOG_GET("lsst.qserv.wbase.Task");

string get_hostname() {
// Get the short name of the current host.
boost::system::error_code ec;
string const hostname = boost::asio::ip::host_name(ec);
if (ec.value() != 0) {
throw runtime_error("Task::" + string(__func__) +
" boost::asio::ip::host_name failed: " + ec.category().name() + string(":") +
to_string(ec.value()) + "[" + ec.message() + "]");
}
return hostname;
}

string buildResultFilePath(shared_ptr<lsst::qserv::proto::TaskMsg> const& taskMsg,
string const& resultsDirname) {
if (resultsDirname.empty()) return resultsDirname;
Expand Down Expand Up @@ -155,14 +143,14 @@ Task::Task(TaskMsgPtr const& t, int fragmentNumber, std::shared_ptr<UserQueryInf
auto const resultDeliveryProtocol = workerConfig->resultDeliveryProtocol();
if (resultDeliveryProtocol != wconfig::WorkerConfig::ResultDeliveryProtocol::SSI) {
_resultFilePath = ::buildResultFilePath(t, workerConfig->resultsDirname());
auto const fqdn = util::get_current_host_fqdn();
if (resultDeliveryProtocol == wconfig::WorkerConfig::ResultDeliveryProtocol::XROOT) {
// NOTE: one extra '/' after the <server>[:<port>] spec is required to make
// NOTE: one extra '/' after the <host>[:<port>] spec is required to make
// a "valid" XROOTD url.
_resultFileXrootUrl = "xroot://" + ::get_hostname() + ":" +
to_string(workerConfig->resultsXrootdPort()) + "/" + _resultFilePath;
_resultFileXrootUrl = "xroot://" + fqdn + ":" + to_string(workerConfig->resultsXrootdPort()) +
"/" + _resultFilePath;
} else if (resultDeliveryProtocol == wconfig::WorkerConfig::ResultDeliveryProtocol::HTTP) {
_resultFileHttpUrl =
"http://" + ::get_hostname() + ":" + to_string(resultsHttpPort) + _resultFilePath;
_resultFileHttpUrl = "http://" + fqdn + ":" + to_string(resultsHttpPort) + _resultFilePath;
} else {
throw std::runtime_error("wbase::Task::Task: unsupported results delivery protocol: " +
wconfig::WorkerConfig::protocol2str(resultDeliveryProtocol));
Expand Down

0 comments on commit ba520b1

Please sign in to comment.