-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: queue drain, and workstealer self-destruct waits for full consu…
…mption not full production Signed-off-by: Nick Mitchell <nickm@us.ibm.com>
- Loading branch information
Showing
15 changed files
with
225 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//go:build full || deploy | ||
|
||
package queue | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"lunchpail.io/cmd/options" | ||
"lunchpail.io/pkg/be" | ||
"lunchpail.io/pkg/runtime/queue" | ||
) | ||
|
||
func Drain() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "drain", | ||
Short: "Drain the output tasks, allowing graceful termination", | ||
Args: cobra.MatchAll(cobra.ExactArgs(0), cobra.OnlyValidArgs), | ||
} | ||
|
||
opts, err := options.RestoreBuildOptions() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
runOpts := options.AddRequiredRunOptions(cmd) | ||
options.AddTargetOptionsTo(cmd, &opts) | ||
|
||
cmd.RunE = func(cmd *cobra.Command, args []string) error { | ||
ctx := context.Background() | ||
backend, err := be.New(ctx, opts) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return queue.Drain(ctx, backend, runOpts.Run) | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package queue | ||
|
||
import ( | ||
"context" | ||
|
||
"golang.org/x/sync/errgroup" | ||
|
||
"lunchpail.io/pkg/be" | ||
) | ||
|
||
// Drain the output tasks, allowing graceful termination | ||
func Drain(ctx context.Context, backend be.Backend, runname string) error { | ||
c, err := NewS3ClientForRun(ctx, backend, runname) | ||
if err != nil { | ||
return err | ||
} | ||
defer c.Stop() | ||
|
||
group, _ := errgroup.WithContext(ctx) | ||
for o := range c.ListObjects(c.Paths.Bucket, c.finishedMarkers(), true) { | ||
if o.Err != nil { | ||
return o.Err | ||
} | ||
|
||
group.Go(func() error { return c.MarkConsumed(o.Key) }) | ||
} | ||
|
||
return group.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.