Skip to content

Commit

Permalink
Merge branch 'master' into feat/interact-with-kubernetes-dapr-apps
Browse files Browse the repository at this point in the history
  • Loading branch information
imneov authored Apr 24, 2024
2 parents f62550c + 619cd9c commit 5ad56cc
Show file tree
Hide file tree
Showing 77 changed files with 2,560 additions and 768 deletions.
6 changes: 6 additions & 0 deletions .github/holopin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
organization: dapr
defaultSticker: clmjkxscc122740fl0mkmb7egi
stickers:
-
id: clmjkxscc122740fl0mkmb7egi
alias: ghc2023
15 changes: 8 additions & 7 deletions .github/workflows/dapr_cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
env:
GOLANG_CI_LINT_VER: v1.51.2
GOLANG_CI_LINT_VER: v1.55.2
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
Expand Down Expand Up @@ -132,14 +132,14 @@ jobs:
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
run: |
[ ! -z "${{ env.REL_VERSION }}" ] && echo "${{ env.REL_VERSION }}" > "${{ env.ARCHIVE_OUTDIR }}/release_version.txt"
- name: upload artifacts
uses: actions/upload-artifact@master
- name: upload artifacts ## Following migration guide in https://github.com/actions/upload-artifact/blob/main/docs/MIGRATION.md
uses: actions/upload-artifact@v4
with:
name: cli_drop
name: cli_drop-${{ matrix.target_os }}_${{ matrix.target_arch }}
path: ${{ env.ARCHIVE_OUTDIR }}
- name: Upload test results
if: always()
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_test_unit.json
path: ${{ env.TEST_OUTPUT_FILE }}
Expand All @@ -152,9 +152,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: download artifacts
uses: actions/download-artifact@master
uses: actions/download-artifact@v4
with:
name: cli_drop
pattern: cli_drop-*
merge-multiple: true
path: ${{ env.ARTIFACT_DIR }}
- name: Set Release Version
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/kind_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ jobs:
name: E2E tests for K8s (KinD)
runs-on: ubuntu-latest
env:
DAPR_RUNTIME_PINNED_VERSION: 1.11.0
DAPR_DASHBOARD_PINNED_VERSION: 0.13.0
DAPR_RUNTIME_PINNED_VERSION: 1.13.0-rc.2
DAPR_DASHBOARD_PINNED_VERSION: 0.14.0
DAPR_RUNTIME_LATEST_STABLE_VERSION:
DAPR_DASHBOARD_LATEST_STABLE_VERSION:
DAPR_TGZ: dapr-1.11.0.tgz
DAPR_TGZ: dapr-1.13.0-rc.2.tgz
strategy:
fail-fast: false # Keep running if one leg fails.
matrix:
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
shell: bash
- name: Upload test results
if: always()
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.k8s-version }}_${{ matrix.mode }}_e2e_k8s.json
path: ${{ env.TEST_OUTPUT_FILE }}
13 changes: 7 additions & 6 deletions .github/workflows/self_hosted_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ jobs:
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
ARCHIVE_OUTDIR: dist/archives
DAPR_RUNTIME_PINNED_VERSION: "1.11.0"
DAPR_DASHBOARD_PINNED_VERSION: 0.13.0
DAPR_RUNTIME_LATEST_STABLE_VERSION:
DAPR_DASHBOARD_LATEST_STABLE_VERSION:
DAPR_RUNTIME_PINNED_VERSION: "1.13.0-rc.2"
DAPR_DASHBOARD_PINNED_VERSION: 0.14.0
DAPR_RUNTIME_LATEST_STABLE_VERSION: ""
DAPR_DASHBOARD_LATEST_STABLE_VERSION: ""
GOLANG_PROTOBUF_REGISTRATION_CONFLICT: warn
PODMAN_VERSION: 4.4.4
strategy:
# TODO: Remove this when our E2E tests are stable for podman on MacOS.
Expand Down Expand Up @@ -178,7 +179,7 @@ jobs:
shell: bash
- name: Upload test results
if: always()
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_e2e_standalone.json
name: ${{ matrix.target_os }}_${{ matrix.target_arch }}_${{ matrix.dapr_install_mode }}_e2e_standalone.json
path: ${{ env.TEST_OUTPUT_FILE }}
2 changes: 1 addition & 1 deletion .github/workflows/upgrade_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ jobs:
- name: Upload test results
if: always()
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.k8s-version }}_${{ matrix.mode }}_e2e_upgrade_k8s.json
path: ${{ env.TEST_OUTPUT_FILE }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ cli

# CLI's auto-generated components directory
**/components
# Auto generated deploy dir inside .dapr directory
**/.dapr/deploy
# Auto generated logs dir inside .dapr directory
**/.dapr/logs

Expand Down
21 changes: 12 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,11 @@ linters-settings:
# minimal occurrences count to trigger, 3 by default
min-occurrences: 5
depguard:
list-type: blacklist
include-go-root: false
packages:
- github.com/Sirupsen/logrus
packages-with-error-messages:
# specify an error message to output when a blacklisted package is used
github.com/Sirupsen/logrus: "must use github.com/sirupsen/logrus"
rules:
main:
deny:
- pkg: "github.com/Sirupsen/logrus"
desc: "must use github.com/sirupsen/logrus"
misspell:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
Expand Down Expand Up @@ -216,7 +214,6 @@ linters-settings:
# Allow multiline assignments to be cuddled. Default is true.
allow-multiline-assign: true
# Allow case blocks to end with a whitespace.
allow-case-traling-whitespace: true
# Allow declarations (var) to be cuddled.
allow-cuddle-declarations: false

Expand Down Expand Up @@ -262,4 +259,10 @@ linters:
- forcetypeassert
- ireturn
- golint
- nosnakecase
- nosnakecase
- tagalign
- varcheck
- deadcode
- structcheck
- ifshort
- testifylint
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ test: test-deps
################################################################################
.PHONY: test-e2e-k8s
test-e2e-k8s: test-deps
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 20m -count=1 -tags=e2e ./tests/e2e/kubernetes/...
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 25m -count=1 -tags=e2e ./tests/e2e/kubernetes/...

################################################################################
# E2E Tests for K8s Template exec #
################################################################################
.PHONY: test-e2e-k8s-template
test-e2e-k8s-template: test-deps
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 25m -count=1 -tags=templatek8s ./tests/e2e/kubernetes/...

################################################################################
# Build, E2E Tests for Kubernetes #
Expand Down Expand Up @@ -200,7 +207,7 @@ e2e-build-run-sh: build test-e2e-sh
################################################################################
.PHONY: modtidy
modtidy:
go mod tidy -compat=1.20
go mod tidy -compat=1.21

################################################################################
# Target: check-diff #
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ dapr upgrade -k --runtime-version=1.0.0

The example above shows how to upgrade from your current version to version `1.0.0`.

*Note: `dapr upgrade` will retry up to 5 times upon failure*

#### Supplying Helm values

All available [Helm Chart values](https://github.com/dapr/dapr/tree/master/charts/dapr#configuration) can be set by using the `--set` flag:
Expand Down
2 changes: 1 addition & 1 deletion cmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ dapr dashboard -k -p 0
}()

// url for dashboard after port forwarding.
webURL := fmt.Sprintf("http://%s", net.JoinHostPort(dashboardHost, fmt.Sprint(portForward.LocalPort)))
webURL := fmt.Sprintf("http://%s", net.JoinHostPort(dashboardHost, fmt.Sprint(portForward.LocalPort))) //nolint: perfsprint

print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Dapr dashboard found in namespace:\t%s", foundNamespace))
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Dapr dashboard available at:\t%s\n", webURL))
Expand Down
6 changes: 6 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
wait bool
timeout uint
slimMode bool
devMode bool
runtimeVersion string
dashboardVersion string
allNamespaces bool
Expand Down Expand Up @@ -68,6 +69,9 @@ dapr init --image-registry <registry-url>
# Initialize Dapr in Kubernetes
dapr init -k
# Initialize Dapr in Kubernetes in dev mode
dapr init -k --dev
# Initialize Dapr in Kubernetes and wait for the installation to complete (default timeout is 300s/5m)
dapr init -k --wait --timeout 600
Expand Down Expand Up @@ -127,6 +131,7 @@ dapr init --runtime-path <path-to-install-directory>
DashboardVersion: dashboardVersion,
EnableMTLS: enableMTLS,
EnableHA: enableHA,
EnableDev: devMode,
Args: values,
Wait: wait,
Timeout: timeout,
Expand Down Expand Up @@ -202,6 +207,7 @@ func init() {
defaultContainerRuntime := string(utils.DOCKER)

InitCmd.Flags().BoolVarP(&kubernetesMode, "kubernetes", "k", false, "Deploy Dapr to a Kubernetes cluster")
InitCmd.Flags().BoolVarP(&devMode, "dev", "", false, "Use Dev mode. Deploy Redis, Zipkin also in the Kubernetes cluster")
InitCmd.Flags().BoolVarP(&wait, "wait", "", false, "Wait for Kubernetes initialization to complete")
InitCmd.Flags().UintVarP(&timeout, "timeout", "", 300, "The wait timeout for the Kubernetes installation")
InitCmd.Flags().BoolVarP(&slimMode, "slim", "s", false, "Exclude placement service, Redis and Zipkin containers from self-hosted installation")
Expand Down
45 changes: 34 additions & 11 deletions cmd/renew_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ limitations under the License.
package cmd

import (
"errors"
"fmt"
"os"
"strings"
"sync"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -168,22 +170,43 @@ func logErrorAndExit(err error) {
}

func restartControlPlaneService() error {
controlPlaneServices := []string{"deploy/dapr-sentry", "deploy/dapr-operator", "statefulsets/dapr-placement-server"}
controlPlaneServices := []string{
"deploy/dapr-sentry",
"deploy/dapr-sidecar-injector",
"deploy/dapr-operator",
"statefulsets/dapr-placement-server",
}
namespace, err := kubernetes.GetDaprNamespace()
if err != nil {
print.FailureStatusEvent(os.Stdout, "Failed to fetch Dapr namespace")
}
for _, name := range controlPlaneServices {
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Restarting %s..", name))
_, err := utils.RunCmdAndWait("kubectl", "rollout", "restart", name, "-n", namespace)
if err != nil {
return fmt.Errorf("error in restarting deployment %s. Error is %w", name, err)
}
_, err = utils.RunCmdAndWait("kubectl", "rollout", "status", name, "-n", namespace)
if err != nil {
return fmt.Errorf("error in checking status for deployment %s. Error is %w", name, err)
}

errs := make([]error, len(controlPlaneServices))
var wg sync.WaitGroup
wg.Add(len(controlPlaneServices))
for i, name := range controlPlaneServices {
go func(i int, name string) {
defer wg.Done()
print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Restarting %s..", name))
_, err := utils.RunCmdAndWait("kubectl", "rollout", "restart", "-n", namespace, name)
if err != nil {
errs[i] = fmt.Errorf("error in restarting deployment %s. Error is %w", name, err)
return
}
_, err = utils.RunCmdAndWait("kubectl", "rollout", "status", "-n", namespace, name)
if err != nil {
errs[i] = fmt.Errorf("error in checking status for deployment %s. Error is %w", name, err)
return
}
}(i, name)
}

wg.Wait()

if err := errors.Join(errs...); err != nil {
return err
}

print.SuccessStatusEvent(os.Stdout, "All control plane services have restarted successfully!")
return nil
}
Loading

0 comments on commit 5ad56cc

Please sign in to comment.