Skip to content

Commit

Permalink
Merge branch 'vmware-tanzu:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpang-vmware authored Dec 18, 2023
2 parents c0cc543 + 64154af commit f4d7dcc
Show file tree
Hide file tree
Showing 30 changed files with 124 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.19
go-version: 1.21

- name: Run build
run: make build
Expand Down
2 changes: 1 addition & 1 deletion build/image/photon/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19.10 as golang-build
FROM golang:1.21.5 as golang-build

WORKDIR /source

Expand Down
5 changes: 5 additions & 0 deletions build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ spec:
maxItems: 5
minItems: 0
type: array
shortID:
description: ShortID specifies Identifier to use when displaying VPC
context in logs. Less than equal to 8 characters.
maxLength: 8
type: string
type: object
status:
description: VPCNetworkConfigurationStatus defines the observed state
Expand Down
6 changes: 6 additions & 0 deletions cmd_clean/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ func main() {
} else {
err = clean.Clean(cf, nil)
}
// the error roughly are:
// 1. failed to validate config
// 2. failed to get nsx client
// 3. failed to initialize cleanup service
// 4. failed to clean up specific resource
err = clean.Clean(cf, nil)
if err != nil {
log.Error(err, "failed to clean nsx resources")
os.Exit(1)
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module github.com/vmware-tanzu/nsx-operator

go 1.19
go 1.21.5

replace (
github.com/vmware-tanzu/nsx-operator/pkg/apis => ./pkg/apis
github.com/vmware-tanzu/nsx-operator/pkg/client => ./pkg/client
)

require (
github.com/agiledragon/gomonkey v2.0.2+incompatible
github.com/agiledragon/gomonkey/v2 v2.9.0
github.com/apparentlymart/go-cidr v1.1.0
github.com/coreos/go-semver v0.3.1
Expand All @@ -23,7 +22,7 @@ require (
github.com/prometheus/client_golang v1.16.0
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.2
github.com/vmware-tanzu/nsx-operator/pkg/apis v0.0.1
github.com/vmware-tanzu/nsx-operator/pkg/apis v1.0.0
github.com/vmware-tanzu/nsx-operator/pkg/client v0.0.0-00010101000000-000000000000
github.com/vmware-tanzu/vm-operator/api v1.8.2
github.com/vmware/govmomi v0.27.4
Expand Down
47 changes: 45 additions & 2 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/apis/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/vmware-tanzu/nsx-operator/pkg/apis

go 1.19
go 1.21.5

require (
k8s.io/api v0.26.1
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ type VPCNetworkConfigurationSpec struct {
// Must be Public or Private.
// +kubebuilder:validation:Enum=Public;Private
DefaultSubnetAccessMode string `json:"defaultSubnetAccessMode,omitempty"`
// ShortID specifies Identifier to use when displaying VPC context in logs.
// Less than equal to 8 characters.
// +kubebuilder:validation:MaxLength=8
// +optional
ShortID string `json:"shortID,omitempty"`
}

// VPCNetworkConfigurationStatus defines the observed state of VPCNetworkConfiguration
Expand Down
19 changes: 16 additions & 3 deletions pkg/clean/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"fmt"
"net/http"

"k8s.io/client-go/util/retry"

"github.com/vmware-tanzu/nsx-operator/pkg/config"
commonctl "github.com/vmware-tanzu/nsx-operator/pkg/controllers/common"
"github.com/vmware-tanzu/nsx-operator/pkg/logger"
Expand All @@ -32,13 +34,24 @@ func Clean(cf *config.NSXOperatorConfig, client *http.Client) error {
return fmt.Errorf("failed to validate config: %w", err)
}
if cleanupService, err := InitializeCleanupService(cf, client); err != nil {
return fmt.Errorf("failed to initialize cleanup service: %w", err)
return err // failed to get nsx client
} else if cleanupService.err != nil {
return fmt.Errorf("failed to initialize cleanup service: %w", cleanupService.err)
} else {
for _, clean := range cleanupService.cleans {
if err := clean.Cleanup(); err != nil {
return fmt.Errorf("failed to clean up: %w", err)
if err := retry.OnError(retry.DefaultRetry, func(err error) bool {
if err != nil {
log.Info("retrying to clean up NSX resources", "error", err)
return true
}
return false
}, func() error {
if err := clean.Cleanup(); err != nil {
return fmt.Errorf("failed to clean up specific resource: %w", err)
}
return nil
}); err != nil {
return err
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/vmware-tanzu/nsx-operator/pkg/client

go 1.19
go 1.21.5

require (
github.com/vmware-tanzu/nsx-operator/pkg/apis v0.0.1
github.com/vmware-tanzu/nsx-operator/pkg/apis v1.0.0
k8s.io/apimachinery v0.28.4
k8s.io/client-go v0.28.4
)
Expand Down
13 changes: 11 additions & 2 deletions pkg/client/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En
github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand All @@ -31,6 +32,7 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
Expand All @@ -41,6 +43,7 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand All @@ -55,13 +58,17 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.9.4 h1:xR7vG4IXt5RWx6FfIjyAtsoMAtnc3C/rFXBBd2AjZwE=
github.com/onsi/ginkgo/v2 v2.9.4/go.mod h1:gCQYp2Q+kSoIj7ykSVb9nskRSsR6PUj4AiLywzIhbKM=
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
Expand All @@ -70,8 +77,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/vmware-tanzu/nsx-operator/pkg/apis v0.0.1 h1:z5hr4FZm2AGkmkwqRjk1QQr5JUBdU7YzN+t5mKaa76s=
github.com/vmware-tanzu/nsx-operator/pkg/apis v0.0.1/go.mod h1:j8vSYBnN83WIaLIW6BKD2IHiI0MMpd4lPxefpA00CzI=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/vmware-tanzu/nsx-operator/pkg/apis v1.0.0 h1:jmHI88hySjGqkpc/QUmSY5G5SsDvoXxmKFEK/GmcHWs=
github.com/vmware-tanzu/nsx-operator/pkg/apis v1.0.0/go.mod h1:ZR/7rewflpAhnswQ6NVkFN0JmaqHgmvDyFVsJLmZ+pw=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down Expand Up @@ -110,6 +118,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y=
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/securitypolicy/namespace_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/securitypolicy/pod_hanlder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/subnet/subnet_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/subnetport/subnetport_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
"time"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha1"
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/vpc/vpc_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func buildNetworkConfigInfo(vpcConfigCR v1alpha1.VPCNetworkConfiguration) (*vpc.
PrivateIPv4CIDRs: vpcConfigCR.Spec.PrivateIPv4CIDRs,
DefaultIPv4SubnetSize: vpcConfigCR.Spec.DefaultIPv4SubnetSize,
DefaultSubnetAccessMode: vpcConfigCR.Spec.DefaultSubnetAccessMode,
ShortID: vpcConfigCR.Spec.ShortID,
}
return ninfo, nil
}
2 changes: 1 addition & 1 deletion pkg/nsx/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model"

Expand Down
2 changes: 1 addition & 1 deletion pkg/nsx/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"

"github.com/vmware-tanzu/nsx-operator/pkg/nsx/ratelimiter"
Expand Down
2 changes: 1 addition & 1 deletion pkg/nsx/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"time"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

Expand Down
2 changes: 1 addition & 1 deletion pkg/nsx/services/ippool/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/nsx/services/mediator/mediator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"reflect"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model"

"github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/common"
Expand Down
4 changes: 2 additions & 2 deletions pkg/nsx/services/securitypolicy/expand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"reflect"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/vmware/vsphere-automation-sdk-go/runtime/data"
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model"
v12 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down
2 changes: 1 addition & 1 deletion pkg/nsx/services/securitypolicy/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/vmware/vsphere-automation-sdk-go/runtime/bindings"
"github.com/vmware/vsphere-automation-sdk-go/runtime/data"
Expand Down
2 changes: 1 addition & 1 deletion pkg/nsx/services/staticroute/staticroute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
Expand Down
2 changes: 1 addition & 1 deletion pkg/nsx/services/subnet/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/vmware/vsphere-automation-sdk-go/runtime/bindings"
"github.com/vmware/vsphere-automation-sdk-go/runtime/data"
Expand Down
3 changes: 3 additions & 0 deletions pkg/nsx/services/vpc/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func buildNSXVPC(obj *v1alpha1.VPC, nc VPCNetworkConfigInfo, cluster string, pat
// update private/public blocks
vpc.ExternalIpv4Blocks = nc.ExternalIPv4Blocks
vpc.PrivateIpv4Blocks = util.GetMapValues(pathMap)
if nc.ShortID != "" {
vpc.ShortId = &nc.ShortID
}

return vpc, nil
}
2 changes: 1 addition & 1 deletion pkg/nsx/services/vpc/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"testing"

"github.com/agiledragon/gomonkey"
"github.com/agiledragon/gomonkey/v2"
"github.com/stretchr/testify/assert"
"github.com/vmware/vsphere-automation-sdk-go/runtime/bindings"
"github.com/vmware/vsphere-automation-sdk-go/runtime/data"
Expand Down
1 change: 1 addition & 0 deletions pkg/nsx/services/vpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ type VPCNetworkConfigInfo struct {
PrivateIPv4CIDRs []string
DefaultIPv4SubnetSize int
DefaultSubnetAccessMode string
ShortID string
}
9 changes: 7 additions & 2 deletions pkg/third_party/retry/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"os"
"testing"
"time"

Expand Down Expand Up @@ -150,6 +151,10 @@ func TestRandomDelay(t *testing.T) {
}

func TestMaxDelay(t *testing.T) {
if os.Getenv("OS") == "macos-latest" {
t.Skip("Skipping testing in MacOS GitHub actions - too slow, duration is wrong")
}

start := time.Now()
err := Do(
func() error { return errors.New("test") },
Expand All @@ -159,8 +164,8 @@ func TestMaxDelay(t *testing.T) {
)
dur := time.Since(start)
assert.Error(t, err)
assert.True(t, dur > 170*time.Millisecond, "5 times with maximum delay retry is longer than 170ms")
assert.True(t, dur < 200*time.Millisecond, "5 times with maximum delay retry is shorter than 200ms")
assert.Greater(t, dur, 120*time.Millisecond, "5 times with maximum delay retry is less than 120ms")
assert.Less(t, dur, 250*time.Millisecond, "5 times with maximum delay retry is longer than 250ms")
}

func TestBackOffDelay(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/nsx_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestDefaultSubnetSet(t *testing.T) {

portPath, _ := filepath.Abs("./manifest/testSubnet/subnetport_1.yaml")
err = applyYAML(portPath, E2ENamespace)
time.Sleep(10 * time.Second)
time.Sleep(30 * time.Second)
assert_nil(t, err)
defer deleteYAML(portPath, E2ENamespace)

Expand Down Expand Up @@ -144,7 +144,7 @@ func TestUserSubnetSet(t *testing.T) {

portPath, _ := filepath.Abs("./manifest/testSubnet/subnetport_2.yaml")
err = applyYAML(portPath, E2ENamespace)
time.Sleep(10 * time.Second)
time.Sleep(30 * time.Second)
assert_nil(t, err)
defer deleteYAML(portPath, E2ENamespace)

Expand Down

0 comments on commit f4d7dcc

Please sign in to comment.