Skip to content

Fix CNS logs bytes when printing HNS Endpoint #3671

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ vendor/
# Binaries
out/*
output/*
cns/service/service

# Artifacts
azure-*.json
Expand Down
4 changes: 2 additions & 2 deletions cni/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ ARG OS_VERSION
ARG OS

# mcr.microsoft.com/oss/go/microsoft/golang:1.23-cbl-mariner2.0
FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang@sha256:f1cb092e89f5f3448b6db87729039c61541cb85747c690f760b3017218d449bb AS go
FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang@sha256:b06999cae63b9b6f43bcb16bd16bcbedae847684515317e15607a601ed108030 AS go

# mcr.microsoft.com/cbl-mariner/base/core:2.0
FROM --platform=linux/${ARCH} mcr.microsoft.com/cbl-mariner/base/core@sha256:12480ee9f027c304fabc17d70afc7d5da6c49ad46f0401947478e7218ea0ff6c AS mariner-core
FROM --platform=linux/${ARCH} mcr.microsoft.com/cbl-mariner/base/core@sha256:961bfedbbbdc0da51bc664f51d959da292eced1ad46c3bf674aba43b9be8c703 AS mariner-core

FROM go AS azure-vnet
ARG OS
Expand Down
6 changes: 3 additions & 3 deletions cns/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ ARG OS_VERSION
ARG OS

# mcr.microsoft.com/oss/go/microsoft/golang:1.23-cbl-mariner2.0
FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang@sha256:f1cb092e89f5f3448b6db87729039c61541cb85747c690f760b3017218d449bb AS go
FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang@sha256:b06999cae63b9b6f43bcb16bd16bcbedae847684515317e15607a601ed108030 AS go

# mcr.microsoft.com/cbl-mariner/base/core:2.0
FROM mcr.microsoft.com/cbl-mariner/base/core@sha256:12480ee9f027c304fabc17d70afc7d5da6c49ad46f0401947478e7218ea0ff6c AS mariner-core
FROM mcr.microsoft.com/cbl-mariner/base/core@sha256:961bfedbbbdc0da51bc664f51d959da292eced1ad46c3bf674aba43b9be8c703 AS mariner-core

# mcr.microsoft.com/cbl-mariner/distroless/minimal:2.0
FROM mcr.microsoft.com/cbl-mariner/distroless/minimal@sha256:a2529d152e75b29502a8de264a4f3dfb8fd126d870c9bf4456d03b7a7dab7268 AS mariner-distroless
FROM mcr.microsoft.com/cbl-mariner/distroless/minimal@sha256:7778a86d86947d5f64c1280a7ee0cf36c6c6d76b5749dd782fbcc14f113961bf AS mariner-distroless

FROM --platform=linux/${ARCH} go AS builder
ARG OS
Expand Down
18 changes: 15 additions & 3 deletions cns/hnsclient/hnsclient_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ const (
// Named Lock for network and endpoint creation/deletion
var namedLock = common.InitNamedLock()

// Error definitions
var (
ErrDeleteEndpoint = errors.New("failed to delete endpoint")
)

// CreateHnsNetwork creates the HNS network with the provided configuration
func CreateHnsNetwork(nwConfig cns.CreateHnsNetworkRequest) error {
logger.Printf("[Azure CNS] CreateHnsNetwork")
Expand Down Expand Up @@ -552,7 +557,10 @@ func configureHostNCApipaEndpoint(

endpoint.IpConfigurations = append(endpoint.IpConfigurations, ipConfiguration)

logger.Printf("[Azure CNS] Configured HostNCApipaEndpoint: %+v", endpoint)
logger.Printf("[Azure CNS] Configured HostNCApipaEndpoint with ID: %s, Name: %s, Network: %s",
endpoint.Id, endpoint.Name, endpoint.HostComputeNetwork)
logger.Printf("[Azure CNS] Endpoint IpConfigurations:%v, Dns:%v, Routes:%v, MacAddress:%s, Flags:%d",
endpoint.IpConfigurations, endpoint.Dns, endpoint.Routes, endpoint.MacAddress, endpoint.Flags)

return endpoint, nil
}
Expand Down Expand Up @@ -689,10 +697,14 @@ func deleteEndpointByNameHnsV2(
}

if err = endpoint.Delete(); err != nil {
return fmt.Errorf("Failed to delete endpoint: %+v. Error: %v", endpoint, err)
return fmt.Errorf("%w: %s (%s): %w",
ErrDeleteEndpoint, endpoint.Name, endpoint.Id, err)
}

logger.Errorf("[Azure CNS] Successfully deleted endpoint: %+v", endpoint)
logger.Errorf("[Azure CNS] Successfully deleted endpoint with ID: %s, Name: %s",
endpoint.Id, endpoint.Name)
logger.Debugf("[Azure CNS] Endpoint details - IpConfigurations:%v, Dns:%v, Routes:%v, MacAddress:%s, Flags:%d",
endpoint.IpConfigurations, endpoint.Dns, endpoint.Routes, endpoint.MacAddress, endpoint.Flags)

return nil
}
Expand Down
Loading