Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature](cloud) Add priority network support for meta-service registry #33931

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

gavinchou
Copy link
Collaborator

@gavinchou gavinchou commented Apr 20, 2024

Meta-service registry IP may be 127.0.0.1 without priority network support. It will be a problem for syncing if there are multiple meta-service.
This PR introduces CIDR-based filter to select a true IP for meta-service when registering itself.

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@gavinchou
Copy link
Collaborator Author

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

// specific language governing permissions and limitations
// under the License.

#include "common/network_util.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'common/network_util.h' file not found [clang-diagnostic-error]

#include "common/network_util.h"
         ^

if (errno != 0 && mask_length == 0) {
char errmsg[64];
// Ignore unused return value
auto ret = strerror_r(errno, errmsg, 64);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'auto ret' can be declared as 'auto *ret' [readability-qualified-auto]

Suggested change
auto ret = strerror_r(errno, errmsg, 64);
auto *ret = strerror_r(errno, errmsg, 64);

netmask_ = netmask_ << (32 - mask_length);
return true;
}
bool contains(const std::string& ip) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'contains' can be made const [readability-make-member-function-const]

Suggested change
bool contains(const std::string& ip) {
bool contains(const std::string& ip) const {

return true;
}

uint32_t address_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use default member initializer for 'address_' [modernize-use-default-member-init]

cloud/src/common/network_util.cpp:37:

-     CIDR() : address_(0), netmask_(0xffffffff) {}
+     CIDR() : , netmask_(0xffffffff) {}
Suggested change
uint32_t address_;
uint32_t address_{0};

}

uint32_t address_;
uint32_t netmask_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: use default member initializer for 'netmask_' [modernize-use-default-member-init]

cloud/src/common/network_util.cpp:37:

-     CIDR() : address_(0), netmask_(0xffffffff) {}
+     CIDR() : address_(0), {}
Suggested change
uint32_t netmask_;
uint32_t netmask_{0xffffffff};

// specific language governing permissions and limitations
// under the License.

#include "common/network_util.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'common/network_util.h' file not found [clang-diagnostic-error]

#include "common/network_util.h"
         ^

@gavinchou gavinchou force-pushed the gavin-cloud-priority-network branch from f540e31 to 1ffb18a Compare April 20, 2024 17:45
@gavinchou
Copy link
Collaborator Author

run buildall

Copy link
Contributor

@dataroaring dataroaring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Apr 21, 2024
Copy link
Contributor

PR approved by anyone and no changes requested.

} else if (!priority_cidrs.empty()) {
if (is_in_prior_network(addr_it->get_host_address_v4())) {
localhost_str = addr_it->get_host_address_v4();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment on lines +207 to +208
} else if (!priority_cidrs.empty()) {
if (is_in_prior_network(addr_it->get_host_address_v4())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else if (!priority_cidrs.empty()) {
if (is_in_prior_network(addr_it->get_host_address_v4())) {
} else if (!priority_cidrs.empty() && is_in_prior_network(addr_it->get_host_address_v4())) {

@dataroaring dataroaring merged commit 4b3d27d into apache:master Apr 22, 2024
29 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. dev/3.0.0-merged reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants