Skip to content

Commit

Permalink
Merge branch 'release-1.14' into fix_podman_install_macos
Browse files Browse the repository at this point in the history
  • Loading branch information
artursouza authored Jul 18, 2024
2 parents 9dc876a + 29d29ab commit 3441b0e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ e2e-build-run-k8s: build test-e2e-k8s
################################################################################
.PHONY: test-e2e-upgrade
test-e2e-upgrade: test-deps
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 30m -count=1 -tags=e2e ./tests/e2e/upgrade/...
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 40m -count=1 -tags=e2e ./tests/e2e/upgrade/...

################################################################################
# Build, E2E Tests for Kubernetes Upgrade #
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Output should look like so:
ℹ️ dapr_redis container is running.
ℹ️ dapr_zipkin container is running.
ℹ️ Use `docker ps` to check running containers.
✅ Success! Dapr is up and running. To get started, go here: https://aka.ms/dapr-getting-started
✅ Success! Dapr is up and running. To get started, go here: https://docs.dapr.io/getting-started
```

> Note: To see that Dapr has been installed successfully, from a command prompt run the `docker ps` command and check that the `daprio/dapr:latest`, `dapr_redis` and `dapr_zipkin` container images are all running.
Expand All @@ -120,7 +120,7 @@ Output should look like so:
ℹ️ daprd binary has been installed to $HOME/.dapr/bin.
ℹ️ placement binary has been installed.
ℹ️ scheduler binary has been installed.
✅ Success! Dapr is up and running. To get started, go here: https://aka.ms/dapr-getting-started
✅ Success! Dapr is up and running. To get started, go here: https://docs.dapr.io/getting-started
```

