Skip to content

Commit

Permalink
refactor: move minio/worker/workstealer subcommands to be under a com…
Browse files Browse the repository at this point in the history
…ponents/ command subtree

Signed-off-by: Nick Mitchell <[email protected]>
  • Loading branch information
starpit committed Sep 25, 2024
1 parent 639e8d8 commit 2132285
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 42 deletions.
19 changes: 19 additions & 0 deletions cmd/subcommands/component.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package subcommands

import (
"github.com/spf13/cobra"

"lunchpail.io/cmd/subcommands/component"
)

func init() {
cmd := &cobra.Command{
Use: "component",
Short: "Commands related to specific components",
}
rootCmd.AddCommand(cmd)

cmd.AddCommand(component.Minio())
cmd.AddCommand(component.Worker())
cmd.AddCommand(component.WorkStealer())
}
14 changes: 6 additions & 8 deletions cmd/subcommands/minio.go → cmd/subcommands/component/minio.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package subcommands
package component

import (
"github.com/spf13/cobra"

"lunchpail.io/cmd/subcommands/minio"
"lunchpail.io/cmd/subcommands/component/minio"
)

func newMinioCmd() *cobra.Command {
return &cobra.Command{
func Minio() *cobra.Command {
cmd := &cobra.Command{
Use: "minio",
Short: "Commands for running minio components",
Long: "Commands for running minio components",
}
}

func init() {
cmd := newMinioCmd()
rootCmd.AddCommand(cmd)
cmd.AddCommand(minio.Server())

return cmd
}
File renamed without changes.
20 changes: 20 additions & 0 deletions cmd/subcommands/component/worker.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package component

import (
"github.com/spf13/cobra"

"lunchpail.io/cmd/subcommands/component/worker"
)

func Worker() *cobra.Command {
cmd := &cobra.Command{
Use: "worker",
Short: "Commands that act as an application worker",
Long: "Commands that act as an application worker",
}

cmd.AddCommand(worker.Run())
cmd.AddCommand(worker.PreStop())

return cmd
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"lunchpail.io/pkg/runtime/worker"
)

func NewPreStopCmd() *cobra.Command {
func PreStop() *cobra.Command {
var cmd = &cobra.Command{
Use: "prestop",
Short: "Mark this worker as dead",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"lunchpail.io/pkg/runtime/worker"
)

func NewRunCmd() *cobra.Command {
func Run() *cobra.Command {
var cmd = &cobra.Command{
Use: "run [-- workerCommand workerCommandArg1 workerCommandArg2 ...]",
Short: "Run as an application worker",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package subcommands
package component

import (
"context"
Expand All @@ -7,7 +7,7 @@ import (
"lunchpail.io/pkg/runtime/workstealer"
)

func newWorkstealerCmd() *cobra.Command {
func WorkStealer() *cobra.Command {
var cmd = &cobra.Command{
Use: "workstealer",
Short: "Run a work stealer",
Expand All @@ -21,7 +21,3 @@ func newWorkstealerCmd() *cobra.Command {

return cmd
}

func init() {
rootCmd.AddCommand(newWorkstealerCmd())
}
22 changes: 0 additions & 22 deletions cmd/subcommands/worker.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/fe/transformer/api/minio/transpile.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func transpile(runname string, ir llir.LLIR) (hlir.Application, error) {
app.Spec.Image = "docker.io/minio/minio:RELEASE.2024-07-04T14-25-45Z"
app.Spec.Role = "queue"
app.Spec.Expose = []string{fmt.Sprintf("%d:%d", ir.Queue.Port, ir.Queue.Port)}
app.Spec.Command = fmt.Sprintf("$LUNCHPAIL_EXE minio server --port %d", ir.Queue.Port)
app.Spec.Command = fmt.Sprintf("$LUNCHPAIL_EXE component minio server --port %d", ir.Queue.Port)

prefixIncludingBucket := api.QueuePrefixPath(ir.Queue, runname)
A := strings.Split(prefixIncludingBucket, "/")
Expand Down
4 changes: 2 additions & 2 deletions pkg/fe/transformer/api/workerpool/lower.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func Lower(compilationName, runname string, app hlir.Application, pool hlir.Work
}
app.Spec.Env["LUNCHPAIL_STARTUP_DELAY"] = strconv.Itoa(startupDelay)

app.Spec.Command = fmt.Sprintf(`trap "$LUNCHPAIL_EXE worker prestop" EXIT
$LUNCHPAIL_EXE worker run --debug=%v -- %s`, opts.Log.Debug, app.Spec.Command)
app.Spec.Command = fmt.Sprintf(`trap "$LUNCHPAIL_EXE component worker prestop" EXIT
$LUNCHPAIL_EXE component worker run --debug=%v -- %s`, opts.Log.Debug, app.Spec.Command)

return shell.LowerAsComponent(
compilationName,
Expand Down
2 changes: 1 addition & 1 deletion pkg/fe/transformer/api/workstealer/transpile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func transpile(runname string) (hlir.Application, error) {

app.Spec.Image = fmt.Sprintf("%s/%s/lunchpail:%s", lunchpail.ImageRegistry, lunchpail.ImageRepo, lunchpail.Version())
app.Spec.Role = "workstealer"
app.Spec.Command = "$LUNCHPAIL_EXE workstealer"
app.Spec.Command = "$LUNCHPAIL_EXE component workstealer"

app.Spec.Env = hlir.Env{}
app.Spec.Env["LUNCHPAIL_RUN_NAME"] = runname
Expand Down

0 comments on commit 2132285

Please sign in to comment.