diff --git a/.gitignore b/.gitignore index 2558114dbc..f9c56d8d2c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ vendor/ # Binaries out/* output/* +cns/service/service # Artifacts azure-*.json diff --git a/.pipelines/build/dockerfiles/cns.Dockerfile b/.pipelines/build/dockerfiles/cns.Dockerfile index 97115c199f..d6540d2bc6 100644 --- a/.pipelines/build/dockerfiles/cns.Dockerfile +++ b/.pipelines/build/dockerfiles/cns.Dockerfile @@ -11,11 +11,11 @@ ENTRYPOINT ["azure-cns.exe"] EXPOSE 10090 # mcr.microsoft.com/azurelinux/base/core:3.0 -FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/base/core@sha256:9948138108a3d69f1dae62104599ac03132225c3b7a5ac57b85a214629c8567d AS build-helper +FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/base/core@sha256:c09a4e011a092a45b5c46ac5633253eb1e1106df028912b89cbe225d9061ef0b AS build-helper RUN tdnf install -y iptables # mcr.microsoft.com/azurelinux/distroless/minimal:3.0 -FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/distroless/minimal@sha256:0801b80a0927309572b9adc99bd1813bc680473175f6e8175cd4124d95dbd50c AS linux +FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/distroless/minimal@sha256:c37100f358ee19e62c60673c54fb43b83d43b2c305846e44b23b2e032e9caf30 AS linux ARG ARTIFACT_DIR . COPY --from=build-helper /usr/sbin/*tables* /usr/sbin/ diff --git a/cni/Dockerfile b/cni/Dockerfile index 6f0eb2e5e5..fc9fefcd53 100644 --- a/cni/Dockerfile +++ b/cni/Dockerfile @@ -6,10 +6,10 @@ ARG OS_VERSION ARG OS # mcr.microsoft.com/oss/go/microsoft/golang:1.23-azurelinux3.0 -FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang@sha256:8f60e85f4b2f567c888d0b3a4cd12dc74bee534d94c528655546452912d90c74 AS go +FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang@sha256:2b7adfb3e3384d2ddc5e65c3f37265f575340d7e1c771bef073ca8da651922f1 AS go # mcr.microsoft.com/azurelinux/base/core:3.0 -FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/base/core@sha256:9948138108a3d69f1dae62104599ac03132225c3b7a5ac57b85a214629c8567d AS mariner-core +FROM --platform=linux/${ARCH} mcr.microsoft.com/azurelinux/base/core@sha256:c09a4e011a092a45b5c46ac5633253eb1e1106df028912b89cbe225d9061ef0b AS mariner-core FROM go AS azure-vnet ARG OS diff --git a/cns/Dockerfile b/cns/Dockerfile index 2539e90043..ee037bfa5b 100644 --- a/cns/Dockerfile +++ b/cns/Dockerfile @@ -5,13 +5,13 @@ ARG OS_VERSION ARG OS # mcr.microsoft.com/oss/go/microsoft/golang:1.23-azurelinux3.0 -FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang@sha256:8f60e85f4b2f567c888d0b3a4cd12dc74bee534d94c528655546452912d90c74 AS go +FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang@sha256:2b7adfb3e3384d2ddc5e65c3f37265f575340d7e1c771bef073ca8da651922f1 AS go # mcr.microsoft.com/azurelinux/base/core:3.0 -FROM mcr.microsoft.com/azurelinux/base/core@sha256:9948138108a3d69f1dae62104599ac03132225c3b7a5ac57b85a214629c8567d AS mariner-core +FROM mcr.microsoft.com/azurelinux/base/core@sha256:c09a4e011a092a45b5c46ac5633253eb1e1106df028912b89cbe225d9061ef0b AS mariner-core # mcr.microsoft.com/azurelinux/distroless/minimal:3.0 -FROM mcr.microsoft.com/azurelinux/distroless/minimal@sha256:0801b80a0927309572b9adc99bd1813bc680473175f6e8175cd4124d95dbd50c AS mariner-distroless +FROM mcr.microsoft.com/azurelinux/distroless/minimal@sha256:c37100f358ee19e62c60673c54fb43b83d43b2c305846e44b23b2e032e9caf30 AS mariner-distroless FROM --platform=linux/${ARCH} go AS builder ARG OS diff --git a/cns/hnsclient/hnsclient_windows.go b/cns/hnsclient/hnsclient_windows.go index b97781a17a..438001add7 100644 --- a/cns/hnsclient/hnsclient_windows.go +++ b/cns/hnsclient/hnsclient_windows.go @@ -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") @@ -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 } @@ -584,7 +592,8 @@ func CreateHostNCApipaEndpoint( } if endpoint != nil { - logger.Debugf("[Azure CNS] Found existing endpoint: %+v", endpoint) + logger.Debugf("[Azure CNS] Found existing endpoint with ID: %s, Name: %s, Network: %s", + endpoint.Id, endpoint.Name, endpoint.HostComputeNetwork) return endpoint.Id, nil } @@ -608,14 +617,18 @@ func CreateHostNCApipaEndpoint( return "", err } - logger.Printf("[Azure CNS] Creating HostNCApipaEndpoint for host container connectivity: %+v", endpoint) + logger.Printf("[Azure CNS] Creating HostNCApipaEndpoint with ID: %s, Name: %s, Network: %s", + endpoint.Id, endpoint.Name, endpoint.HostComputeNetwork) if endpoint, err = endpoint.Create(); err != nil { err = fmt.Errorf("Failed to create HostNCApipaEndpoint: %s. Error: %v", endpointName, err) logger.Errorf("[Azure CNS] %s", err.Error()) return "", err } - logger.Printf("[Azure CNS] Successfully created HostNCApipaEndpoint: %+v", endpoint) + logger.Printf("[Azure CNS] Successfully created HostNCApipaEndpoint with ID: %s, Name: %s, Network: %s", + endpoint.Id, endpoint.Name, endpoint.HostComputeNetwork) + 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 endpoint.Id, nil } @@ -689,10 +702,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): %v", + 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 }