Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/kind_e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
name: E2E tests for K8s (KinD)
runs-on: ubuntu-latest
env:
DAPR_RUNTIME_PINNED_VERSION: 1.16.0
DAPR_RUNTIME_PINNED_VERSION: 1.16.1
DAPR_DASHBOARD_PINNED_VERSION: 0.15.0
DAPR_RUNTIME_LATEST_STABLE_VERSION:
DAPR_DASHBOARD_LATEST_STABLE_VERSION:
Expand Down
2 changes: 1 addition & 1 deletion .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.16.0"
DAPR_RUNTIME_PINNED_VERSION: "1.16.1"
DAPR_DASHBOARD_PINNED_VERSION: 0.15.0
DAPR_RUNTIME_LATEST_STABLE_VERSION: ""
DAPR_DASHBOARD_LATEST_STABLE_VERSION: ""
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ TEST_OUTPUT_FILE ?= test_output.json

# Set the default timeout for tests to 10 minutes
ifndef E2E_SH_TEST_TIMEOUT
override E2E_SH_TEST_TIMEOUT := 10m
override E2E_SH_TEST_TIMEOUT := 30m
endif

# Use the variable H to add a header (equivalent to =>) to informational output
Expand Down
3 changes: 3 additions & 0 deletions cmd/dapr.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/dapr/cli/cmd/scheduler"
"github.com/dapr/cli/pkg/api"
"github.com/dapr/cli/pkg/print"
"github.com/dapr/cli/pkg/standalone"
Expand Down Expand Up @@ -108,4 +109,6 @@ func init() {
RootCmd.Flags().BoolVarP(&versionFlag, "version", "v", false, "version for dapr")
RootCmd.PersistentFlags().StringVarP(&daprRuntimePath, "runtime-path", "", "", "The path to the dapr runtime installation directory")
RootCmd.PersistentFlags().BoolVarP(&logAsJSON, "log-as-json", "", false, "Log output in JSON format")

RootCmd.AddCommand(scheduler.SchedulerCmd)
}
52 changes: 52 additions & 0 deletions cmd/scheduler/delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright 2025 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scheduler

import (
"github.com/spf13/cobra"

"github.com/dapr/cli/pkg/scheduler"
"github.com/dapr/kit/signals"
)

var DeleteCmd = &cobra.Command{
Use: "delete",
Aliases: []string{"d", "del"},
Short: `Delete one of more jobs from scheduler.
Job names are formatted by their type, app ID, then identifier.
Actor reminders require the actor type, actor ID, then reminder name, separated by /.
Workflow reminders require the app ID, instance ID, then reminder name, separated by /.
Accepts multiple names.
`,
Args: cobra.MinimumNArgs(1),
Example: `
dapr scheduler delete app/my-app-id/my-job-name
dapr scheduler delete actor/my-actor-type/my-actor-id/my-reminder-name
dapr scheduler delete workflow/my-app-id/my-instance-id/my-workflow-reminder-name
`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := signals.Context()
opts := scheduler.DeleteOptions{
SchedulerNamespace: schedulerNamespace,
KubernetesMode: kubernetesMode,
DaprNamespace: daprNamespace,
}

return scheduler.Delete(ctx, opts, args...)
},
}

func init() {
SchedulerCmd.AddCommand(DeleteCmd)
}
54 changes: 54 additions & 0 deletions cmd/scheduler/deleteall.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright 2025 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scheduler

import (
"github.com/spf13/cobra"

"github.com/dapr/cli/pkg/scheduler"
"github.com/dapr/kit/signals"
)

var DeleteAllCmd = &cobra.Command{
Use: "delete-all",
Aliases: []string{"da", "delall"},
Short: `Delete all scheduled jobs in the specified namespace of a particular filter.
Accepts a single key as an argument. Deletes all jobs which match the filter key.
`,
Args: cobra.ExactArgs(1),
Example: `
dapr scheduler delete-all all
dapr scheduler delete-all app
dapr scheduler delete-all app/my-app-id
dapr scheduler delete-all actor/my-actor-type
dapr scheduler delete-all actor/my-actor-type/my-actor-id
dapr scheduler delete-all workflow
dapr scheduler delete-all workflow/my-app-id
dapr scheduler delete-all workflow/my-app-id/my-workflow-id
Comment on lines +31 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this command run as dry-run and only print the number of records to delete and run it with --execute when you are sure that is the number or reminder you expect to delete? Probably the same for deletecommand

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but then cli becomes pretty annoying to use. I would rather have a --dry-run flag.

`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := signals.Context()
opts := scheduler.DeleteOptions{
SchedulerNamespace: schedulerNamespace,
KubernetesMode: kubernetesMode,
DaprNamespace: daprNamespace,
}

return scheduler.DeleteAll(ctx, opts, args[0])
},
}

func init() {
SchedulerCmd.AddCommand(DeleteAllCmd)
}
61 changes: 61 additions & 0 deletions cmd/scheduler/export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2025 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scheduler

