Fix some issues with the configuration update.
In analyzer_config_manager.cc, make the error message when config_parser
can't be spawned a little more helpful and fix the environment passed to
the spawned process. (used to be empty, now passes the report master's
environment.
In report_master_deployment, remove the double-quotes around the
report_master_config_repo_url argument. The double-quotes were confusing
the url parser in the config_parser git-handling code.
Fix a typo in a log message occuring near startup that was driving me
insane while debugging the above two problems.
Change-Id: I2d91bf69907a7aec59bae7f3ea2b3629a2baf7f4
diff --git a/analyzer/report_master/report_master_service.cc b/analyzer/report_master/report_master_service.cc
index 6259b2b..d0b6dcb 100644
--- a/analyzer/report_master/report_master_service.cc
+++ b/analyzer/report_master/report_master_service.cc
@@ -287,7 +287,7 @@
options.pem_key_cert_pairs.back().cert_chain = std::move(tls_server_cert);
server_credentials = grpc::SslServerCredentials(options);
} else {
- LOG(WARNING) << "Using insecure server credentials becuase -use_tls=false.";
+ LOG(WARNING) << "Using insecure server credentials because -use_tls=false.";
server_credentials = grpc::InsecureServerCredentials();
}
diff --git a/config/analyzer_config_manager.cc b/config/analyzer_config_manager.cc
index 06caf52..e76735a 100644
--- a/config/analyzer_config_manager.cc
+++ b/config/analyzer_config_manager.cc
@@ -8,6 +8,7 @@
#include <spawn.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <unistd.h>
#include <fstream>
#include <memory>
#include <mutex>
@@ -84,6 +85,7 @@
std::shared_ptr<AnalyzerConfigManager>(new AnalyzerConfigManager(
std::move(config), FLAGS_cobalt_config_proto_path,
FLAGS_config_update_repository_url, FLAGS_config_parser_bin_path));
+ manager->Update(120);
return manager;
}
@@ -95,23 +97,26 @@
LOG(INFO) << "Updating configuration from " << update_repository_path_;
+ std::string timeout_seconds_str = std::to_string(timeout_seconds);
const char* argv[] = {
- config_parser_bin_path_.c_str(), "-repo_url",
- update_repository_path_.c_str(), "-output_file",
- cobalt_config_proto_path_.c_str(), "-git_timeout",
- std::to_string(timeout_seconds).c_str(), nullptr,
+ config_parser_bin_path_.c_str(), "-repo_url",
+ update_repository_path_.c_str(), "-output_file",
+ cobalt_config_proto_path_.c_str(), "-git_timeout",
+ timeout_seconds_str.c_str(), nullptr,
};
- char* env[] = {};
pid_t pid;
posix_spawnattr_t spawnattr;
posix_spawnattr_init(&spawnattr);
+ errno = 0;
+ // The variable "environ" is the current environment found in unistd.h.
int status = posix_spawn(&pid, config_parser_bin_path_.c_str(), nullptr,
- &spawnattr, const_cast<char* const*>(argv), env);
+ &spawnattr, const_cast<char* const*>(argv), environ);
if (0 != status) {
LOG_STACKDRIVER_COUNT_METRIC(ERROR, kUpdateFailure)
- << "Error spawning config_parser at " << config_parser_bin_path_;
+ << "Error spawning config_parser at " << config_parser_bin_path_
+ << " with error: " << strerror(errno);
return false;
}
LOG(INFO) << "Spawned " << config_parser_bin_path_;
diff --git a/kubernetes/report_master/report_master_deployment.yaml b/kubernetes/report_master/report_master_deployment.yaml
index 440957c..5c23724 100644
--- a/kubernetes/report_master/report_master_deployment.yaml
+++ b/kubernetes/report_master/report_master_deployment.yaml
@@ -66,7 +66,7 @@
# copied in Dockerfile.
- '/usr/local/bin/config_parser'
- '-config_update_repository_url'
- - '"$$REPORT_MASTER_CONFIG_UPDATE_REPO_URL$$"'
+ - '$$REPORT_MASTER_CONFIG_UPDATE_REPO_URL$$'
- $$REPORT_MASTER_ENABLE_REPORT_SCHEDULING_FLAG$$
# This configures the AuthEnforcer.
- '-googlers_only'