Repository: argoproj/argo-rollouts (go)

Issue:
Doc.: Bad (old?) reference to "Analysis" instead of "AnalysisTemplate"
## Summary 

The page at https://argoproj.github.io/argo-rollouts/architecture refers to Analysis and AnalysisRun resources, and doesn't mention AnalysisTemplate. 

Shouldn't those references to "Analysis" say "AnalysisTemplate"?

## Diagnostics

> What version of Argo Rollouts are you running?

N/A

I'm looking at https://argoproj.github.io/argo-rollouts/architecture/#analysis-and-analysisrun as of 2021-05-28.

---
<!-- Issue Author: Don't delete this message to encourage other users to support your issue! -->
**Message from the maintainers**:

Impacted by this bug? Give it a 👍. We prioritize the issues with the most 👍.

Pull request description:
fix: better handle the deletion of ambassador canary mapping
Checklist:

* [x] Either (a) I've created an [enhancement proposal](https://github.com/argoproj/argo-rollouts/issues/new/choose) and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
* [x] The title of the PR is (a) [conventional](https://www.conventionalcommits.org/en/v1.0.0/), (b) states what changed, and (c) suffixes the related issues number. E.g. `"fix(controller): Updates such and such. Fixes #1234"`.  
* [x] I've signed my commits with [DCO](https://github.com/argoproj/argoproj)
* [x] I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
* [x] My builds are green. Try syncing with master if they are not. 
* [x] My organization is added to [USERS.md](https://github.com/argoproj/argo-rollouts/blob/master/USERS.md).

Patch:
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index ee68a8ca2..a52f71420 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -60,7 +60,7 @@ jobs:
             quay.io/argoproj/argo-rollouts
             ghcr.io/argoproj/argo-rollouts
           tags: |
-            type=semver,pattern={{version}}
+            type=semver,pattern=v{{version}},value=${{ github.event.inputs.tag }}
 
       - name: Docker meta (plugin)
         id: plugin-meta
@@ -70,7 +70,7 @@ jobs:
             quay.io/argoproj/kubectl-argo-rollouts
             ghcr.io/argoproj/kubectl-argo-rollouts
           tags: |
-            type=semver,pattern={{version}}
+            type=semver,pattern=v{{version}},value=${{ github.event.inputs.tag }}
 
       - name: Build and push (controller-image)
         uses: docker/build-push-action@v2
diff --git a/Makefile b/Makefile
index 0ec9e5b53..50d1d04fc 100644
--- a/Makefile
+++ b/Makefile
@@ -180,19 +180,21 @@ controller:
 
 .PHONY: plugin
 plugin: ui/dist
+	cp -r ui/dist/app/* server/static
 	CGO_ENABLED=0 go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME} ./cmd/kubectl-argo-rollouts
 
 ui/dist:
 	yarn --cwd ui install
 	yarn --cwd ui build
-	cp -r ui/dist/app/* server/static
 
 .PHONY: plugin-linux
 plugin-linux: ui/dist
+	cp -r ui/dist/app/* server/static
 	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME}-linux-amd64 ./cmd/kubectl-argo-rollouts
 
 .PHONY: plugin-darwin
 plugin-darwin: ui/dist
+	cp -r ui/dist/app/* server/static
 	CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME}-darwin-amd64 ./cmd/kubectl-argo-rollouts
 
 .PHONY: plugin-docs
diff --git a/rollout/trafficrouting/ambassador/ambassador.go b/rollout/trafficrouting/ambassador/ambassador.go
index 34c38f79d..8a1e1cb2b 100644
--- a/rollout/trafficrouting/ambassador/ambassador.go
+++ b/rollout/trafficrouting/ambassador/ambassador.go
@@ -7,6 +7,7 @@ import (
 	"strconv"
 	"strings"
 	"sync"
+	"time"
 
 	"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
 	"github.com/argoproj/argo-rollouts/utils/defaults"
@@ -150,8 +151,17 @@ func (r *Reconciler) handleCanaryMapping(ctx context.Context, baseMappingName st
 	}
 
 	if desiredWeight == 0 {
-		r.Log.Infof("deleting canary mapping %q", canaryMapping.GetName())
-		return r.deleteCanaryMapping(ctx, canaryMapping, desiredWeight, r.Client)
+		go func() {
+			// The deletion of the canary mapping needs to happen moments after
+			// updating the weight to zero to prevent traffic to reach the older
+			// version at the end of the rollout
+			time.Sleep(5 * time.Second)
+			r.Log.Infof("deleting canary mapping %q", canaryMapping.GetName())
+			err := r.deleteCanaryMapping(ctx, canaryMapping, desiredWeight, r.Client)
+			if err != nil {
+				r.Log.Errorf("error deleting canary mapping: %s", err)
+			}
+		}()
 	}
 
 	r.Log.Infof("updating canary mapping %q weight to %d", canaryMapping.GetName(), desiredWeight)


Test patch:
diff --git a/rollout/trafficrouting/ambassador/ambassador_test.go b/rollout/trafficrouting/ambassador/ambassador_test.go
index 6f653db60..f580b0123 100644
--- a/rollout/trafficrouting/ambassador/ambassador_test.go
+++ b/rollout/trafficrouting/ambassador/ambassador_test.go
@@ -310,8 +310,8 @@ func TestReconciler_SetWeight(t *testing.T) {
 			assert.Equal(t, 1, len(f.fakeClient.getInvokations))
 			assert.Equal(t, "myapp-mapping-canary", f.fakeClient.getInvokations[0].name)
 			assert.Equal(t, 0, len(f.fakeClient.createInvokations))
-			assert.Equal(t, 0, len(f.fakeClient.updateInvokations))
-			assert.Equal(t, 1, len(f.fakeClient.deleteInvokations))
+			assert.Equal(t, 1, len(f.fakeClient.updateInvokations))
+			assert.Equal(t, 0, len(f.fakeClient.deleteInvokations))
 		})
 		t.Run("will return error if base mapping defines the weight", func(t *testing.T) {
 			// given