diff --git a/.github/workflows/e2e-test-ci-v2-cron-dev.yml b/.github/workflows/e2e-test-ci-v2-cron-dev.yml index b7a1fbc3d8..de34007be2 100644 --- a/.github/workflows/e2e-test-ci-v2-cron-dev.yml +++ b/.github/workflows/e2e-test-ci-v2-cron-dev.yml @@ -34,7 +34,7 @@ concurrency: jobs: changes: if: ${{ (!github.event.pull_request.draft && github.event.schedule == '0 0 * * *') }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest outputs: docs: ${{ steps.filter.outputs.docs }} go: ${{ steps.filter.outputs.go }} @@ -65,7 +65,7 @@ jobs: - ".github/**" build: name: Build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: changes if: needs.changes.outputs.go == 'true' @@ -120,7 +120,7 @@ jobs: | pigz > docker-dev.tar.gz - name: cache - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: docker-dev.tar.gz path: docker-dev.tar.gz @@ -128,7 +128,7 @@ jobs: prepare: needs: changes if: needs.changes.outputs.go == 'true' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -151,7 +151,7 @@ jobs: - changes - prepare - build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false # If false, GitHub will not cancels all in-progress jobs in the matrix if any matrix job fails. matrix: @@ -173,7 +173,7 @@ jobs: sudo cp ~/go/bin/ginkgo /usr/local/bin - name: cache - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: docker-dev.tar.gz diff --git a/.github/workflows/e2e-test-ci-v2-cron.yml b/.github/workflows/e2e-test-ci-v2-cron.yml index 287c3e8545..0c9fb269cb 100644 --- a/.github/workflows/e2e-test-ci-v2-cron.yml +++ b/.github/workflows/e2e-test-ci-v2-cron.yml @@ -33,7 +33,7 @@ concurrency: jobs: changes: if: ${{ (!github.event.pull_request.draft && contains(github.event.pull_request.labels.*.name, 'area/test/apiv2')) || github.event.schedule == '0 0 * * *' }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest outputs: docs: ${{ steps.filter.outputs.docs }} go: ${{ steps.filter.outputs.go }} @@ -64,7 +64,7 @@ jobs: - ".github/**" build: name: Build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: changes if: needs.changes.outputs.go == 'true' @@ -119,7 +119,7 @@ jobs: | pigz > docker-v2.tar.gz - name: cache - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: docker-v2.tar.gz path: docker-v2.tar.gz @@ -127,7 +127,7 @@ jobs: prepare: needs: changes if: needs.changes.outputs.go == 'true' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -150,7 +150,7 @@ jobs: - changes - prepare - build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false # If false, GitHub will not cancels all in-progress jobs in the matrix if any matrix job fails. matrix: @@ -172,7 +172,7 @@ jobs: sudo cp ~/go/bin/ginkgo /usr/local/bin - name: cache - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: docker-v2.tar.gz diff --git a/.github/workflows/e2e-test-ci.yml b/.github/workflows/e2e-test-ci.yml index bf5ae42203..eb11045693 100644 --- a/.github/workflows/e2e-test-ci.yml +++ b/.github/workflows/e2e-test-ci.yml @@ -33,7 +33,7 @@ concurrency: jobs: changes: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest outputs: docs: ${{ steps.filter.outputs.docs }} go: ${{ steps.filter.outputs.go }} @@ -64,7 +64,7 @@ jobs: - ".github/**" build: name: Build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: changes if: needs.changes.outputs.go == 'true' @@ -120,7 +120,7 @@ jobs: | pigz > docker.tar.gz - name: cache - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: docker.tar.gz path: docker.tar.gz @@ -128,7 +128,7 @@ jobs: prepare: needs: changes if: needs.changes.outputs.go == 'true' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -151,7 +151,7 @@ jobs: - changes - prepare - build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false # If false, GitHub will not cancels all in-progress jobs in the matrix if any matrix job fails. matrix: @@ -175,7 +175,7 @@ jobs: sudo cp ~/go/bin/ginkgo /usr/local/bin - name: cache - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: docker.tar.gz diff --git a/.github/workflows/k8s-timer-ci.yml b/.github/workflows/k8s-timer-ci.yml index 9632de0be1..87a268802e 100644 --- a/.github/workflows/k8s-timer-ci.yml +++ b/.github/workflows/k8s-timer-ci.yml @@ -26,7 +26,7 @@ on: jobs: changes: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest outputs: docs: ${{ steps.filter.outputs.docs }} go: ${{ steps.filter.outputs.go }} @@ -56,7 +56,7 @@ jobs: - 'utils/**' build: name: Build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: changes steps: @@ -109,7 +109,7 @@ jobs: | pigz > docker.tar.gz - name: cache - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: docker.tar.gz path: docker.tar.gz @@ -117,7 +117,7 @@ jobs: prepare: needs: changes if: needs.changes.outputs.go == 'true' - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: @@ -131,7 +131,7 @@ jobs: - changes - prepare - build - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest strategy: fail-fast: false # If false, GitHub will not cancels all in-progress jobs in the matrix if any matrix job fails. matrix: @@ -157,7 +157,7 @@ jobs: sudo cp ~/go/bin/ginkgo /usr/local/bin - name: cache - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: docker.tar.gz diff --git a/CHANGELOG.md b/CHANGELOG.md index 733d92c267..5eb4527f67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ # Table of Contents +- [1.8.4](#184) - [1.8.3](#182) - [1.8.2](#182) - [1.8.1](#181) @@ -42,6 +43,21 @@ - [0.2.0](#020) - [0.1.0](#010) +# 1.8.4 + +## What's New + +- upgrade: etcd-adapter and add e2e test @Revolyssup (#2369) +- chore: upgrade ubuntu from 20.04 to latest @Revolyssup (#2352) +- chore: upgrade actions/upload-artifact and actions/download-artifact @nic-6443 (#2328) +- docs: update http[].match.exprs any -> all @acuteaura (#2270) +- fix: attempt to shut down when provider init fails @acuteaura (#2263) + +## 👨🏽‍💻 Contributors + +Thank you to our contributors for making this release possible: +@Revolyssup, @acuteaura and @nic-6443 + # 1.8.3 ## What's New @@ -53,7 +69,6 @@ Thank you to our contributors for making this release possible: @Revolyssup - # 1.8.2 ## What's New @@ -940,7 +955,7 @@ https://github.com/apache/apisix-ingress-controller/issues. * lsy * mango * Fatpa -* Hoshea Jiang +* Hoshea Jiang * JasonZhu * Yu.Bozhong * seven dickens @@ -1234,7 +1249,7 @@ https://github.com/apache/apisix-ingress-controller/issues. * lsy * mango * Fatpa -* Hoshea Jiang +* Hoshea Jiang * JasonZhu * Xin Rong * Yu.Bozhong @@ -1720,7 +1735,7 @@ Please try out the release binaries and report any issues at ### Contributors * kv -* Hoshea Jiang +* Hoshea Jiang * Jintao Zhang * Sarasa Kisaragi * Baoyuan @@ -1798,7 +1813,7 @@ Please try out the release binaries and report any issues at * kv * Jintao Zhang * Baoyuan -* Hoshea Jiang +* Hoshea Jiang * chen zhuo * okaybase * yuanfeng0905 diff --git a/docs/en/latest/references/apisix_route_v2.md b/docs/en/latest/references/apisix_route_v2.md index 0104efe511..1cb8ebc3a8 100644 --- a/docs/en/latest/references/apisix_route_v2.md +++ b/docs/en/latest/references/apisix_route_v2.md @@ -48,7 +48,7 @@ The table below describes each of the attributes in the spec. The fields `apiVer | http[].match.hosts | array | List of hosts to match the Route with. The Route will be used if any one of the hosts is matched. | | http[].match.methods | array | List of HTTP methods (`GET`, `POST`, `PUT`, `DELETE`, `PATCH`, `HEAD`, `OPTIONS`, `CONNECT`, `TRACE`) to match the Route with. The Route will be used if any one of the methods is matched. | | http[].match.remoteAddrs | array | List of IP addresses (CIDR format) to match the Route with. The Route will be used if any one of the IP address is matched. | -| http[].match.exprs | array | List of expressions to match the Route with. The Route will be used if any one of the expression is matched. | +| http[].match.exprs | array | List of expressions to match the Route with. The Route will be used if all of the expressions are matched. | | http[].match.exprs[].subject | object | Subject for the expression. | | http[].match.exprs[].subject.scope | string | Scope of the subject. Can be one of `Header`, `Query`, `Cookie`, or `Path`. | | http[].match.exprs[].subject.name | string | Subject name. Can be empty when the scope is `Path`. | diff --git a/go.mod b/go.mod index b92e2e4492..26f50d7983 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/apache/apisix-ingress-controller go 1.20 require ( - github.com/api7/etcd-adapter v0.2.4 + github.com/api7/etcd-adapter v0.2.5 github.com/api7/gopkg v0.2.0 github.com/gin-gonic/gin v1.9.1 github.com/hashicorp/go-memdb v1.3.4 diff --git a/go.sum b/go.sum index 650ed7797e..6968affa66 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/api7/etcd-adapter v0.2.4 h1:VWdDPUJPai5IdxV5dwwZF9e7Ilw7sBWwaEeFzPO2fV4= -github.com/api7/etcd-adapter v0.2.4/go.mod h1:JoLtq4IxiIw6Z+k9eRGHL0CDyfRvnNXGI0skV0EsSE8= +github.com/api7/etcd-adapter v0.2.5 h1:uyXqDsIaI39I/1AT9/7iKSGU8icsKhpuOHFb17wkvJE= +github.com/api7/etcd-adapter v0.2.5/go.mod h1:JoLtq4IxiIw6Z+k9eRGHL0CDyfRvnNXGI0skV0EsSE8= github.com/api7/gopkg v0.2.0 h1:+5vw6Rt9IeEpJoL2JMZFDwGDhH4aaeUJize21/3Qdzc= github.com/api7/gopkg v0.2.0/go.mod h1:LlplmjGCrkcS3nyCYpTwkdLkuNlYRYAnI8XH1qwsICw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= diff --git a/pkg/providers/controller.go b/pkg/providers/controller.go index d8693221b9..e50e09172e 100644 --- a/pkg/providers/controller.go +++ b/pkg/providers/controller.go @@ -16,6 +16,7 @@ package providers import ( "context" + "errors" "fmt" "os" "sync" @@ -183,7 +184,18 @@ func (c *Controller) Run(ctx context.Context) error { return err } - c.run(rootCtx) + err := c.run(rootCtx) + if err != nil { + log.Errorf("provider run returned error, exiting process: %s", err) + + // attempt to give up leader status, should also release the waitgroup and exit the process + rootCancel() + go func() { + time.Sleep(time.Second * 5) + log.Errorf("process has not quit 5s after provider failure, forcing exit: %s", err) + os.Exit(1) + }() + } wg.Wait() return nil @@ -382,7 +394,7 @@ func (c *Controller) initSharedInformers() *providertypes.ListerInformer { return listerInformer } -func (c *Controller) run(ctx context.Context) { +func (c *Controller) run(ctx context.Context) error { log.Infow("controller tries to leading ...", zap.String("namespace", c.namespace), zap.String("pod", c.name), @@ -406,29 +418,22 @@ func (c *Controller) run(ctx context.Context) { CacheSynced: !c.cfg.EtcdServer.Enabled, SSLKeyEncryptSalt: c.cfg.EtcdServer.SSLKeyEncryptSalt, } + + // TODO: needs retry logic err := c.apisix.AddCluster(ctx, clusterOpts) if err != nil && err != apisix.ErrDuplicatedCluster { - // TODO give up the leader role log.Errorf("failed to add default cluster: %s", err) - return + return err } if err := c.apisix.Cluster(c.cfg.APISIX.DefaultClusterName).HasSynced(ctx); err != nil { - // TODO give up the leader role log.Errorf("failed to wait the default cluster to be ready: %s", err) - - // re-create apisix cluster, used in next c.run - if err = c.apisix.UpdateCluster(ctx, clusterOpts); err != nil { - log.Errorf("failed to update default cluster: %s", err) - return - } - return + return err } // Creation Phase log.Info("creating controller") - c.informers = c.initSharedInformers() common := &providertypes.Common{ ControllerNamespace: c.namespace, @@ -443,14 +448,12 @@ func (c *Controller) run(ctx context.Context) { c.namespaceProvider, err = namespace.NewWatchingNamespaceProvider(ctx, c.kubeClient, c.cfg, c.resourceSyncCh) if err != nil { - ctx.Done() - return + return err } c.podProvider, err = pod.NewProvider(common, c.namespaceProvider) if err != nil { - ctx.Done() - return + return err } c.translator = translation.NewTranslator(&translation.TranslatorOptions{ @@ -466,20 +469,17 @@ func (c *Controller) run(ctx context.Context) { c.apisixProvider, c.apisixTranslator, err = apisixprovider.NewProvider(common, c.namespaceProvider, c.translator) if err != nil { - ctx.Done() - return + return err } c.ingressProvider, err = ingressprovider.NewProvider(common, c.namespaceProvider, c.translator, c.apisixTranslator) if err != nil { - ctx.Done() - return + return err } c.kubeProvider, err = k8s.NewProvider(common, c.translator, c.namespaceProvider, c.apisixProvider, c.ingressProvider) if err != nil { - ctx.Done() - return + return err } if c.cfg.Kubernetes.EnableGatewayAPI { @@ -495,8 +495,7 @@ func (c *Controller) run(ctx context.Context) { ListerInformer: common.ListerInformer, }) if err != nil { - ctx.Done() - return + return err } } @@ -505,16 +504,14 @@ func (c *Controller) run(ctx context.Context) { log.Info("init namespaces") if err = c.namespaceProvider.Init(ctx); err != nil { - ctx.Done() - return + return err } log.Info("wait for resource sync") // Wait for resource sync if ok := c.informers.StartAndWaitForCacheSync(ctx); !ok { - ctx.Done() - return + return errors.New("StartAndWaitForCacheSync failed") } log.Info("init providers") @@ -522,8 +519,7 @@ func (c *Controller) run(ctx context.Context) { // Compare resource if !c.cfg.EtcdServer.Enabled { if err = c.apisixProvider.Init(ctx); err != nil { - ctx.Done() - return + return err } } @@ -573,6 +569,8 @@ func (c *Controller) run(ctx context.Context) { log.Error("Start failed, abort...") cancelFunc() } + + return nil } func (c *Controller) checkClusterHealth(ctx context.Context, cancelFunc context.CancelFunc) { diff --git a/test/e2e/go.mod b/test/e2e/go.mod index b2f1e80f42..d4b5abfa32 100644 --- a/test/e2e/go.mod +++ b/test/e2e/go.mod @@ -21,7 +21,7 @@ require ( github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 // indirect github.com/ajg/form v1.5.1 // indirect github.com/andybalholm/brotli v1.0.4 // indirect - github.com/api7/etcd-adapter v0.2.4 // indirect + github.com/api7/etcd-adapter v0.2.5 // indirect github.com/api7/gopkg v0.2.0 // indirect github.com/aws/aws-sdk-go v1.40.56 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/test/e2e/go.sum b/test/e2e/go.sum index 58d3d1aabe..11472b21e8 100644 --- a/test/e2e/go.sum +++ b/test/e2e/go.sum @@ -8,13 +8,14 @@ github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/api7/etcd-adapter v0.2.4 h1:VWdDPUJPai5IdxV5dwwZF9e7Ilw7sBWwaEeFzPO2fV4= -github.com/api7/etcd-adapter v0.2.4/go.mod h1:JoLtq4IxiIw6Z+k9eRGHL0CDyfRvnNXGI0skV0EsSE8= +github.com/api7/etcd-adapter v0.2.5 h1:uyXqDsIaI39I/1AT9/7iKSGU8icsKhpuOHFb17wkvJE= +github.com/api7/etcd-adapter v0.2.5/go.mod h1:JoLtq4IxiIw6Z+k9eRGHL0CDyfRvnNXGI0skV0EsSE8= github.com/api7/gopkg v0.2.0 h1:+5vw6Rt9IeEpJoL2JMZFDwGDhH4aaeUJize21/3Qdzc= github.com/api7/gopkg v0.2.0/go.mod h1:LlplmjGCrkcS3nyCYpTwkdLkuNlYRYAnI8XH1qwsICw= github.com/api7/terratest v1.0.0 h1:Grg0xcvNpSRZa7QzjqfTPR3lfiHk13IdIBUrfUrDmw4= github.com/api7/terratest v1.0.0/go.mod h1:JGeIGgLbxbG9/Oqm06z6YXVr76CfomdmLkV564qov+8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/aws/aws-sdk-go v1.40.56 h1:FM2yjR0UUYFzDTMx+mH9Vyw1k1EUUxsAFzk+BjkzANA= github.com/aws/aws-sdk-go v1.40.56/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -38,7 +39,9 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -57,6 +60,7 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= +github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= @@ -65,6 +69,7 @@ github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gavv/httpexpect/v2 v2.16.0 h1:Ty2favARiTYTOkCRZGX7ojXXjGyNAIohM1lZ3vqaEwI= @@ -91,6 +96,7 @@ github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogB github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -177,6 +183,7 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8= +github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= @@ -208,6 +215,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= 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= @@ -258,6 +266,7 @@ github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3Hig github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.9 h1:uH2qQXheeefCCkuBBSLi7jCiSmj3VRh2+Goq2N7Xxu0= github.com/pelletier/go-toml/v2 v2.0.9/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= @@ -284,6 +293,7 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= 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/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -350,14 +360,18 @@ github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FB github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= +github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/etcd/api/v3 v3.5.9 h1:4wSsluwyTbGGmyjJktOf3wFQoTBIURXHnq9n/G/JQHs= go.etcd.io/etcd/api/v3 v3.5.9/go.mod h1:uyAal843mC8uUVSLWz6eHa/d971iDGnCRpmKd2Z+X8k= go.etcd.io/etcd/client/pkg/v3 v3.5.9 h1:oidDC4+YEuSIQbsR94rY9gur91UPL6DnxDCIYd2IGsE= +go.etcd.io/etcd/client/pkg/v3 v3.5.9/go.mod h1:y+CzeSmkMpWN2Jyu1npecjB9BBnABxGM4pN8cGuJeL4= go.etcd.io/etcd/client/v3 v3.5.9 h1:r5xghnU7CwbUxD/fbUtRyJGaYNfDun8sp/gTr1hew6E= +go.etcd.io/etcd/client/v3 v3.5.9/go.mod h1:i/Eo5LrZ5IKqpbtpPDuaUnDOUv471oDg8cjQaUr2MbA= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= diff --git a/test/e2e/suite-chore/etcd_consistency.go b/test/e2e/suite-chore/etcd_consistency.go new file mode 100644 index 0000000000..27da0597f4 --- /dev/null +++ b/test/e2e/suite-chore/etcd_consistency.go @@ -0,0 +1,112 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package chore + +import ( + "fmt" + "net/http" + + "github.com/onsi/ginkgo/v2" + "github.com/stretchr/testify/assert" + + "github.com/apache/apisix-ingress-controller/test/e2e/scaffold" +) + +var _ = ginkgo.Describe("suite-chore: etcd revision", func() { + s := scaffold.NewScaffold(&scaffold.Options{ + EnableEtcdServer: true, + }) + ginkgo.It("etcd revision", func() { + ginkgo.By("apply route", func() { + backendSvc, backendSvcPort := s.DefaultHTTPBackend() + ar := fmt.Sprintf(` +apiVersion: apisix.apache.org/v2 +kind: ApisixRoute +metadata: + name: httpbin-route +spec: + http: + - name: rule1 + match: + hosts: + - httpbin.org + paths: + - /ip + backends: + - serviceName: %s + servicePort: %d +`, backendSvc, backendSvcPort[0]) + assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixResource(ar)) + assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(1), "checking number of routes") + assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(1), "checking number of upstreams") + + s.NewAPISIXClient().GET("/ip").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusOK) + }) + ginkgo.By("apply route again", func() { + backendSvc, backendSvcPort := s.DefaultHTTPBackend() + ar := fmt.Sprintf(` +apiVersion: apisix.apache.org/v2 +kind: ApisixRoute +metadata: + name: httpbin-route-2 +spec: + http: + - name: rule2 + match: + hosts: + - httpbin.org + paths: + - /headers + backends: + - serviceName: %s + servicePort: %d +`, backendSvc, backendSvcPort[0]) + assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixResource(ar)) + assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(2), "checking number of routes") + assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(1), "checking number of upstreams") + + s.NewAPISIXClient().GET("/headers").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusOK) + }) + + ginkgo.By("restart ingress controller") + s.RestartIngressControllerDeploy() + + ginkgo.By("apply route again and this should take effect", func() { + backendSvc, backendSvcPort := s.DefaultHTTPBackend() + ar := fmt.Sprintf(` +apiVersion: apisix.apache.org/v2 +kind: ApisixRoute +metadata: + name: httpbin-route-3 +spec: + http: + - name: rule3 + match: + hosts: + - httpbin.org + paths: + - /get + backends: + - serviceName: %s + servicePort: %d +`, backendSvc, backendSvcPort[0]) + assert.Nil(ginkgo.GinkgoT(), s.CreateVersionedApisixResource(ar)) + assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixRoutesCreated(3), "checking number of routes") + assert.Nil(ginkgo.GinkgoT(), s.EnsureNumApisixUpstreamsCreated(1), "checking number of upstreams") + + s.NewAPISIXClient().GET("/get").WithHeader("Host", "httpbin.org").Expect().Status(http.StatusOK) + }) + }) +})