Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scheduler: change /var/lock to /run/lock #1445

Open
wants to merge 28 commits into
base: release-1.14
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
678b417
Scheduler: change /var/lock to /run/lock
JoshVanL Aug 15, 2024
6654a5e
Update dapr in standalone tests to 1.14.1
JoshVanL Aug 15, 2024
0dea2d0
Update dapr in github workflow to 1.14.1
JoshVanL Aug 15, 2024
019e6a7
Adds scheduler upgrade and downgread tests
JoshVanL Aug 15, 2024
343d111
Adds back missing tests
JoshVanL Aug 15, 2024
c20e588
Fix comma in test code
JoshVanL Aug 15, 2024
c938c55
Fix string match
JoshVanL Aug 15, 2024
822190c
Fix string match in standalone e2e test
JoshVanL Aug 16, 2024
cff312d
Increase e2e timeout
JoshVanL Aug 16, 2024
dbd961d
Assert directory does not exist
JoshVanL Aug 16, 2024
553f522
Remove old upgrade test versions
JoshVanL Aug 16, 2024
4014bb3
increase timeout
JoshVanL Aug 16, 2024
e601f43
Adds container logs command for scheduler fail
JoshVanL Aug 16, 2024
f778633
Change data path based image variant
JoshVanL Aug 16, 2024
0281606
Increase 30m to 45m timeout in workflow
JoshVanL Aug 16, 2024
a168890
Remove another old test
JoshVanL Aug 16, 2024
fb41c2e
Remove testing container logs
JoshVanL Aug 16, 2024
bd413b1
Use correct names for RBAC resources
JoshVanL Aug 16, 2024
8353f3f
Adds dapr_scheduler log output
JoshVanL Aug 17, 2024
7742891
Read all logs
JoshVanL Aug 19, 2024
389f836
Only use var lock if in windows
JoshVanL Aug 19, 2024
4c26cb6
Linting
JoshVanL Aug 19, 2024
73a74d4
linting
JoshVanL Aug 19, 2024
3f79c26
Make lock path absolute
JoshVanL Aug 19, 2024
41b2a54
Remove runtime windows check for mariner
JoshVanL Aug 19, 2024
9910c5c
Fix image runtime version on suffix mariner
JoshVanL Aug 19, 2024
03d99b2
Print version..
JoshVanL Aug 19, 2024
fa652f9
Increase dapr dashboard to 0.14.0 in upgrade test
JoshVanL Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 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.13.0-rc.2
DAPR_RUNTIME_PINNED_VERSION: 1.14.1
DAPR_DASHBOARD_PINNED_VERSION: 0.14.0
DAPR_RUNTIME_LATEST_STABLE_VERSION:
DAPR_DASHBOARD_LATEST_STABLE_VERSION:
DAPR_TGZ: dapr-1.13.0-rc.2.tgz
DAPR_TGZ: dapr-1.14.1.tgz
strategy:
fail-fast: false # Keep running if one leg fails.
matrix:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/self_hosted_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
ARCHIVE_OUTDIR: dist/archives
DAPR_RUNTIME_PINNED_VERSION: "1.13.0-rc.2"
DAPR_RUNTIME_PINNED_VERSION: "1.14.1"
DAPR_DASHBOARD_PINNED_VERSION: 0.14.0
DAPR_RUNTIME_LATEST_STABLE_VERSION: ""
DAPR_DASHBOARD_LATEST_STABLE_VERSION: ""
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
shell: bash
- name: Set the test timeout - MacOS
if: matrix.os == 'macos-latest-large'
run: echo "E2E_SH_TEST_TIMEOUT=30m" >> $GITHUB_ENV
run: echo "E2E_SH_TEST_TIMEOUT=40m" >> $GITHUB_ENV
- name: Run E2E tests with GHCR
# runs every 6hrs
if: github.event.schedule == '0 */6 * * *'
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,14 @@ test: test-deps
################################################################################
.PHONY: test-e2e-k8s
test-e2e-k8s: test-deps
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 25m -count=1 -tags=e2e ./tests/e2e/kubernetes/...
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 40m -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/...
gotestsum --jsonfile $(TEST_OUTPUT_FILE) --format standard-verbose -- -timeout 40m -count=1 -tags=templatek8s ./tests/e2e/kubernetes/...

