mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-31 20:16:43 +00:00
production_snitch_base: Fallback for empty DC or rack strings
Lubos Kosco points out that on Microsoft Azure, for example, it is possible for the "zone metadata" (which we use as rack information) can be empty as shown in: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service?tabs=windows#instance-metadata Therefore, protect against empty DC or rack strings in `production_snitch_base` to keep the behavior consistent across different snitches.
This commit is contained in:
@@ -123,11 +123,21 @@ sstring production_snitch_base::get_endpoint_info(inet_address endpoint, gms::ap
|
||||
}
|
||||
|
||||
void production_snitch_base::set_my_dc(const sstring& new_dc) {
|
||||
_my_dc = new_dc;
|
||||
if (!new_dc.empty()) {
|
||||
_my_dc = new_dc;
|
||||
} else {
|
||||
_my_dc = default_dc;
|
||||
logger().warn("{} snitch attempted to set DC to an empty string, falling back to {}.", get_name(), default_dc);
|
||||
}
|
||||
}
|
||||
|
||||
void production_snitch_base::set_my_rack(const sstring& new_rack) {
|
||||
_my_rack = new_rack;
|
||||
if (!new_rack.empty()) {
|
||||
_my_rack = new_rack;
|
||||
} else {
|
||||
_my_rack = default_rack;
|
||||
logger().warn("{} snitch attempted to set rack to an empty string, falling back to {}.", get_name(), default_rack);
|
||||
}
|
||||
}
|
||||
|
||||
void production_snitch_base::set_prefer_local(bool prefer_local) {
|
||||
|
||||
Reference in New Issue
Block a user