15275: Avoids running manage_versioning when not needed.
[arvados.git] / lib / dispatchcloud / cmd.go
index 92948fb300e703971e59957b4f6f98db176a42ef..22ceb8aebe787ae79c1274cc0c714bc39df04640 100644 (file)
@@ -5,6 +5,9 @@
 package dispatchcloud
 
 import (
+       "context"
+       "fmt"
+
        "git.curoverse.com/arvados.git/lib/cmd"
        "git.curoverse.com/arvados.git/lib/service"
        "git.curoverse.com/arvados.git/sdk/go/arvados"
@@ -12,8 +15,17 @@ import (
 
 var Command cmd.Handler = service.Command(arvados.ServiceNameDispatchCloud, newHandler)
 
-func newHandler(cluster *arvados.Cluster, _ *arvados.NodeProfile) service.Handler {
-       d := &dispatcher{Cluster: cluster}
+func newHandler(ctx context.Context, cluster *arvados.Cluster, np *arvados.NodeProfile, token string) service.Handler {
+       ac, err := arvados.NewClientFromConfig(cluster)
+       if err != nil {
+               return service.ErrorHandler(ctx, cluster, np, fmt.Errorf("error initializing client from cluster config: %s", err))
+       }
+       d := &dispatcher{
+               Cluster:   cluster,
+               Context:   ctx,
+               ArvClient: ac,
+               AuthToken: token,
+       }
        go d.Start()
        return d
 }