import (
"os"

"github.com/spf13/cobra"

"github.com/dapr/cli/pkg/print"
"github.com/dapr/cli/pkg/scheduler"
"github.com/dapr/kit/signals"
)

var (
schedulerExportFile string
)

var SchedulerExportCmd = &cobra.Command{
Use: "export",
Short: "Export all jobs and actor reminders to a binary file, including the tracked count.",
Long: `Export jobs and actor reminders which are scheduled in Scheduler.
Can later be imported using 'dapr scheduler import'.
dapr scheduler export -o output.bin
`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := signals.Context()

err := scheduler.Export(ctx, scheduler.ExportImportOptions{
SchedulerNamespace: schedulerNamespace,
KubernetesMode: kubernetesMode,
TargetFile: schedulerExportFile,
})
if err != nil {
return err
}

print.InfoStatusEvent(os.Stdout, "Export to '%s' complete.", schedulerExportFile)

return nil
},
}

func init() {
SchedulerExportCmd.Flags().MarkHidden("namespace")
SchedulerExportCmd.Flags().StringVarP(&schedulerExportFile, "output-file", "o", "", "Output binary file to export jobs and actor reminders to.")
SchedulerExportCmd.MarkFlagRequired("output-file")
SchedulerExportCmd.MarkFlagFilename("output-file")
SchedulerCmd.AddCommand(SchedulerExportCmd)
}
93 changes: 93 additions & 0 deletions cmd/scheduler/get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
Copyright 2025 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scheduler

import (
"os"

"github.com/gocarina/gocsv"
"github.com/spf13/cobra"

"github.com/dapr/cli/pkg/scheduler"
"github.com/dapr/cli/utils"
"github.com/dapr/kit/signals"
)

var (
getOutputFormat *string
)

var GetCmd = &cobra.Command{
Use: "get",
Aliases: []string{"g", "ge"},
Short: `Get a scheduled app job or actor reminder in Scheduler.
Job names are formatted by their type, app ID, then identifier.
Actor reminders require the actor type, actor ID, then reminder name, separated by /.
Workflow reminders require the app ID, instance ID, then reminder name, separated by /.
Activity reminders require the app ID, activity ID, separated by /.
Accepts multiple names.
`,
Args: cobra.MinimumNArgs(1),
Example: `
dapr scheduler get app/my-app-id/my-job-name
dapr scheduler get actor/my-actor-type/my-actor-id/my-reminder-name
dapr scheduler get workflow/my-app-id/my-instance-id/my-workflow-reminder-name
dapr scheduler get activity/my-app-id/xyz::0::1
`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := signals.Context()
opts := scheduler.GetOptions{
SchedulerNamespace: schedulerNamespace,
KubernetesMode: kubernetesMode,
DaprNamespace: daprNamespace,
}

var list any
var err error
if *getOutputFormat == outputFormatShort {
list, err = scheduler.Get(ctx, opts, args...)
} else {
list, err = scheduler.GetWide(ctx, opts, args...)
}
if err != nil {
return err
}

switch *getOutputFormat {
case outputFormatYAML:
err = utils.PrintDetail(os.Stdout, "yaml", list)
case outputFormatJSON:
err = utils.PrintDetail(os.Stdout, "json", list)
default:
var table string
table, err = gocsv.MarshalString(list)
if err != nil {
break
}

utils.PrintTable(table)
}

if err != nil {
return err
}

return nil
},
}

func init() {
getOutputFormat = outputFunc(GetCmd)
SchedulerCmd.AddCommand(GetCmd)
}
60 changes: 60 additions & 0 deletions cmd/scheduler/import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright 2025 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scheduler

import (
"os"

"github.com/spf13/cobra"

"github.com/dapr/cli/pkg/print"
"github.com/dapr/cli/pkg/scheduler"
"github.com/dapr/kit/signals"
)

var (
schedulerImportFile string
)

var SchedulerImportCmd = &cobra.Command{
Use: "import",
Short: "Import all jobs and actor reminders from a binary file generated by 'dapr scheduler export'.",
Long: `Import jobs and actor reminders to Scheduler from a binary file generated by 'dapr scheduler export'.
dapr scheduler import -f export.bin`,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := signals.Context()

err := scheduler.Import(ctx, scheduler.ExportImportOptions{
SchedulerNamespace: schedulerNamespace,
KubernetesMode: kubernetesMode,
TargetFile: schedulerImportFile,
})
if err != nil {
return err
}

print.InfoStatusEvent(os.Stdout, "Import from '%s' complete.", schedulerImportFile)

return nil
},
}

func init() {
SchedulerImportCmd.Flags().MarkHidden("namespace")
SchedulerImportCmd.Flags().StringVarP(&schedulerImportFile, "input-file", "f", "", "Input file to import jobs and actor reminders from.")
SchedulerImportCmd.MarkFlagRequired("input-file")
SchedulerImportCmd.MarkFlagFilename("input-file")
SchedulerCmd.AddCommand(SchedulerImportCmd)
}
Loading
Loading