Skip to content

Commit 9d2959a

Browse files
committed
Adds dapr scheduler
Docs: TODO ```bash $ dapr scheduler Scheduler management commands. Use -k to target a Kubernetes Dapr cluster. Usage: dapr scheduler [command] Aliases: scheduler, sched Available Commands: delete 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. delete-all 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. export Export all jobs and actor reminders to a binary file, including the tracked count. get 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. import Import all jobs and actor reminders from a binary file generated by 'dapr scheduler export'. list List scheduled jobs in Scheduler. Flags: -h, --help help for scheduler -k, --kubernetes Perform scheduler command on a Kubernetes Dapr cluster -n, --namespace string Namespace of the Dapr application (default "default") --scheduler-namespace string Kubernetes namespace where the scheduler is deployed, only relevant if --kubernetes is set (default "dapr-system") Global Flags: --log-as-json Log output in JSON format --runtime-path string The path to the dapr runtime installation directory Use "dapr scheduler [command] --help" for more information about a command. ``` ``` $ dapr scheduler delete --help 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. Usage: dapr scheduler delete [flags] Aliases: delete, d, del Examples: 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 Flags: -h, --help help for delete Global Flags: -k, --kubernetes Perform scheduler command on a Kubernetes Dapr cluster --log-as-json Log output in JSON format -n, --namespace string Namespace of the Dapr application (default "default") --runtime-path string The path to the dapr runtime installation directory --scheduler-namespace string Kubernetes namespace where the scheduler is deployed, only relevant if --kubernetes is set (default "dapr-system") ``` ``` $ dapr scheduler delete-all --help 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. Usage: dapr scheduler delete-all [flags] Aliases: delete-all, da, delall Examples: 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 Flags: -h, --help help for delete-all Global Flags: -k, --kubernetes Perform scheduler command on a Kubernetes Dapr cluster --log-as-json Log output in JSON format -n, --namespace string Namespace of the Dapr application (default "default") --runtime-path string The path to the dapr runtime installation directory --scheduler-namespace string Kubernetes namespace where the scheduler is deployed, only relevant if --kubernetes is set (default "dapr-system") ``` ``` $ dapr scheduler export --help Export jobs and actor reminders which are scheduled in Scheduler. Can later be imported using 'dapr scheduler import'. dapr scheduler export -o output.bin Usage: dapr scheduler export [flags] Flags: -h, --help help for export -o, --output-file string Output binary file to export jobs and actor reminders to. Global Flags: -k, --kubernetes Perform scheduler command on a Kubernetes Dapr cluster --log-as-json Log output in JSON format -n, --namespace string Namespace of the Dapr application (default "default") --runtime-path string The path to the dapr runtime installation directory --scheduler-namespace string Kubernetes namespace where the scheduler is deployed, only relevant if --kubernetes is set (default "dapr-system") ``` ``` $ dapr scheduler get --help 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. Usage: dapr scheduler get [flags] Aliases: get, g, ge Examples: 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 Flags: -h, --help help for get -o, --output string Output format. One of short, wide, yaml, json (default "short") Global Flags: -k, --kubernetes Perform scheduler command on a Kubernetes Dapr cluster --log-as-json Log output in JSON format -n, --namespace string Namespace of the Dapr application (default "default") --runtime-path string The path to the dapr runtime installation directory --scheduler-namespace string Kubernetes namespace where the scheduler is deployed, only relevant if --kubernetes is set (default "dapr-system") ``` ``` $ dapr scheduler import --help Import jobs and actor reminders to Scheduler from a binary file generated by 'dapr scheduler export'. dapr scheduler import -f export.bin Usage: dapr scheduler import [flags] Flags: -h, --help help for import -f, --input-file string Input file to import jobs and actor reminders from. Global Flags: -k, --kubernetes Perform scheduler command on a Kubernetes Dapr cluster --log-as-json Log output in JSON format -n, --namespace string Namespace of the Dapr application (default "default") --runtime-path string The path to the dapr runtime installation directory --scheduler-namespace string Kubernetes namespace where the scheduler is deployed, only relevant if --kubernetes is set (default "dapr-system") ``` ``` $ dapr scheduler list --help List scheduled jobs in Scheduler. Usage: dapr scheduler list [flags] Flags: --filter string Filter jobs by type. Supported values are all, app, actor, workflow, activity (default "all") -h, --help help for list -o, --output string Output format. One of short, wide, yaml, json (default "short") Global Flags: -k, --kubernetes Perform scheduler command on a Kubernetes Dapr cluster --log-as-json Log output in JSON format -n, --namespace string Namespace of the Dapr application (default "default") --runtime-path string The path to the dapr runtime installation directory --scheduler-namespace string Kubernetes namespace where the scheduler is deployed, only relevant if --kubernetes is set (default "dapr-system") ``` Signed-off-by: joshvanl <[email protected]>
1 parent f369ffb commit 9d2959a