>Note: When initializing Dapr with the `--slim` flag only the Dapr runtime, placement, and scheduler service binaries are installed. An empty default components folder is created with no default configuration files. During `dapr run` user should use `--resources-path` (`--components-path` is deprecated and will be removed in future releases) to point to a components directory with custom configurations files or alternatively place these files in the default directory. For Linux/MacOS, the default components directory path is `$HOME/.dapr/components` and for Windows it is `%USERPROFILE%\.dapr\components`.
Expand Down Expand Up @@ -289,7 +289,7 @@ Output should look like as follows:
ℹ️ Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr/#install-with-helm-advanced
✅ Deploying the Dapr control plane to your cluster...
✅ Success! Dapr has been installed to namespace dapr-system. To verify, run "dapr status -k" in your terminal. To get started, go here: https://aka.ms/dapr-getting-started
✅ Success! Dapr has been installed to namespace dapr-system. To verify, run "dapr status -k" in your terminal. To get started, go here: https://docs.dapr.io/getting-started
```

#### Supplying Helm values
Expand Down
8 changes: 5 additions & 3 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var (
fromDir string
containerRuntime string
imageVariant string
schedulerVolume string
)

var InitCmd = &cobra.Command{
Expand Down Expand Up @@ -146,7 +147,7 @@ dapr init --runtime-path <path-to-install-directory>
print.FailureStatusEvent(os.Stderr, err.Error())
os.Exit(1)
}
print.SuccessStatusEvent(os.Stdout, fmt.Sprintf("Success! Dapr has been installed to namespace %s. To verify, run `dapr status -k' in your terminal. To get started, go here: https://aka.ms/dapr-getting-started", config.Namespace))
print.SuccessStatusEvent(os.Stdout, fmt.Sprintf("Success! Dapr has been installed to namespace %s. To verify, run `dapr status -k' in your terminal. To get started, go here: https://docs.dapr.io/getting-started", config.Namespace))
} else {
dockerNetwork := ""
imageRegistryURI := ""
Expand All @@ -170,12 +171,12 @@ dapr init --runtime-path <path-to-install-directory>
print.FailureStatusEvent(os.Stdout, "Invalid container runtime. Supported values are docker and podman.")
os.Exit(1)
}
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode, imageRegistryURI, fromDir, containerRuntime, imageVariant, daprRuntimePath)
err := standalone.Init(runtimeVersion, dashboardVersion, dockerNetwork, slimMode, imageRegistryURI, fromDir, containerRuntime, imageVariant, daprRuntimePath, &schedulerVolume)
if err != nil {
print.FailureStatusEvent(os.Stderr, err.Error())
os.Exit(1)
}
print.SuccessStatusEvent(os.Stdout, "Success! Dapr is up and running. To get started, go here: https://aka.ms/dapr-getting-started")
print.SuccessStatusEvent(os.Stdout, "Success! Dapr is up and running. To get started, go here: https://docs.dapr.io/getting-started")
}
},
}
Expand Down Expand Up @@ -219,6 +220,7 @@ func init() {
InitCmd.Flags().String("network", "", "The Docker network on which to deploy the Dapr runtime")
InitCmd.Flags().StringVarP(&fromDir, "from-dir", "", "", "Use Dapr artifacts from local directory for self-hosted installation")
InitCmd.Flags().StringVarP(&imageVariant, "image-variant", "", "", "The image variant to use for the Dapr runtime, for example: mariner")
InitCmd.Flags().StringVarP(&schedulerVolume, "scheduler-volume", "", "dapr_scheduler", "Self-hosted only. Specify a volume for the scheduler service data directory.")
InitCmd.Flags().BoolP("help", "h", false, "Print this help message")
InitCmd.Flags().StringArrayVar(&values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
InitCmd.Flags().String("image-registry", "", "Custom/private docker image repository URL")
Expand Down
2 changes: 1 addition & 1 deletion cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func init() {
UninstallCmd.Flags().BoolVarP(&uninstallKubernetes, "kubernetes", "k", false, "Uninstall Dapr from a Kubernetes cluster")
UninstallCmd.Flags().BoolVarP(&uninstallDev, "dev", "", false, "Uninstall Dapr Redis and Zipking installations from Kubernetes cluster")
UninstallCmd.Flags().UintVarP(&timeout, "timeout", "", 300, "The timeout for the Kubernetes uninstall")
UninstallCmd.Flags().BoolVar(&uninstallAll, "all", false, "Remove .dapr directory, Redis, Placement, Scheduler, and Zipkin containers on local machine, and CRDs on a Kubernetes cluster")
UninstallCmd.Flags().BoolVar(&uninstallAll, "all", false, "Remove .dapr directory, Redis, Placement, Scheduler (and default volume in self-hosted mode), and Zipkin containers on local machine, and CRDs on a Kubernetes cluster")
UninstallCmd.Flags().String("network", "", "The Docker network from which to remove the Dapr runtime")
UninstallCmd.Flags().StringVarP(&uninstallNamespace, "namespace", "n", "dapr-system", "The Kubernetes namespace to uninstall Dapr from")
UninstallCmd.Flags().BoolP("help", "h", false, "Print this help message")
Expand Down
11 changes: 0 additions & 11 deletions pkg/standalone/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"os"
path_filepath "path/filepath"
"runtime"
"strconv"
"strings"
)

Expand Down Expand Up @@ -61,16 +60,6 @@ func getDaprBinPath(daprDir string) string {
return path_filepath.Join(daprDir, defaultDaprBinDirName)
}

// getSchedulerDataPath returns the data path of a given instance
// Receiving instanceID allows multiple instances of scheduler to run locally in the future.
func getSchedulerDataPath(daprDir string, instanceID int) string {
return path_filepath.Join(
daprDir,
defaultSchedulerDirName,
defaultSchedulerDataDirName,
strconv.Itoa(instanceID))
}

func binaryFilePathWithDir(binaryDir string, binaryFilePrefix string) string {
binaryPath := path_filepath.Join(binaryDir, binaryFilePrefix)
if runtime.GOOS == daprWindowsOS {
Expand Down
10 changes: 6 additions & 4 deletions pkg/standalone/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ type initInfo struct {
imageRegistryURL string
containerRuntime string
imageVariant string
schedulerVolume *string
}

type daprImageInfo struct {
Expand Down Expand Up @@ -184,7 +185,7 @@ func isSchedulerIncluded(runtimeVersion string) (bool, error) {
}

// Init installs Dapr on a local machine using the supplied runtimeVersion.
func Init(runtimeVersion, dashboardVersion string, dockerNetwork string, slimMode bool, imageRegistryURL string, fromDir string, containerRuntime string, imageVariant string, daprInstallPath string) error {
func Init(runtimeVersion, dashboardVersion string, dockerNetwork string, slimMode bool, imageRegistryURL string, fromDir string, containerRuntime string, imageVariant string, daprInstallPath string, schedulerVolume *string) error {
var err error
var bundleDet bundleDetails
containerRuntime = strings.TrimSpace(containerRuntime)
Expand Down Expand Up @@ -305,6 +306,7 @@ func Init(runtimeVersion, dashboardVersion string, dockerNetwork string, slimMod
imageRegistryURL: imageRegistryURL,
containerRuntime: containerRuntime,
imageVariant: imageVariant,
schedulerVolume: schedulerVolume,
}
for _, step := range initSteps {
// Run init on the configurations and containers.
Expand Down Expand Up @@ -633,15 +635,15 @@ func runSchedulerService(wg *sync.WaitGroup, errorChan chan<- error, info initIn
}
}

// instanceID is 0 because we run one instance only for now.
schedulerDataDir := getSchedulerDataPath(info.installDir, 0)
args := []string{
"run",
"--name", schedulerContainerName,
"--restart", "always",
"-d",
"--entrypoint", "./scheduler",
"--volume", fmt.Sprintf("%v:/data-default-dapr-scheduler-server-0", schedulerDataDir),
}
if info.schedulerVolume != nil {
args = append(args, "--volume", *info.schedulerVolume+":/data-default-dapr-scheduler-server-0")
}

if info.dockerNetwork != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/standalone/standalone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func TestInitLogActualContainerRuntimeName(t *testing.T) {
t.Skip("Skipping test as container runtime is available")
}

err := Init(latestVersion, latestVersion, "", false, "", "", test.containerRuntime, "", "")
err := Init(latestVersion, latestVersion, "", false, "", "", test.containerRuntime, "", "", nil)
assert.NotNil(t, err)
assert.Contains(t, err.Error(), test.containerRuntime)
})
Expand Down
18 changes: 18 additions & 0 deletions pkg/standalone/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ func removeDockerContainer(containerErrs []error, containerName, network, runtim
return containerErrs
}

func removeSchedulerVolume(containerErrs []error, runtimeCmd string) []error {
print.InfoStatusEvent(os.Stdout, "Removing volume if it exists: dapr_scheduler")
_, err := utils.RunCmdAndWait(
runtimeCmd, "volume", "rm",
"--force",
"dapr_scheduler")
if err != nil {
containerErrs = append(
containerErrs,
fmt.Errorf("could not remove dapr_scheduler volume: %w", err))
}
return containerErrs
}

func removeDir(dirPath string) error {
_, err := os.Stat(dirPath)
if os.IsNotExist(err) {
Expand Down Expand Up @@ -117,6 +131,10 @@ func Uninstall(uninstallAll bool, dockerNetwork string, containerRuntime string,
if err != nil {
print.WarningStatusEvent(os.Stdout, "WARNING: could not delete dapr dir %s: %s", installDir, err)
}

if containerRuntimeAvailable {
containerErrs = removeSchedulerVolume(containerErrs, runtimeCmd)
}
}

err = errors.New("uninstall failed")
Expand Down

0 comments on commit 3441b0e

Please sign in to comment.