-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add job submit commands, database, and new client
This change adds the JobSubmit, to proto, and to each of the client and server. At this point we can request a job to be submit to a specific cluster, and the token that was generated on register of the cluster is required to "authenticate." We then validate those things and add the job to the database! Next we need a small client to run from within a flux instance and check for jobs assigned to it, and when it receives one, it will be removed from the database. I think I want to make flux-core "bindings" for Go first. Signed-off-by: vsoch <vsoch@users.noreply.github.com>
- Loading branch information
Showing
23 changed files
with
788 additions
and
242 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
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,73 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/akamensky/argparse" | ||
register "github.com/converged-computing/rainbow/cmd/rainbow/register" | ||
submit "github.com/converged-computing/rainbow/cmd/rainbow/submit" | ||
"github.com/converged-computing/rainbow/pkg/types" | ||
) | ||
|
||
var ( | ||
Header = ` | ||
• ┓ | ||
┏┓┏┓┓┏┓┣┓┏┓┓┏┏ | ||
┛ ┗┻┗┛┗┗┛┗┛┗┻┛ | ||
` | ||
|
||
defaultSecret = "chocolate-cookies" | ||
) | ||
|
||
func RunVersion() { | ||
fmt.Printf("🌈️ rainbow version %s\n", types.Version) | ||
} | ||
|
||
func main() { | ||
|
||
parser := argparse.NewParser("rainbow", "Interact with a rainbow multi-cluster") | ||
versionCmd := parser.NewCommand("version", "See the version of compspec") | ||
registerCmd := parser.NewCommand("register", "Register a new cluster") | ||
submitCmd := parser.NewCommand("submit", "Submit a job to a rainbow cluster") | ||
|
||
// Shared values | ||
host := parser.String("", "host", &argparse.Options{Default: "localhost:50051", Help: "Scheduler server address (host:port)"}) | ||
clusterName := parser.String("", "cluster-name", &argparse.Options{Default: "keebler", Help: "Name of cluster to register"}) | ||
|
||
// Register | ||
secret := registerCmd.String("s", "secret", &argparse.Options{Default: defaultSecret, Help: "Registration 'secret'"}) | ||
|
||
// Submit (note that command for now needs to be in quotes to get the whole thing) | ||
submitSecret := submitCmd.String("s", "secret", &argparse.Options{Default: defaultSecret, Help: "Registration 'secret'"}) | ||
nodes := submitCmd.Int("n", "nodes", &argparse.Options{Default: 1, Help: "Number of nodes to request"}) | ||
tasks := submitCmd.Int("t", "tasks", &argparse.Options{Help: "Number of tasks to request (per node? total?)"}) | ||
command := submitCmd.String("c", "command", &argparse.Options{Default: defaultSecret, Help: "Command to submit"}) | ||
jobName := submitCmd.String("", "job-name", &argparse.Options{Help: "Name for the job (defaults to first command)"}) | ||
|
||
// Now parse the arguments | ||
err := parser.Parse(os.Args) | ||
if err != nil { | ||
fmt.Println(Header) | ||
fmt.Println(parser.Usage(err)) | ||
return | ||
} | ||
|
||
if registerCmd.Happened() { | ||
err := register.Run(*host, *clusterName, *secret) | ||
if err != nil { | ||
log.Fatalf("Issue with register: %s\n", err) | ||
} | ||
} else if submitCmd.Happened() { | ||
err := submit.Run(*host, *jobName, *command, *nodes, *tasks, *submitSecret, *clusterName) | ||
if err != nil { | ||
log.Fatal(err.Error()) | ||
} | ||
} else if versionCmd.Happened() { | ||
RunVersion() | ||
} else { | ||
fmt.Println(Header) | ||
fmt.Println(parser.Usage(nil)) | ||
} | ||
} |
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 extract | ||
|
||
import ( | ||
"context" | ||
"log" | ||
|
||
"github.com/converged-computing/rainbow/pkg/client" | ||
) | ||
|
||
// Run will run an extraction of host metadata | ||
func Run(host, clusterName, secret string) error { | ||
c, err := client.NewClient(host) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Printf("registering cluster: %s", clusterName) | ||
|
||
// Last argument is secret, empty for now | ||
response, err := c.Register(context.Background(), clusterName, secret) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// If we get here, success! Dump all the stuff. | ||
log.Printf("status: %s", response.Status) | ||
log.Printf(" token: %s", response.Token) | ||
return nil | ||
} |
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,55 @@ | ||
package match | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"strings" | ||
|
||
"github.com/converged-computing/rainbow/pkg/client" | ||
"github.com/converged-computing/rainbow/pkg/types" | ||
) | ||
|
||
// Run will check a manifest list of artifacts against a host machine | ||
// For now, the host machine parameters will be provided as flags | ||
func Run( | ||
host, jobName, command string, | ||
nodes, tasks int, | ||
submitSecret, clusterName string, | ||
) error { | ||
|
||
c, err := client.NewClient(host) | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
// Further validation of job happens with client below | ||
if command == "" { | ||
return fmt.Errorf("a command is required") | ||
} | ||
log.Printf("submit job: %s", command) | ||
|
||
// Prepare a JobSpec | ||
if jobName == "" { | ||
parts := strings.Split(command, " ") | ||
jobName = parts[0] | ||
} | ||
jobspec := types.JobSpec{ | ||
Name: jobName, | ||
Nodes: int32(nodes), | ||
Tasks: int32(tasks), | ||
Command: command, | ||
} | ||
|
||
// Last argument is secret, empty for now | ||
response, err := c.SubmitJob(context.Background(), jobspec, clusterName, submitSecret) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// If we get here, success! Dump all the stuff. | ||
//log.Printf("status: %s", response.Status) | ||
//log.Printf(" token: %s", response.Token) | ||
log.Println(response) | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.