File tree

30 files changed

+3025
-9
lines changed

30 files changed

+3025
-9
lines changed

.github/workflows/kind_e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
name: E2E tests for K8s (KinD)
5151
runs-on: ubuntu-latest
5252
env:
53-
DAPR_RUNTIME_PINNED_VERSION: 1.16.0
53+
DAPR_RUNTIME_PINNED_VERSION: 1.16.1-rc.3
5454
DAPR_DASHBOARD_PINNED_VERSION: 0.15.0
5555
DAPR_RUNTIME_LATEST_STABLE_VERSION:
5656
DAPR_DASHBOARD_LATEST_STABLE_VERSION:

.github/workflows/self_hosted_e2e.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
GOARCH: ${{ matrix.target_arch }}
3939
GOPROXY: https://proxy.golang.org
4040
ARCHIVE_OUTDIR: dist/archives
41-
DAPR_RUNTIME_PINNED_VERSION: "1.16.0"
41+
DAPR_RUNTIME_PINNED_VERSION: "1.16.1-rc.3"
4242
DAPR_DASHBOARD_PINNED_VERSION: 0.15.0
4343
DAPR_RUNTIME_LATEST_STABLE_VERSION: ""
4444
DAPR_DASHBOARD_LATEST_STABLE_VERSION: ""

cmd/dapr.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/spf13/cobra"
2222
"github.com/spf13/viper"
2323

24+
"github.com/dapr/cli/cmd/scheduler"
2425
"github.com/dapr/cli/pkg/api"
2526
"github.com/dapr/cli/pkg/print"
2627
"github.com/dapr/cli/pkg/standalone"
@@ -108,4 +109,6 @@ func init() {
108109
RootCmd.Flags().BoolVarP(&versionFlag, "version", "v", false, "version for dapr")
109110
RootCmd.PersistentFlags().StringVarP(&daprRuntimePath, "runtime-path", "", "", "The path to the dapr runtime installation directory")
110111
RootCmd.PersistentFlags().BoolVarP(&logAsJSON, "log-as-json", "", false, "Log output in JSON format")
112+
113+
RootCmd.AddCommand(scheduler.SchedulerCmd)
111114
}

cmd/scheduler/delete.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright 2025 The Dapr Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package scheduler
15+
16+
import (
17+
"github.com/spf13/cobra"
18+
19+
"github.com/dapr/cli/pkg/scheduler"
20+
"github.com/dapr/kit/signals"
21+
)
22+
23+
var DeleteCmd = &cobra.Command{
24+
Use: "delete",
25+
Aliases: []string{"d", "del"},
26+
Short: `Delete one of more jobs from scheduler.
27+
Job names are formatted by their type, app ID, then identifier.
28+
Actor reminders require the actor type, actor ID, then reminder name, separated by /.
29+
Workflow reminders require the app ID, instance ID, then reminder name, separated by /.
30+
Accepts multiple names.
31+
`,
32+
Args: cobra.MinimumNArgs(1),
33+
Example: `
34+
dapr scheduler delete app/my-app-id/my-job-name
35+
dapr scheduler delete actor/my-actor-type/my-actor-id/my-reminder-name
36+
dapr scheduler delete workflow/my-app-id/my-instance-id/my-workflow-reminder-name
37+
`,
38+
RunE: func(cmd *cobra.Command, args []string) error {
39+
ctx := signals.Context()
40+
opts := scheduler.DeleteOptions{
41+
SchedulerNamespace: schedulerNamespace,
42+
KubernetesMode: kubernetesMode,
43+
DaprNamespace: daprNamespace,
44+
}
45+
46+
return scheduler.Delete(ctx, opts, args...)
47+
},
48+
}
49+
50+
func init() {
51+
SchedulerCmd.AddCommand(DeleteCmd)
52+
}