################################################################################
# Build, E2E Tests for Kubernetes #
Expand Down
60 changes: 32 additions & 28 deletions pkg/standalone/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"net/http"
"os"
"path"
path_filepath "path/filepath"
"path/filepath"
"runtime"
"strings"
"sync"
Expand Down Expand Up @@ -229,7 +229,7 @@ func Init(runtimeVersion, dashboardVersion string, dockerNetwork string, slimMod
// If --from-dir flag is given try parsing the details from the expected details file in the specified directory.
if isAirGapInit {
bundleDet = bundleDetails{}
detailsFilePath := path_filepath.Join(fromDir, bundleDetailsFileName)
detailsFilePath := filepath.Join(fromDir, bundleDetailsFileName)
err = bundleDet.readAndParseDetails(detailsFilePath)
if err != nil {
return fmt.Errorf("error parsing details file from bundle location: %w", err)
Expand Down Expand Up @@ -524,7 +524,7 @@ func runPlacementService(wg *sync.WaitGroup, errorChan chan<- error, info initIn

if isAirGapInit {
// if --from-dir flag is given load the image details from the installer-bundle.
dir := path_filepath.Join(info.fromDir, *info.bundleDet.ImageSubDir)
dir := filepath.Join(info.fromDir, *info.bundleDet.ImageSubDir)
image = info.bundleDet.getDaprImageName()
err = loadContainer(dir, info.bundleDet.getDaprImageFileName(), info.containerRuntime)
if err != nil {
Expand Down Expand Up @@ -619,7 +619,7 @@ func runSchedulerService(wg *sync.WaitGroup, errorChan chan<- error, info initIn

if isAirGapInit {
// if --from-dir flag is given load the image details from the installer-bundle.
dir := path_filepath.Join(info.fromDir, *info.bundleDet.ImageSubDir)
dir := filepath.Join(info.fromDir, *info.bundleDet.ImageSubDir)
image = info.bundleDet.getDaprImageName()
err = loadContainer(dir, info.bundleDet.getDaprImageFileName(), info.containerRuntime)
if err != nil {
Expand All @@ -642,17 +642,21 @@ func runSchedulerService(wg *sync.WaitGroup, errorChan chan<- error, info initIn
"-d",
"--entrypoint", "./scheduler",
}
schedVolPath := filepath.Join("/var", "lock")
if info.imageVariant == "mariner" {
schedVolPath = filepath.Join("/run", "lock")
}
if info.schedulerVolume != nil {
// Don't touch this file location unless things start breaking.
// In Docker, when Docker creates a volume and mounts that volume. Docker
// assumes the file permissions of that directory if it exists in the container.
// If that directory didn't exist in the container previously, then Docker sets
// the permissions owned by root and not writeable.
// We are lucky in that the Dapr containers have a world writeable directory at
// /var/lock and can therefore mount the Docker volume here.
// /run/lock and can therefore mount the Docker volume here.
// TODO: update the Dapr scheduler dockerfile to create a scheduler user id writeable
// directory at /var/lib/dapr/scheduler, then update the path here.
args = append(args, "--volume", *info.schedulerVolume+":/var/lock")
args = append(args, "--volume", *info.schedulerVolume+":"+schedVolPath)
}

if info.dockerNetwork != "" {
Expand All @@ -673,7 +677,7 @@ func runSchedulerService(wg *sync.WaitGroup, errorChan chan<- error, info initIn
)
}

args = append(args, image, "--etcd-data-dir=/var/lock/dapr/scheduler")
args = append(args, image, "--etcd-data-dir="+schedVolPath+"/dapr/scheduler")

_, err = utils.RunCmdAndWait(runtimeCmd, args...)
if err != nil {
Expand All @@ -690,26 +694,26 @@ func runSchedulerService(wg *sync.WaitGroup, errorChan chan<- error, info initIn

func moveDashboardFiles(extractedFilePath string, dir string) (string, error) {
// Move /release/os/web directory to /web.
oldPath := path_filepath.Join(path_filepath.Dir(extractedFilePath), "web")
newPath := path_filepath.Join(dir, "web")
oldPath := filepath.Join(filepath.Dir(extractedFilePath), "web")
newPath := filepath.Join(dir, "web")
err := os.Rename(oldPath, newPath)
if err != nil {
err = fmt.Errorf("failed to move dashboard files: %w", err)
return "", err
}

// Move binary from /release/<os>/web/dashboard(.exe) to /dashboard(.exe).
err = os.Rename(extractedFilePath, path_filepath.Join(dir, path_filepath.Base(extractedFilePath)))
err = os.Rename(extractedFilePath, filepath.Join(dir, filepath.Base(extractedFilePath)))
if err != nil {
err = fmt.Errorf("error moving %s binary to path: %w", path_filepath.Base(extractedFilePath), err)
err = fmt.Errorf("error moving %s binary to path: %w", filepath.Base(extractedFilePath), err)
return "", err
}

// Change the extracted binary file path to reflect the move above.
extractedFilePath = path_filepath.Join(dir, path_filepath.Base(extractedFilePath))
extractedFilePath = filepath.Join(dir, filepath.Base(extractedFilePath))

// Remove the now-empty 'release' directory.
err = os.RemoveAll(path_filepath.Join(dir, "release"))
err = os.RemoveAll(filepath.Join(dir, "release"))
if err != nil {
err = fmt.Errorf("error moving dashboard files: %w", err)
return "", err
Expand Down Expand Up @@ -777,28 +781,28 @@ func installScheduler(wg *sync.WaitGroup, errorChan chan<- error, info initInfo)
// installBinary installs the daprd, placement, scheduler, or dashboard binaries and associated files inside the default dapr bin directory.
func installBinary(version, binaryFilePrefix, githubRepo string, info initInfo) error {
var (
err error
filepath string
err error
path string
)

dir := getDaprBinPath(info.installDir)
if isAirGapInit {
filepath = path_filepath.Join(info.fromDir, *info.bundleDet.BinarySubDir, binaryName(binaryFilePrefix))
path = filepath.Join(info.fromDir, *info.bundleDet.BinarySubDir, binaryName(binaryFilePrefix))
} else {
filepath, err = downloadBinary(dir, version, binaryFilePrefix, githubRepo)
path, err = downloadBinary(dir, version, binaryFilePrefix, githubRepo)
if err != nil {
return fmt.Errorf("error downloading %s binary: %w", binaryFilePrefix, err)
}
}

extractedFilePath, err := extractFile(filepath, dir, binaryFilePrefix)
extractedFilePath, err := extractFile(path, dir, binaryFilePrefix)
if err != nil {
return err
}

// remove downloaded archive from the default dapr bin path.
if !isAirGapInit {
err = os.Remove(filepath)
err = os.Remove(path)
if err != nil {
return fmt.Errorf("failed to remove archive: %w", err)
}
Expand Down Expand Up @@ -906,8 +910,8 @@ func makeExecutable(filepath string) error {

// https://github.com/snyk/zip-slip-vulnerability, fixes gosec G305
func sanitizeExtractPath(destination string, filePath string) (string, error) {
destpath := path_filepath.Join(destination, filePath)
if !strings.HasPrefix(destpath, path_filepath.Clean(destination)+string(os.PathSeparator)) {
destpath := filepath.Join(destination, filePath)
if !strings.HasPrefix(destpath, filepath.Clean(destination)+string(os.PathSeparator)) {
return "", fmt.Errorf("%s: illegal file path", filePath)
}
return destpath, nil
Expand Down Expand Up @@ -956,7 +960,7 @@ func unzip(r *zip.Reader, targetDir string, binaryFilePrefix string) (string, er
continue
}

if err = os.MkdirAll(path_filepath.Dir(fpath), os.ModePerm); err != nil {
if err = os.MkdirAll(filepath.Dir(fpath), os.ModePerm); err != nil {
return "", err
}

Expand Down Expand Up @@ -1047,14 +1051,14 @@ func untar(reader io.Reader, targetDir string, binaryFilePrefix string) (string,
return foundBinary, nil
}

func moveFileToPath(filepath string, installLocation string) (string, error) {
fileName := path_filepath.Base(filepath)
func moveFileToPath(path string, installLocation string) (string, error) {
fileName := filepath.Base(path)
destFilePath := ""

destDir := installLocation
destFilePath = path.Join(destDir, fileName)
destFilePath = filepath.Join(destDir, fileName)

input, err := os.ReadFile(filepath)
input, err := os.ReadFile(path)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -1126,7 +1130,7 @@ func createRedisStateStore(redisHost string, componentsPath string) error {
return err
}

filePath := path_filepath.Join(componentsPath, stateStoreYamlFileName)
filePath := filepath.Join(componentsPath, stateStoreYamlFileName)
err = checkAndOverWriteFile(filePath, b)

return err
Expand Down Expand Up @@ -1157,7 +1161,7 @@ func createRedisPubSub(redisHost string, componentsPath string) error {
return err
}

filePath := path_filepath.Join(componentsPath, pubSubYamlFileName)
filePath := filepath.Join(componentsPath, pubSubYamlFileName)
err = checkAndOverWriteFile(filePath, b)

return err
Expand Down
5 changes: 1 addition & 4 deletions tests/e2e/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,7 @@ func MTLSTestOnInstallUpgrade(opts TestOptions) func(t *testing.T) {

// export
// check that the dir does not exist now.
_, err = os.Stat("./certs")
if assert.Error(t, err) {
assert.True(t, os.IsNotExist(err), err.Error())
}
assert.NoDirExists(t, "./certs")

output, err = spawn.Command(daprPath, "mtls", "export", "-o", "./certs")
require.NoError(t, err, "expected no error on mtls export")
Expand Down
30 changes: 23 additions & 7 deletions tests/e2e/standalone/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package standalone_test

import (
"context"
"fmt"
"io"
"net"
"os"
"path/filepath"
Expand Down Expand Up @@ -167,15 +169,15 @@ func TestStandaloneInit(t *testing.T) {
placementPort = 6050
}

verifyTCPLocalhost(t, placementPort)
verifyTCPLocalhost(t, placementPort)
})

t.Run("init version with scheduler", func(t *testing.T) {
// Ensure a clean environment
must(t, cmdUninstall, "failed to uninstall Dapr")

args := []string{
"--runtime-version", "1.14.0-rc.3",
"--runtime-version", "1.14.1",
"--dev",
}
output, err := cmdInit(args...)
Expand All @@ -190,8 +192,8 @@ func TestStandaloneInit(t *testing.T) {
require.DirExists(t, daprPath, "Directory %s does not exist", daprPath)

_, latestDaprDashboardVersion := common.GetVersionsFromEnv(t, true)
verifyContainers(t, "1.14.0-rc.3")
verifyBinaries(t, daprPath, "1.14.0-rc.3", latestDaprDashboardVersion)
verifyContainers(t, "1.14.1")
verifyBinaries(t, daprPath, "1.14.1", latestDaprDashboardVersion)
verifyConfigs(t, daprPath)

placementPort := 50005
Expand All @@ -201,8 +203,8 @@ func TestStandaloneInit(t *testing.T) {
schedulerPort = 6060
}

verifyTCPLocalhost(t, placementPort)
verifyTCPLocalhost(t, schedulerPort)
verifyTCPLocalhost(t, placementPort)
verifyTCPLocalhost(t, schedulerPort)
})

t.Run("init without runtime-version flag with mariner images", func(t *testing.T) {
Expand All @@ -213,6 +215,19 @@ func TestStandaloneInit(t *testing.T) {
}
output, err := cmdInit(args...)
t.Log(output)

cli, err := dockerClient.NewClientWithOpts(dockerClient.FromEnv)
require.NoError(t, err)

b, err := cli.ContainerLogs(context.Background(), "dapr_scheduler", types.ContainerLogsOptions{
ShowStdout: true,
ShowStderr: true,
})
require.NoError(t, err)
logs, err := io.ReadAll(b)
require.NoError(t, err)
fmt.Printf(">>%s\n", logs)

require.NoError(t, err, "init failed")
assert.Contains(t, output, "Success! Dapr is up and running.")

Expand Down Expand Up @@ -252,7 +267,7 @@ func verifyContainers(t *testing.T, daprRuntimeVersion string) {
"dapr_redis": "",
}

v, err := semver.NewVersion(daprRuntimeVersion)
v, err := semver.NewVersion(strings.TrimSuffix(daprRuntimeVersion, "-mariner"))
require.NoError(t, err)
if v.Major() >= 1 && v.Minor() >= 14 {
daprContainers["dapr_scheduler"] = daprRuntimeVersion
Expand All @@ -272,6 +287,7 @@ func verifyContainers(t *testing.T, daprRuntimeVersion string) {
}
version := container.Image[versionIndex+1:]
if version != expectedVersion {
fmt.Printf(">>%s >>%s >>%s\n", name, version, expectedVersion)
continue
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/standalone/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestStandaloneRun(t *testing.T) {
output, err := cmdRun(path, "--dapr-internal-grpc-port", "9999", "--", "bash", "-c", "echo test")
t.Log(output)
require.NoError(t, err, "run failed")
assert.Contains(t, output, "Internal gRPC server is running on port 9999")
assert.Contains(t, output, "Internal gRPC server is running on :9999")
assert.Contains(t, output, "Exited App successfully")
assert.Contains(t, output, "Exited Dapr successfully")
assert.NotContains(t, output, "Could not update sidecar metadata for cliPID")
Expand Down
Loading
Loading