From e58eaa9f410f6f1d594520a471c191e06e191022 Mon Sep 17 00:00:00 2001 From: Charlie Stanley Date: Thu, 12 Nov 2020 16:25:39 -0800 Subject: [PATCH 1/5] All any 2xx status code for success on standalone publish (#510) (#511) --- pkg/standalone/publish.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/standalone/publish.go b/pkg/standalone/publish.go index 7506c8581..4406a8da5 100644 --- a/pkg/standalone/publish.go +++ b/pkg/standalone/publish.go @@ -46,7 +46,7 @@ func (s *Standalone) Publish(topic, payload, pubsubName string) error { return err } defer r.Body.Close() - if r.StatusCode != http.StatusOK { + if r.StatusCode >= 300 || r.StatusCode < 200 { return fmt.Errorf("unexpected status code %d on publishing to %s in %s", r.StatusCode, topic, pubsubName) } From 3c0ec02a168a406f68c7dac98f104f67b88d49a0 Mon Sep 17 00:00:00 2001 From: Van Tian Date: Sat, 14 Nov 2020 02:00:01 +0800 Subject: [PATCH 2/5] Support path that contains spaces (#514) Executing Install.ps1 will fail when DaprRoot contains spaces --- install/install.ps1 | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/install/install.ps1 b/install/install.ps1 index ec285ada6..093f79114 100755 --- a/install/install.ps1 +++ b/install/install.ps1 @@ -8,23 +8,27 @@ param ( $ErrorActionPreference = 'stop' +#Escape space of DapRoot path +$DaprRoot = $DaprRoot -replace ' ', '` ' + # Constants $DaprCliFileName = "dapr.exe" $DaprCliFilePath = "${DaprRoot}\${DaprCliFileName}" # GitHub Org and repo hosting Dapr CLI -$GitHubOrg="dapr" -$GitHubRepo="cli" +$GitHubOrg = "dapr" +$GitHubRepo = "cli" # Set Github request authentication for basic authentication. if ($Env:GITHUB_USER) { $basicAuth = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($Env:GITHUB_USER + ":" + $Env:GITHUB_TOKEN)); - $githubHeader = @{"Authorization"="Basic $basicAuth"} -} else { + $githubHeader = @{"Authorization" = "Basic $basicAuth" } +} +else { $githubHeader = @{} } -if((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') { +if ((Get-ExecutionPolicy) -gt 'RemoteSigned' -or (Get-ExecutionPolicy) -eq 'ByPass') { Write-Output "PowerShell requires an execution policy of 'RemoteSigned'." Write-Output "To make this change please run:" Write-Output "'Set-ExecutionPolicy RemoteSigned -scope CurrentUser'" @@ -39,7 +43,8 @@ if (Test-Path $DaprCliFilePath -PathType Leaf) { Write-Warning "Dapr is detected - $DaprCliFilePath" Invoke-Expression "$DaprCliFilePath --version" Write-Output "Reinstalling Dapr..." -} else { +} +else { Write-Output "Installing Dapr..." } @@ -57,7 +62,7 @@ if ($releases.Count -eq 0) { } # Filter windows binary and download archive -$windowsAsset = $releases | Where-Object { $_.tag_name -notlike "*rc*"} | Select-Object -First 1 | Select-Object -ExpandProperty assets | Where-Object { $_.name -Like "*windows_amd64.zip" } +$windowsAsset = $releases | Where-Object { $_.tag_name -notlike "*rc*" } | Select-Object -First 1 | Select-Object -ExpandProperty assets | Where-Object { $_.name -Like "*windows_amd64.zip" } if (!$windowsAsset) { throw "Cannot find the windows Dapr CLI binary" } @@ -88,9 +93,10 @@ Remove-Item $zipFilePath -Force # Add DaprRoot directory to User Path environment variable Write-Output "Try to add $DaprRoot to User Path Environment variable..." $UserPathEnvionmentVar = [Environment]::GetEnvironmentVariable("PATH", "User") -if($UserPathEnvionmentVar -like '*dapr*') { +if ($UserPathEnvionmentVar -like '*dapr*') { Write-Output "Skipping to add $DaprRoot to User Path - $UserPathEnvionmentVar" -} else { +} +else { [System.Environment]::SetEnvironmentVariable("PATH", $UserPathEnvionmentVar + ";$DaprRoot", "User") $UserPathEnvionmentVar = [Environment]::GetEnvironmentVariable("PATH", "User") Write-Output "Added $DaprRoot to User Path - $UserPathEnvionmentVar" From 43a94bd4770d89aa47a11deca584e66f5679894d Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Fri, 13 Nov 2020 10:35:20 -0800 Subject: [PATCH 3/5] Fix dapr status -k for new placement (#512) * fix ha mode for placement * support backward compat * go mod tidy Co-authored-by: Yaron Schneider --- go.mod | 1 - go.sum | 18 +-- pkg/kubernetes/status.go | 9 +- pkg/kubernetes/status_test.go | 204 ++++++++++++++++++---------------- 4 files changed, 123 insertions(+), 109 deletions(-) diff --git a/go.mod b/go.mod index 991751a79..466fa192a 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,6 @@ require ( k8s.io/client-go v0.17.2 k8s.io/helm v2.16.10+incompatible rsc.io/letsencrypt v0.0.3 // indirect - sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874 // indirect ) replace ( diff --git a/go.sum b/go.sum index 62a131574..2eb814c1d 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,7 @@ github.com/Azure/go-autorest v13.3.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSW github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest v0.9.2/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest v0.9.3/go.mod h1:GsRuLYvwzLjjjRoWEIyMUaYq8GNUx2nRB378IPt/1p0= -github.com/Azure/go-autorest/autorest v0.10.0 h1:mvdtztBqcL8se7MdrUweNieTNi4kfNG6GOJuurQJpuY= -github.com/Azure/go-autorest/autorest v0.10.0/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= +github.com/Azure/go-autorest/autorest v0.10.2 h1:NuSF3gXetiHyUbVdneJMEVyPUYAe5wh+aN08JYAf1tI= github.com/Azure/go-autorest/autorest v0.10.2/go.mod h1:/FALq9T/kS7b5J5qsQ+RSTUdAmGFqi0vUdVNNx8q630= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/adal v0.6.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= @@ -224,11 +223,8 @@ github.com/cyphar/filepath-securejoin v0.2.2 h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrP github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/dancannon/gorethink v4.0.0+incompatible/go.mod h1:BLvkat9KmZc1efyYwhz3WnybhRZtgF1K929FD8z1avU= github.com/dapr/components-contrib v0.0.0-20200219164914-5b75f4d0fbc6/go.mod h1:AZi8IGs8LFdywJg/YGwDs7MAxJkvGa8RgHN4NoJSKt0= -github.com/dapr/components-contrib v0.0.0-20200430212123-b647397b2c81/go.mod h1:D+yWYWWStM7YQzQHhBs2+7/6RyqNHFKnyujbsPzfsnI= github.com/dapr/components-contrib v0.4.1/go.mod h1:PB89pXKGk+FVWa/6WSzgx5T5w5aubHlXzCc77+RUOb8= github.com/dapr/dapr v0.4.1-0.20200228055659-71892bc0111e/go.mod h1:c60DJ9TdSdpbLjgqP55A5u4ZCYChFwa9UGYIXd9pmm4= -github.com/dapr/dapr v0.7.1 h1:Aojq7EsiXhYKzvpQlXxe1R1/mluT+OCzKHrKaxrR8kI= -github.com/dapr/dapr v0.7.1/go.mod h1:aFq3/2Ks7wHY7TE6GN3wR2BCjiw7y3GcP1LrJrniftw= github.com/dapr/dapr v0.11.3 h1:FYqbIcGpH1iCOs8a7f0sOEAXRrY6Iywqc4FS3tylsFY= github.com/dapr/dapr v0.11.3/go.mod h1:z00qEei04rRwbFnovVQVyYbbRVL4FWpWtmaXAjjZOyI= github.com/dapr/go-sdk v0.0.0-20200121181907-48249cda2fad/go.mod h1:yeOIFBz6+BigHpk4ASJbgQDVjQ8+00oCWrFyOAFdob8= @@ -301,7 +297,6 @@ github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwC github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4= github.com/fasthttp-contrib/sessions v0.0.0-20160905201309-74f6ac73d5d5/go.mod h1:MQXNGeXkpojWTxbN7vXoE3f7EmlA11MlJbsrJpVBINA= github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= -github.com/fasthttp/router v1.0.4/go.mod h1:3ZGZormG7E+VbnYeToF+zmcF4oBGcAKOD8a8XL+fOZo= github.com/fasthttp/router v1.3.1/go.mod h1:athTSKMdel0Qhh3W4nB8qn+EPYuyj6YZMUo6ZcXWTgc= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= @@ -606,7 +601,6 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.9.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= @@ -744,12 +738,14 @@ github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.2 h1:uqH7bpe+ERSiDa34FDOF7RikN6RzXgduUF8yarlZp94= github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v0.0.0-20190113212917-5533ce8a0da3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34= github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= github.com/open-policy-agent/opa v0.23.2/go.mod h1:rrwxoT/b011T0cyj+gg2VvxqTtn6N3gp/jzmr3fjW44= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= @@ -851,7 +847,6 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/savsgio/gotils v0.0.0-20200413113635-8c468ce75cca/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8= github.com/savsgio/gotils v0.0.0-20200616100644-13ff1fd2c28c/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sendgrid/rest v2.4.1+incompatible/go.mod h1:kXX7q3jZtJXK5c5qK83bSGMdV6tsOE70KbHoqJls4lE= @@ -914,6 +909,7 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= @@ -932,7 +928,6 @@ github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6Kllzaw github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.6.0 h1:uWF8lgKmeaIewWVPwi4GRq2P6+R46IgYZdxWtM+GtEY= github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= -github.com/valyala/fasthttp v1.12.0/go.mod h1:229t1eWu9UXTPmoUkbpN/fctKPBY4IJoFXQnxHGXy6E= github.com/valyala/fasthttp v1.16.0/go.mod h1:YOKImeEosDdBPnxc0gy7INqi3m1zK6A+xl6TwOBhHCA= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= @@ -1077,8 +1072,6 @@ golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1356,8 +1349,6 @@ k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c h1:/KUFqjjqAcY4Us6luF5RDNZ16KJtb49HfR3ZHB9qYXM= -k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29 h1:NeQXVJ2XFSkRoPzRo8AId01ZER+j8oV4SZADT4iBOXQ= k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29/go.mod h1:F+5wygcW0wmRTnM3cOgIqGivxkwSWIWT5YdsDbeAOaU= k8s.io/kubectl v0.17.2 h1:QZR8Q6lWiVRjwKslekdbN5WPMp53dS/17j5e+oi5XVU= @@ -1387,7 +1378,6 @@ sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5 sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18= sigs.k8s.io/structured-merge-diff/v2 v2.0.1/go.mod h1:Wb7vfKAodbKgf6tn1Kl0VvGj7mRH6DGaRcixXEJXTsE= -sigs.k8s.io/structured-merge-diff/v3 v3.0.0-20200116222232-67a7b8c61874/go.mod h1:PlARxl6Hbt/+BC80dRLi1qAmnMqwqDg62YvvVkZjemw= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= diff --git a/pkg/kubernetes/status.go b/pkg/kubernetes/status.go index 38f21153f..1fac2cf37 100644 --- a/pkg/kubernetes/status.go +++ b/pkg/kubernetes/status.go @@ -18,7 +18,14 @@ import ( k8s "k8s.io/client-go/kubernetes" ) -var controlPlaneLabels = []string{"dapr-operator", "dapr-sentry", "dapr-placement", "dapr-sidecar-injector", "dapr-dashboard"} +var controlPlaneLabels = []string{ + "dapr-operator", + "dapr-sentry", + "dapr-placement", // TODO: This is for the backward compatibility. Remove this after 1.0.0 GA release. + "dapr-placement-server", + "dapr-sidecar-injector", + "dapr-dashboard", +} type StatusClient struct { client k8s.Interface diff --git a/pkg/kubernetes/status_test.go b/pkg/kubernetes/status_test.go index f3629d2ee..647460db5 100644 --- a/pkg/kubernetes/status_test.go +++ b/pkg/kubernetes/status_test.go @@ -23,6 +23,37 @@ func newTestSimpleK8s(objects ...runtime.Object) *StatusClient { return &client } +func newDaprControlPlanePod(name string, appName string, creationTime time.Time, state v1.ContainerState, ready bool) *v1.Pod { + return &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: "dapr-system", + Annotations: map[string]string{}, + Labels: map[string]string{ + "app": appName, + }, + CreationTimestamp: metav1.Time{ + Time: creationTime, + }, + }, + Status: v1.PodStatus{ + ContainerStatuses: []v1.ContainerStatus{ + { + State: state, + Ready: ready, + }, + }, + }, + Spec: v1.PodSpec{ + Containers: []v1.Container{ + { + Image: name + ":0.0.1", + }, + }, + }, + } +} + func TestStatus(t *testing.T) { t.Run("empty status. dapr not init", func(t *testing.T) { k8s := newTestSimpleK8s() @@ -32,39 +63,17 @@ func TestStatus(t *testing.T) { } assert.Equal(t, 0, len(status), "Expected status to be empty list") }) + t.Run("one status waiting", func(t *testing.T) { - k8s := newTestSimpleK8s((&v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "dapr-dashboard", - Namespace: "dapr-system", - Annotations: map[string]string{}, - Labels: map[string]string{ - "app": "dapr-dashboard", - }, - CreationTimestamp: metav1.Time{ - Time: time.Now(), - }, - }, - Status: v1.PodStatus{ - ContainerStatuses: []v1.ContainerStatus{ - { - State: v1.ContainerState{ - Waiting: &v1.ContainerStateWaiting{ - Reason: "test", - Message: "test", - }, - }, - }, - }, - }, - Spec: v1.PodSpec{ - Containers: []v1.Container{ - { - Image: "dapr-dashboard:0.0.1", - }, + k8s := newTestSimpleK8s(newDaprControlPlanePod( + "dapr-dashboard-58877dbc9d-n8qg2", "dapr-dashboard", + time.Now(), + v1.ContainerState{ + Waiting: &v1.ContainerStateWaiting{ + Reason: "test", + Message: "test", }, - }, - })) + }, false)) status, err := k8s.Status() assert.Nil(t, err, "status should not raise an error") assert.Equal(t, 1, len(status), "Expected status to be empty list") @@ -76,42 +85,19 @@ func TestStatus(t *testing.T) { assert.Equal(t, "False", stat.Healthy, "expected health to match") assert.True(t, strings.HasPrefix(stat.Status, "Waiting"), "expected waiting status") }) + t.Run("one status running", func(t *testing.T) { testTime := time.Now() - k8s := newTestSimpleK8s((&v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "dapr-dashboard", - Namespace: "dapr-system", - Annotations: map[string]string{}, - Labels: map[string]string{ - "app": "dapr-dashboard", - }, - CreationTimestamp: metav1.Time{ - Time: testTime.Add(time.Duration(-20) * time.Minute), - }, - }, - Status: v1.PodStatus{ - ContainerStatuses: []v1.ContainerStatus{ - { - State: v1.ContainerState{ - Running: &v1.ContainerStateRunning{ - StartedAt: metav1.Time{ - Time: testTime.Add(time.Duration(-19) * time.Minute), - }, - }, - }, - Ready: true, - }, - }, - }, - Spec: v1.PodSpec{ - Containers: []v1.Container{ - { - Image: "dapr-dashboard:0.0.1", + k8s := newTestSimpleK8s(newDaprControlPlanePod( + "dapr-dashboard-58877dbc9d-n8qg2", "dapr-dashboard", + testTime.Add(time.Duration(-20)*time.Minute), + v1.ContainerState{ + Running: &v1.ContainerStateRunning{ + StartedAt: metav1.Time{ + Time: testTime.Add(time.Duration(-19) * time.Minute), }, }, - }, - })) + }, true)) status, err := k8s.Status() assert.Nil(t, err, "status should not raise an error") assert.Equal(t, 1, len(status), "Expected status to be empty list") @@ -124,39 +110,19 @@ func TestStatus(t *testing.T) { assert.Equal(t, "True", stat.Healthy, "expected health to match") assert.Equal(t, stat.Status, "Running", "expected running status") }) + t.Run("one status terminated", func(t *testing.T) { testTime := time.Now() - k8s := newTestSimpleK8s((&v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "dapr-dashboard", - Namespace: "dapr-system", - Annotations: map[string]string{}, - Labels: map[string]string{ - "app": "dapr-dashboard", - }, - CreationTimestamp: metav1.Time{ - Time: testTime.Add(time.Duration(-20) * time.Minute), - }, - }, - Status: v1.PodStatus{ - ContainerStatuses: []v1.ContainerStatus{ - { - State: v1.ContainerState{ - Terminated: &v1.ContainerStateTerminated{ - ExitCode: 1, - }, - }, - }, - }, - }, - Spec: v1.PodSpec{ - Containers: []v1.Container{ - { - Image: "dapr-dashboard:0.0.1", - }, + + k8s := newTestSimpleK8s(newDaprControlPlanePod( + "dapr-dashboard-58877dbc9d-n8qg2", "dapr-dashboard", + testTime.Add(time.Duration(-20)*time.Minute), + v1.ContainerState{ + Terminated: &v1.ContainerStateTerminated{ + ExitCode: 1, }, - }, - })) + }, false)) + status, err := k8s.Status() assert.Nil(t, err, "status should not raise an error") assert.Equal(t, 1, len(status), "Expected status to be empty list") @@ -169,6 +135,7 @@ func TestStatus(t *testing.T) { assert.Equal(t, "False", stat.Healthy, "expected health to match") assert.Equal(t, stat.Status, "Terminated", "expected terminated status") }) + t.Run("one status empty client", func(t *testing.T) { k8s := &StatusClient{} status, err := k8s.Status() @@ -177,3 +144,54 @@ func TestStatus(t *testing.T) { assert.Nil(t, status, "expected nil for status") }) } + +func TestControlPlaneServices(t *testing.T) { + controlPlaneServices := []struct { + name string + appName string + }{ + {"dapr-dashboard-58877dbc9d-n8qg2", "dapr-dashboard"}, + {"dapr-operator-67d7d7bb6c-7h96c", "dapr-operator"}, + {"dapr-operator-67d7d7bb6c-2h96d", "dapr-operator"}, + {"dapr-operator-67d7d7bb6c-3h96c", "dapr-operator"}, + {"dapr-placement-server-0", "dapr-placement-server"}, + {"dapr-placement-server-1", "dapr-placement-server"}, + {"dapr-placement-server-2", "dapr-placement-server"}, + {"dapr-sentry-647759cd46-9ptks", "dapr-sentry"}, + {"dapr-sentry-647759cd46-aptks", "dapr-sentry"}, + {"dapr-sentry-647759cd46-bptks", "dapr-sentry"}, + {"dapr-sidecar-injector-74648c9dcb-5bsmn", "dapr-sidecar-injector"}, + {"dapr-sidecar-injector-74648c9dcb-6bsmn", "dapr-sidecar-injector"}, + {"dapr-sidecar-injector-74648c9dcb-7bsmn", "dapr-sidecar-injector"}, + } + + expectedReplicas := map[string]int{} + + runtimeObj := make([]runtime.Object, len(controlPlaneServices)) + for i, s := range controlPlaneServices { + testTime := time.Now() + runtimeObj[i] = newDaprControlPlanePod( + s.name, s.appName, + testTime.Add(time.Duration(-20)*time.Minute), + v1.ContainerState{ + Running: &v1.ContainerStateRunning{ + StartedAt: metav1.Time{ + Time: testTime.Add(time.Duration(-19) * time.Minute), + }, + }, + }, true) + expectedReplicas[s.appName]++ + } + + k8s := newTestSimpleK8s(runtimeObj...) + status, err := k8s.Status() + assert.Nil(t, err, "status should not raise an error") + + assert.Equal(t, len(expectedReplicas), len(status), "Expected status to be empty list") + + for _, stat := range status { + replicas, ok := expectedReplicas[stat.Name] + assert.True(t, ok) + assert.Equal(t, replicas, stat.Replicas, "expected replicas to match") + } +} From 1f0c0f34f561c877b930380c8bb7692cef61869e Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Fri, 13 Nov 2020 14:31:18 -0800 Subject: [PATCH 4/5] Add release note to GH proposal template (#517) Add release note to GH proposal template --- .github/ISSUE_TEMPLATE/proposal.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/proposal.md b/.github/ISSUE_TEMPLATE/proposal.md index 3d6cb17eb..4b080ec33 100644 --- a/.github/ISSUE_TEMPLATE/proposal.md +++ b/.github/ISSUE_TEMPLATE/proposal.md @@ -7,3 +7,15 @@ assignees: '' --- ## Describe the proposal + + +## Release Note + + + + + + + + +RELEASE NOTE: From a60221e96406a145ab22e454eec6642961725f5c Mon Sep 17 00:00:00 2001 From: Young Bu Park Date: Mon, 16 Nov 2020 16:10:01 -0800 Subject: [PATCH 5/5] Support version param in one liner script (#520) * Support version params * revert * fix * wip * fix windows command line * fix * Update README.md --- install/README.md | 24 ++++++++++++++++++++++++ install/install.ps1 | 21 +++++++++++++++------ install/install.sh | 11 ++++++++++- 3 files changed, 49 insertions(+), 7 deletions(-) diff --git a/install/README.md b/install/README.md index 8cb95ce79..46524327c 100644 --- a/install/README.md +++ b/install/README.md @@ -2,18 +2,42 @@ ## Windows +### Get the latest stable version + ``` powershell -Command "iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1 | iex" ``` +### Get the specific version + +``` +powershell -Command "$script=iwr -useb https://raw.githubusercontent.com/dapr/cli/master/install/install.ps1; $block=[ScriptBlock]::Create($script); invoke-command -ScriptBlock $block -ArgumentList " +``` + ## MacOS +### Get the latest stable version + ``` curl -fsSL https://raw.githubusercontent.com/dapr/cli/master/install/install.sh | /bin/bash ``` +### Get the specific version + +``` +curl -fsSL https://raw.githubusercontent.com/dapr/cli/master/install/install.sh | /bin/bash -s +``` + ## Linux +### Get the latest stable version + ``` wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash ``` + +### Get the specific version + +``` +wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash -s +``` diff --git a/install/install.ps1 b/install/install.ps1 index 093f79114..3d5a41ce1 100755 --- a/install/install.ps1 +++ b/install/install.ps1 @@ -3,9 +3,11 @@ # Licensed under the MIT License. # ------------------------------------------------------------ param ( + [string]$Version, [string]$DaprRoot = "c:\dapr" ) +Write-Output "" $ErrorActionPreference = 'stop' #Escape space of DapRoot path @@ -62,16 +64,23 @@ if ($releases.Count -eq 0) { } # Filter windows binary and download archive -$windowsAsset = $releases | Where-Object { $_.tag_name -notlike "*rc*" } | Select-Object -First 1 | Select-Object -ExpandProperty assets | Where-Object { $_.name -Like "*windows_amd64.zip" } -if (!$windowsAsset) { - throw "Cannot find the windows Dapr CLI binary" +if (!$Version) { + $windowsAsset = $releases | Where-Object { $_.tag_name -notlike "*rc*" } | Select-Object -First 1 | Select-Object -ExpandProperty assets | Where-Object { $_.name -Like "*windows_amd64.zip" } + if (!$windowsAsset) { + throw "Cannot find the windows Dapr CLI binary" + } + $zipFileUrl = $windowsAsset.url + $assetName = $windowsAsset.name +} else { + $assetName = "dapr_windows_amd64.zip" + $zipFileUrl = "https://github.com/${GitHubOrg}/${GitHubRepo}/releases/download/v${Version}/${assetName}" } -$zipFilePath = $DaprRoot + "\" + $windowsAsset.name -Write-Output "Downloading $zipFilePath ..." +$zipFilePath = $DaprRoot + "\" + $assetName +Write-Output "Downloading $zipFileUrl ..." $githubHeader.Accept = "application/octet-stream" -Invoke-WebRequest -Headers $githubHeader -Uri $windowsAsset.url -OutFile $zipFilePath +Invoke-WebRequest -Headers $githubHeader -Uri $zipFileUrl -OutFile $zipFilePath if (!(Test-Path $zipFilePath -PathType Leaf)) { throw "Failed to download Dapr Cli binary - $zipFilePath" } diff --git a/install/install.sh b/install/install.sh index 59c9d526e..4fbcadba9 100755 --- a/install/install.sh +++ b/install/install.sh @@ -174,7 +174,16 @@ verifySupported checkExistingDapr checkHttpRequestCLI -getLatestRelease + +if [ -z "$1" ]; then + echo "Getting the latest Dapr CLI..." + getLatestRelease +else + ret_val=v$1 +fi + +echo "Installing $ret_val Dapr CLI..." + downloadFile $ret_val installFile cleanup