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

Not always listen on TCP #7617

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
12 changes: 8 additions & 4 deletions src/go/guestagent/pkg/tracker/apitracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ func (a *APITracker) Add(containerID string, portMap nat.PortMap) error {
for portProto, portBindings := range portMap {
var tmpPortBinding []nat.PortBinding

log.Debugf("called add with portProto: %+v, portBindings: %+v\n", portProto, portBindings)

for _, portBinding := range portBindings {
// The expose API only supports IPv4
ipv4, err := isIPv4(portBinding.HostIP)
Expand All @@ -100,8 +102,9 @@ func (a *APITracker) Add(containerID string, portMap nat.PortMap) error {

err = a.apiForwarder.Expose(
&types.ExposeRequest{
Local: ipPortBuilder(a.determineHostIP(portBinding.HostIP), portBinding.HostPort),
Remote: ipPortBuilder(a.tapInterfaceIP, portBinding.HostPort),
Local: ipPortBuilder(a.determineHostIP(portBinding.HostIP), portBinding.HostPort),
Remote: ipPortBuilder(a.tapInterfaceIP, portBinding.HostPort),
Protocol: types.TransportProtocol(portProto.Proto()),
})
if err != nil {
errs = append(errs, fmt.Errorf("exposing %+v failed: %w", portBinding, err))
Expand Down Expand Up @@ -147,7 +150,7 @@ func (a *APITracker) Remove(containerID string) error {

var errs []error

for _, portBindings := range portMap {
for portProto, portBindings := range portMap {
for _, portBinding := range portBindings {
// The unexpose API only supports IPv4
ipv4, err := isIPv4(portBinding.HostIP)
Expand All @@ -160,7 +163,8 @@ func (a *APITracker) Remove(containerID string) error {

err = a.apiForwarder.Unexpose(
&types.UnexposeRequest{
Local: ipPortBuilder(a.determineHostIP(portBinding.HostIP), portBinding.HostPort),
Local: ipPortBuilder(a.determineHostIP(portBinding.HostIP), portBinding.HostPort),
Protocol: types.TransportProtocol(portProto.Proto()),
})
if err != nil {
errs = append(errs,
Expand Down
Loading