fix(xds): set lastSnapshot after initial delta push #360
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Conformance | |
| on: | |
| push: | |
| branches: [main] | |
| schedule: | |
| - cron: "0 2 * * *" | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| packages: read | |
| env: | |
| CLUSTER_NAME: conformance | |
| GATEWAY_API_VERSION: v1.5.1 | |
| CONTROLPLANE_IMAGE: ghcr.io/nantian-gw/nantian-controlplane:ci-${{ github.sha }} | |
| jobs: | |
| gateway-api: | |
| name: Gateway API Conformance | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 75 | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 | |
| - name: Resolve dependency images | |
| run: | | |
| source scripts/ci/dependency-images.sh | |
| { | |
| echo "DATAPLANE_IMAGE=${DATAPLANE_IMAGE:-$DEFAULT_DATAPLANE_IMAGE}" | |
| echo "DASHBOARD_IMAGE=${DASHBOARD_IMAGE:-$DEFAULT_DASHBOARD_IMAGE}" | |
| } >>"${GITHUB_ENV}" | |
| - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 | |
| with: | |
| go-version-file: go.mod | |
| cache-dependency-path: go.sum | |
| - name: Install Kind tooling | |
| run: scripts/ci/install-kind-tools.sh | |
| - name: Create kind cluster | |
| run: scripts/ci/create-kind-cluster.sh | |
| - name: Install Gateway API CRDs | |
| run: scripts/ci/install-gateway-api-crds.sh | |
| - name: Build current control-plane image | |
| run: scripts/ci/build-controlplane-image.sh | |
| - name: Load images into kind | |
| run: scripts/ci/load-kind-images.sh | |
| - name: Deploy Nantian Gateway | |
| run: scripts/ci/deploy-kind-conformance.sh | |
| - name: Record image versions | |
| run: | | |
| echo "=== Images under test ===" | |
| kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .spec.containers[] | " \(.name): \(.image)"' | |
| echo "=== Image digests ===" | |
| kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .status.containerStatuses[] | " \(.name): \(.imageID)"' | |
| - name: Run conformance tests | |
| id: conformance | |
| run: | | |
| mkdir -p dist/conformance | |
| report_path="${GITHUB_WORKSPACE}/dist/conformance/report.yaml" | |
| apply_file="$(go env GOMODCACHE)/sigs.k8s.io/gateway-api/conformance@v1.5.1/utils/kubernetes/apply.go" | |
| chmod u+w "$apply_file" | |
| python3 - "$apply_file" << 'PYEOF' | |
| import sys | |
| path = sys.argv[1] | |
| content = open(path).read() | |
| old = '\t\tuObj.SetResourceVersion(fetchedObj.GetResourceVersion())\n\t\ttlog.Logf(t, "Updating %s %s", uObj.GetName(), uObj.GetKind())\n\t\terr = c.Update(ctx, uObj)' | |
| new = '''\t\tuObj.SetResourceVersion(fetchedObj.GetResourceVersion()) | |
| \t\ttlog.Logf(t, "Updating %s %s", uObj.GetName(), uObj.GetKind()) | |
| \t\tfor i := 0; i < 5; i++ { | |
| \t\t\tif i > 0 { | |
| \t\t\t\ttime.Sleep(time.Duration(1<<i) * 100 * time.Millisecond) | |
| \t\t\t\tlatest := &unstructured.Unstructured{} | |
| \t\t\t\tlatest.SetGroupVersionKind(uObj.GroupVersionKind()) | |
| \t\t\t\tif getErr := c.Get(ctx, client.ObjectKeyFromObject(uObj), latest); getErr != nil { | |
| \t\t\t\t\terr = getErr | |
| \t\t\t\t\tbreak | |
| \t\t\t\t} | |
| \t\t\t\tuObj.SetResourceVersion(latest.GetResourceVersion()) | |
| \t\t\t} | |
| \t\t\terr = c.Update(ctx, uObj) | |
| \t\t\tif err == nil || !apierrors.IsConflict(err) { | |
| \t\t\t\tbreak | |
| \t\t\t} | |
| \t\t}''' | |
| content = content.replace(old, new) | |
| # Add time import | |
| content = content.replace( | |
| '"testing"', | |
| '"testing"\n\t"time"' | |
| ) | |
| open(path, 'w').write(content) | |
| print("Patched apply.go with conflict retry") | |
| PYEOF | |
| set +e | |
| go test -tags=conformance -count=1 -v -timeout 30m ./conformance/ \ | |
| -args \ | |
| -gateway-class nantian-gw \ | |
| -report-output "$report_path" \ | |
| -organization "Nantian Gateway" \ | |
| -project "Nantian Gateway" \ | |
| -url "https://github.com/nantian-gw/gateway" \ | |
| -version "${GITHUB_SHA}" \ | |
| -contact "https://github.com/nantian-gw/gateway/issues" 2>&1 \ | |
| | tee dist/conformance/run.log | |
| status=${PIPESTATUS[0]} | |
| echo "exit_code=${status}" >>"${GITHUB_OUTPUT}" | |
| exit "${status}" | |
| - name: Collect diagnostics on failure | |
| if: failure() | |
| run: ARTIFACT_DIR=tmp/conformance-diagnostics scripts/ci/collect-kind-diagnostics.sh | |
| - name: Upload conformance artifacts | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: conformance-results | |
| path: | | |
| dist/conformance/ | |
| tmp/conformance-diagnostics/ | |
| if-no-files-found: warn | |
| - name: Cleanup | |
| if: always() | |
| run: command -v kind >/dev/null 2>&1 && kind delete cluster --name "$CLUSTER_NAME" || true | |
| gateway-api-all-features: | |
| name: Gateway API Conformance (All Features) | |
| if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 75 | |
| env: | |
| CLUSTER_NAME: conformance-all-features | |
| CONFORMANCE_EXPERIMENTAL: "true" | |
| ALL_FEATURES: "true" | |
| steps: | |
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 | |
| - name: Resolve dependency images | |
| run: | | |
| source scripts/ci/dependency-images.sh | |
| { | |
| echo "DATAPLANE_IMAGE=${DATAPLANE_IMAGE:-$DEFAULT_DATAPLANE_IMAGE}" | |
| echo "DASHBOARD_IMAGE=${DASHBOARD_IMAGE:-$DEFAULT_DASHBOARD_IMAGE}" | |
| } >>"${GITHUB_ENV}" | |
| - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 | |
| with: | |
| go-version-file: go.mod | |
| cache-dependency-path: go.sum | |
| - name: Install Kind tooling | |
| run: scripts/ci/install-kind-tools.sh | |
| - name: Create kind cluster | |
| run: scripts/ci/create-kind-cluster.sh | |
| - name: Install Gateway API CRDs | |
| run: scripts/ci/install-gateway-api-crds.sh | |
| - name: Build current control-plane image | |
| run: scripts/ci/build-controlplane-image.sh | |
| - name: Load images into kind | |
| run: scripts/ci/load-kind-images.sh | |
| - name: Deploy Nantian Gateway | |
| run: scripts/ci/deploy-kind-conformance.sh | |
| - name: Record image versions | |
| run: | | |
| echo "=== Images under test ===" | |
| kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .spec.containers[] | " \(.name): \(.image)"' | |
| echo "=== Image digests ===" | |
| kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .status.containerStatuses[] | " \(.name): \(.imageID)"' | |
| - name: Run conformance tests | |
| id: conformance | |
| run: | | |
| mkdir -p dist/conformance | |
| report_path="${GITHUB_WORKSPACE}/dist/conformance/report.yaml" | |
| apply_file="$(go env GOMODCACHE)/sigs.k8s.io/gateway-api/conformance@v1.5.1/utils/kubernetes/apply.go" | |
| chmod u+w "$apply_file" | |
| python3 - "$apply_file" << 'PYEOF' | |
| import sys | |
| path = sys.argv[1] | |
| content = open(path).read() | |
| old = '\t\tuObj.SetResourceVersion(fetchedObj.GetResourceVersion())\n\t\ttlog.Logf(t, "Updating %s %s", uObj.GetName(), uObj.GetKind())\n\t\terr = c.Update(ctx, uObj)' | |
| new = '''\t\tuObj.SetResourceVersion(fetchedObj.GetResourceVersion()) | |
| \t\ttlog.Logf(t, "Updating %s %s", uObj.GetName(), uObj.GetKind()) | |
| \t\tfor i := 0; i < 5; i++ { | |
| \t\t\tif i > 0 { | |
| \t\t\t\ttime.Sleep(time.Duration(1<<i) * 100 * time.Millisecond) | |
| \t\t\t\tlatest := &unstructured.Unstructured{} | |
| \t\t\t\tlatest.SetGroupVersionKind(uObj.GroupVersionKind()) | |
| \t\t\t\tif getErr := c.Get(ctx, client.ObjectKeyFromObject(uObj), latest); getErr != nil { | |
| \t\t\t\t\terr = getErr | |
| \t\t\t\t\tbreak | |
| \t\t\t\t} | |
| \t\t\t\tuObj.SetResourceVersion(latest.GetResourceVersion()) | |
| \t\t\t} | |
| \t\t\terr = c.Update(ctx, uObj) | |
| \t\t\tif err == nil || !apierrors.IsConflict(err) { | |
| \t\t\t\tbreak | |
| \t\t\t} | |
| \t\t}''' | |
| content = content.replace(old, new) | |
| content = content.replace( | |
| '"testing"', | |
| '"testing"\n\t"time"' | |
| ) | |
| open(path, 'w').write(content) | |
| print("Patched apply.go with conflict retry") | |
| PYEOF | |
| set +e | |
| go test -tags=conformance -count=1 -v -timeout 30m ./conformance/ \ | |
| -args \ | |
| -gateway-class nantian-gw \ | |
| -report-output "$report_path" \ | |
| -organization "Nantian Gateway" \ | |
| -project "Nantian Gateway" \ | |
| -url "https://github.com/nantian-gw/gateway" \ | |
| -version "${GITHUB_SHA}" \ | |
| -contact "https://github.com/nantian-gw/gateway/issues" 2>&1 \ | |
| | tee dist/conformance/run.log | |
| status=${PIPESTATUS[0]} | |
| echo "exit_code=${status}" >>"${GITHUB_OUTPUT}" | |
| exit "${status}" | |
| - name: Collect diagnostics on failure | |
| if: failure() | |
| run: ARTIFACT_DIR=tmp/conformance-diagnostics scripts/ci/collect-kind-diagnostics.sh | |
| - name: Upload conformance artifacts | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a | |
| with: | |
| name: conformance-all-features-results | |
| path: | | |
| dist/conformance/ | |
| tmp/conformance-diagnostics/ | |
| if-no-files-found: warn | |
| - name: Cleanup | |
| if: always() | |
| run: command -v kind >/dev/null 2>&1 && kind delete cluster --name "$CLUSTER_NAME" || true |