cmd/scheduler/deleteall.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
Copyright 2025 The Dapr Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package scheduler
15+
16+
import (
17+
"github.com/spf13/cobra"
18+
19+
"github.com/dapr/cli/pkg/scheduler"
20+
"github.com/dapr/kit/signals"
21+
)
22+
23+
var DeleteAllCmd = &cobra.Command{
24+
Use: "delete-all",
25+
Aliases: []string{"da", "delall"},
26+
Short: `Delete all scheduled jobs in the specified namespace of a particular filter.
27+
Accepts a single key as an argument. Deletes all jobs which match the filter key.
28+
`,
29+
Args: cobra.ExactArgs(1),
30+
Example: `
31+
dapr scheduler delete-all all
32+
dapr scheduler delete-all app
33+
dapr scheduler delete-all app/my-app-id
34+
dapr scheduler delete-all actor/my-actor-type
35+
dapr scheduler delete-all actor/my-actor-type/my-actor-id
36+
dapr scheduler delete-all workflow
37+
dapr scheduler delete-all workflow/my-app-id
38+
dapr scheduler delete-all workflow/my-app-id/my-workflow-id
39+
`,
40+
RunE: func(cmd *cobra.Command, args []string) error {
41+
ctx := signals.Context()
42+
opts := scheduler.DeleteOptions{
43+
SchedulerNamespace: schedulerNamespace,
44+
KubernetesMode: kubernetesMode,
45+
DaprNamespace: daprNamespace,
46+
}
47+
48+
return scheduler.DeleteAll(ctx, opts, args[0])
49+
},
50+
}
51+
52+
func init() {
53+
SchedulerCmd.AddCommand(DeleteAllCmd)
54+
}

cmd/scheduler/export.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2025 The Dapr Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package scheduler
15+
16+
import (
17+
"os"
18+
19+
"github.com/spf13/cobra"
20+
21+
"github.com/dapr/cli/pkg/print"
22+
"github.com/dapr/cli/pkg/scheduler"
23+
"github.com/dapr/kit/signals"
24+
)
25+
26+
var (
27+
schedulerExportFile string
28+
)
29+
30+
var SchedulerExportCmd = &cobra.Command{
31+
Use: "export",
32+
Short: "Export all jobs and actor reminders to a binary file, including the tracked count.",
33+
Long: `Export jobs and actor reminders which are scheduled in Scheduler.
34+
Can later be imported using 'dapr scheduler import'.
35+
dapr scheduler export -o output.bin
36+
`,
37+
RunE: func(cmd *cobra.Command, args []string) error {
38+
ctx := signals.Context()
39+
40+
err := scheduler.Export(ctx, scheduler.ExportImportOptions{
41+
SchedulerNamespace: schedulerNamespace,
42+
KubernetesMode: kubernetesMode,
43+
TargetFile: schedulerExportFile,
44+
})
45+
if err != nil {
46+
return err
47+
}
48+
49+
print.InfoStatusEvent(os.Stdout, "Export to '%s' complete.", schedulerExportFile)
50+
51+
return nil
52+
},
53+
}
54+
55+
func init() {
56+
SchedulerExportCmd.Flags().MarkHidden("namespace")
57+
SchedulerExportCmd.Flags().StringVarP(&schedulerExportFile, "output-file", "o", "", "Output binary file to export jobs and actor reminders to.")
58+
SchedulerExportCmd.MarkFlagRequired("output-file")
59+
SchedulerExportCmd.MarkFlagFilename("output-file")
60+
SchedulerCmd.AddCommand(SchedulerExportCmd)
61+
}

