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

[#879][#925] Docker network Pool overlaps with other one on this address space #1211

Merged
merged 5 commits into from
Dec 21, 2023

Conversation

xunliu
Copy link
Member

@xunliu xunliu commented Dec 19, 2023

What changes were proposed in this pull request?

  1. Added Docker network overlap detection
  2. Reduced IP allocation ranges for lower conflict probability, Modified to 10.20.30.0/28 only allocate IP ranger 10.20.30.1 ~ 10.20.30.14
  3. Docker network only created on MacOS and default Docker server environment

Why are the changes needed?

Fix: #879, #925

Does this PR introduce any user-facing change?

N/A

How was this patch tested?

CI

@xunliu xunliu self-assigned this Dec 19, 2023
@@ -140,6 +181,62 @@ private static Network createDockerNetwork() {
.build());
}

public static boolean ipRangesOverlap(String cidr1, String cidr2) throws Exception {
long[] net1 = cidrToRange(cidr1);
Copy link
Contributor

Choose a reason for hiding this comment

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

What the meaning of cidr?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, can you include the link in the Java doc, others may also be confused by it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the comment about CIDR in the codes.
Another, This is only Integration Test, I think not need write in the Java doc.

Copy link
Contributor

Choose a reason for hiding this comment

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

I added the comment about CIDR in the codes.

That's exactly what I mean here.

@qqqttt123
Copy link
Contributor

Do we need backport this pr to branch 0.3?

@xunliu xunliu added need backport Issues that need to backport to another branch branch-0.3 labels Dec 20, 2023
@xunliu
Copy link
Member Author

xunliu commented Dec 20, 2023

Do we need backport this pr to branch 0.3?

Yes, I think need.

@yuqi1129
Copy link
Contributor

I'm OK with this PR except comment here https://github.com/datastrato/gravitino/pull/1211/files#r1432213859

yuqi1129
yuqi1129 previously approved these changes Dec 21, 2023
Copy link
Contributor

@yuqi1129 yuqi1129 left a comment

Choose a reason for hiding this comment

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

LGTM

@xunliu
Copy link
Member Author

xunliu commented Dec 21, 2023

@jerryshao Please help me review this PR, Thanks.

@@ -189,7 +189,7 @@ public SELF withEnvVars(Map<String, String> envVars) {
}

public SELF withNetwork(Network network) {
this.network = Optional.of(network);
this.network = network != null ? Optional.of(network) : Optional.empty();
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change to Optional.ofNullable().

@@ -38,7 +46,10 @@ private ContainerSuite() {
Info info = dockerClient.infoCmd().exec();
LOG.info("Docker info: {}", info);

network = createDockerNetwork();
if (System.getenv("NEED_CREATE_DOCKER_NETWORK") != null
&& Objects.equals(System.getenv("NEED_CREATE_DOCKER_NETWORK"), "true")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to use string ignore case compare.

if (System.getenv("NEED_CREATE_DOCKER_NETWORK") != null
&& Objects.equals(System.getenv("NEED_CREATE_DOCKER_NETWORK"), "true")) {
String needCreateDockerNetwork = System.getenv("NEED_CREATE_DOCKER_NETWORK");
if (needCreateDockerNetwork != null && needCreateDockerNetwork.equalsIgnoreCase("true")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use "true".equals(xxx) instead and we can remove needCreateDockerNetwork != null

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok for me. We can improve it later on. @xunliu do you want to fix it?

@jerryshao jerryshao merged commit 38ea933 into apache:main Dec 21, 2023
github-actions bot pushed a commit that referenced this pull request Dec 21, 2023
…ess space (#1211)

### What changes were proposed in this pull request?

1. Added Docker network overlap detection
2. Reduced IP allocation ranges for lower conflict probability, Modified
to `10.20.30.0/28` only allocate IP ranger `10.20.30.1` ~ `10.20.30.14`
3. Docker network only created on MacOS and default Docker server
environment

### Why are the changes needed?

Fix: #879, #925

### Does this PR introduce _any_ user-facing change?

N/A

### How was this patch tested?

CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need backport Issues that need to backport to another branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug report] Build using Gradle fails when running ./gradlew build locally on Ubuntu
4 participants