-
Notifications
You must be signed in to change notification settings - Fork 1.1k
OCPBUGS-58229: server: handle missing network namespace gracefully during networkStop #9301
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d17990a
server: handle missing network namespace gracefully during networkStop
sohankunkerkar 1ae6655
test: add coverage for network recovery after reboot with destroyed n…
sohankunkerkar 65395cb
test: use quay.io instead of registry.fedoraproject.org
sohankunkerkar faec3f5
contrib/test/ci: skip network recovery after reboot test for kata
sohankunkerkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//go:build freebsd | ||
// +build freebsd | ||
|
||
package server | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cri-o/cri-o/internal/lib/sandbox" | ||
"github.com/cri-o/cri-o/internal/log" | ||
) | ||
|
||
// validateNetworkNamespace checks if the given path is a valid network namespace | ||
// On FreeBSD, this is a no-op since network namespaces are Linux-specific. | ||
func (s *Server) validateNetworkNamespace(netnsPath string) error { | ||
// Network namespaces are Linux-specific, so on FreeBSD we assume it's valid | ||
return nil | ||
} | ||
|
||
// cleanupNetns removes a network namespace file and logs the action | ||
// On FreeBSD, this is a no-op since network namespaces are Linux-specific. | ||
func (s *Server) cleanupNetns(ctx context.Context, netnsPath string, sb *sandbox.Sandbox) { | ||
log.Debugf(ctx, "Network namespace cleanup not supported on this platform") | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package server | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/containernetworking/plugins/pkg/ns" | ||
|
||
"github.com/cri-o/cri-o/internal/lib/sandbox" | ||
"github.com/cri-o/cri-o/internal/log" | ||
) | ||
|
||
// validateNetworkNamespace checks if the given path is a valid network namespace. | ||
func (s *Server) validateNetworkNamespace(netnsPath string) error { | ||
netns, err := ns.GetNS(netnsPath) | ||
if err != nil { | ||
return fmt.Errorf("invalid network namespace: %w", err) | ||
} | ||
|
||
defer netns.Close() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd remove the |
||
|
||
return nil | ||
} | ||
|
||
// cleanupNetns removes a network namespace file and logs the action. | ||
func (s *Server) cleanupNetns(ctx context.Context, netnsPath string, sb *sandbox.Sandbox) { | ||
if rmErr := os.RemoveAll(netnsPath); rmErr != nil { | ||
log.Warnf(ctx, "Failed to remove netns path %s: %v", netnsPath, rmErr) | ||
} else { | ||
log.Infof(ctx, "Removed netns path %s from pod sandbox %s(%s)", netnsPath, sb.Name(), sb.ID()) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build !linux && !freebsd | ||
// +build !linux,!freebsd | ||
|
||
package server | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cri-o/cri-o/internal/lib/sandbox" | ||
"github.com/cri-o/cri-o/internal/log" | ||
) | ||
|
||
// validateNetworkNamespace checks if the given path is a valid network namespace | ||
// On unsupported platforms, this is a no-op since network namespaces are Linux-specific. | ||
func (s *Server) validateNetworkNamespace(netnsPath string) error { | ||
return nil | ||
} | ||
|
||
// cleanupNetns removes a network namespace file and logs the action | ||
// On unsupported platforms, this is a no-op since network namespaces are Linux-specific. | ||
func (s *Server) cleanupNetns(ctx context.Context, netnsPath string, sb *sandbox.Sandbox) { | ||
log.Debugf(ctx, "Network namespace cleanup not supported on this platform") | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
unqualified-search-registries = ['quay.io' ,'registry.access.redhat.com', 'registry.fedoraproject.org', 'docker.io'] | ||
unqualified-search-registries = ['quay.io', 'registry.access.redhat.com', 'docker.io'] | ||
|
||
[aliases] | ||
"image-for-testing" = "registry.crio.test.com/repo" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had IP leaks on containerd because of a similar change that ignored calling the network CNI plugin on some cases, causing the CNI to no release the IP address containerd/containerd#12132
I can not see this is similar or not, but @danwinship you should ensure that in this scenario the plugin gets the CNI DEL to release any resource associated to the Pod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aojea Thanks for calling that out. I can see the potential issue there. Let me go ahead and fix the issue.