cmd/scheduler/get.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
Copyright 2025 The Dapr Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package scheduler
15+
16+
import (
17+
"os"
18+
19+
"github.com/gocarina/gocsv"
20+
"github.com/spf13/cobra"
21+
22+
"github.com/dapr/cli/pkg/scheduler"
23+
"github.com/dapr/cli/utils"
24+
"github.com/dapr/kit/signals"
25+
)
26+
27+
var (
28+
getOutputFormat *string
29+
)
30+
31+
var GetCmd = &cobra.Command{
32+
Use: "get",
33+
Aliases: []string{"g", "ge"},
34+
Short: `Get a scheduled app job or actor reminder in Scheduler.
35+
Job names are formatted by their type, app ID, then identifier.
36+
Actor reminders require the actor type, actor ID, then reminder name, separated by /.
37+
Workflow reminders require the app ID, instance ID, then reminder name, separated by /.
38+
Activity reminders require the app ID, activity ID, separated by /.
39+
Accepts multiple names.
40+
`,
41+
Args: cobra.MinimumNArgs(1),
42+
Example: `
43+
dapr scheduler get app/my-app-id/my-job-name
44+
dapr scheduler get actor/my-actor-type/my-actor-id/my-reminder-name
45+
dapr scheduler get workflow/my-app-id/my-instance-id/my-workflow-reminder-name
46+
dapr scheduler get activity/my-app-id/xyz::0::1
47+
`,
48+
RunE: func(cmd *cobra.Command, args []string) error {
49+
ctx := signals.Context()
50+
opts := scheduler.GetOptions{
51+
SchedulerNamespace: schedulerNamespace,
52+
KubernetesMode: kubernetesMode,
53+
DaprNamespace: daprNamespace,
54+
}
55+
56+
var list any
57+
var err error
58+
if *getOutputFormat == outputFormatShort {
59+
list, err = scheduler.Get(ctx, opts, args...)
60+
} else {
61+
list, err = scheduler.GetWide(ctx, opts, args...)
62+
}
63+
if err != nil {
64+
return err
65+
}
66+
67+
switch *getOutputFormat {
68+
case outputFormatYAML:
69+
err = utils.PrintDetail(os.Stdout, "yaml", list)
70+
case outputFormatJSON:
71+
err = utils.PrintDetail(os.Stdout, "json", list)
72+
default:
73+
var table string
74+
table, err = gocsv.MarshalString(list)
75+
if err != nil {
76+
break
77+
}
78+
79+
utils.PrintTable(table)
80+
}
81+
82+
if err != nil {
83+
return err
84+
}
85+
86+
return nil
87+
},
88+
}
89+
90+
func init() {
91+
getOutputFormat = outputFunc(GetCmd)
92+
SchedulerCmd.AddCommand(GetCmd)
93+
}

cmd/scheduler/import.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
Copyright 2025 The Dapr Authors
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package scheduler
15+
16+
import (
17+
"os"
18+
19+
"github.com/spf13/cobra"
20+
21+
"github.com/dapr/cli/pkg/print"
22+
"github.com/dapr/cli/pkg/scheduler"
23+
"github.com/dapr/kit/signals"
24+
)
25+
26+
var (
27+
schedulerImportFile string
28+
)
29+
30+
var SchedulerImportCmd = &cobra.Command{
31+
Use: "import",
32+
Short: "Import all jobs and actor reminders from a binary file generated by 'dapr scheduler export'.",
33+
Long: `Import jobs and actor reminders to Scheduler from a binary file generated by 'dapr scheduler export'.
34+
dapr scheduler import -f export.bin`,
35+
Args: cobra.NoArgs,
36+
RunE: func(cmd *cobra.Command, args []string) error {
37+
ctx := signals.Context()
38+
39+
err := scheduler.Import(ctx, scheduler.ExportImportOptions{
40+
SchedulerNamespace: schedulerNamespace,
41+
KubernetesMode: kubernetesMode,
42+
TargetFile: schedulerImportFile,
43+
})
44+
if err != nil {
45+
return err
46+
}
47+
48+
print.InfoStatusEvent(os.Stdout, "Import from '%s' complete.", schedulerImportFile)
49+
50+
return nil
51+
},
52+
}
53+
54+
func init() {
55+
SchedulerImportCmd.Flags().MarkHidden("namespace")
56+
SchedulerImportCmd.Flags().StringVarP(&schedulerImportFile, "input-file", "f", "", "Input file to import jobs and actor reminders from.")
57+
SchedulerImportCmd.MarkFlagRequired("input-file")
58+
SchedulerImportCmd.MarkFlagFilename("input-file")
59+
SchedulerCmd.AddCommand(SchedulerImportCmd)
60+
}

0 commit comments

Comments
 (0)