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

fix of preheating may not working #573

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions pkg/eni/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
LocalIPType string
IPv4 netip.Addr
IPv6 netip.Addr

NoCache bool // do not use cached ip
}

func (l *LocalIPRequest) ResourceType() ResourceType {
Expand Down Expand Up @@ -329,20 +331,28 @@
expectV6 := 0

if l.enableIPv4 {
ipv4 := l.ipv4.PeekAvailable(cni.PodID)
if ipv4 == nil && len(l.ipv4)+l.allocatingV4 >= l.cap {
return nil, []Trace{{Condition: Full}}
} else if ipv4 == nil {
if lo.NoCache {

Check warning on line 334 in pkg/eni/local.go

View check run for this annotation

Codecov / codecov/patch

pkg/eni/local.go#L334

Added line #L334 was not covered by tests
expectV4 = 1
} else {
ipv4 := l.ipv4.PeekAvailable(cni.PodID)
if ipv4 == nil && len(l.ipv4)+l.allocatingV4 >= l.cap {
return nil, []Trace{{Condition: Full}}
} else if ipv4 == nil {
expectV4 = 1
}

Check warning on line 342 in pkg/eni/local.go

View check run for this annotation

Codecov / codecov/patch

pkg/eni/local.go#L336-L342

Added lines #L336 - L342 were not covered by tests
}
}

if l.enableIPv6 {
ipv6 := l.ipv6.PeekAvailable(cni.PodID)
if ipv6 == nil && len(l.ipv6)+l.allocatingV6 >= l.cap {
return nil, []Trace{{Condition: Full}}
} else if ipv6 == nil {
if lo.NoCache {

Check warning on line 347 in pkg/eni/local.go

View check run for this annotation

Codecov / codecov/patch

pkg/eni/local.go#L347

Added line #L347 was not covered by tests
expectV6 = 1
} else {
ipv6 := l.ipv6.PeekAvailable(cni.PodID)
if ipv6 == nil && len(l.ipv6)+l.allocatingV6 >= l.cap {
return nil, []Trace{{Condition: Full}}
} else if ipv6 == nil {
expectV6 = 1
}

Check warning on line 355 in pkg/eni/local.go

View check run for this annotation

Codecov / codecov/patch

pkg/eni/local.go#L349-L355

Added lines #L349 - L355 were not covered by tests
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/eni/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@

_, err := m.Allocate(ctx, &daemon.CNI{}, &AllocRequest{
ResourceRequests: []ResourceRequest{
&LocalIPRequest{},
&LocalIPRequest{NoCache: true},

Check warning on line 321 in pkg/eni/manager.go

View check run for this annotation

Codecov / codecov/patch

pkg/eni/manager.go#L321

Added line #L321 was not covered by tests
},
})
if err != nil {
Expand Down
Loading