From d7b1eaae4b9c190996591f7f6269d5dc6daca7c0 Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Fri, 22 Feb 2019 00:02:34 +0100 Subject: [PATCH] Leave cluster RPC command (#496) Leave cluster RPC command Implement the command to leave a cluster using an agent command and calling the leave method by RPC to the local or remote agent. --- cmd/agent.go | 2 +- cmd/leave.go | 35 +++++++ dkron/agent.go | 18 +++- dkron/api.go | 2 +- dkron/grpc.go | 44 ++++++++- dkron/invoke.go | 7 +- proto/dkron.pb.go | 133 +++++++++++++++++---------- proto/dkron.proto | 2 + website/content/cli/dkron.md | 5 +- website/content/cli/dkron_agent.md | 58 ++++++------ website/content/cli/dkron_doc.md | 4 +- website/content/cli/dkron_keygen.md | 4 +- website/content/cli/dkron_leave.md | 41 +++++++++ website/content/cli/dkron_version.md | 4 +- 14 files changed, 262 insertions(+), 97 deletions(-) create mode 100644 cmd/leave.go create mode 100644 website/content/cli/dkron_leave.md diff --git a/cmd/agent.go b/cmd/agent.go index d52c154fc..b7733914e 100644 --- a/cmd/agent.go +++ b/cmd/agent.go @@ -111,7 +111,7 @@ WAIT: log.Info("agent: Gracefully shutting down agent...") go func() { plugin.CleanupClients() - if err := agent.Leave(); err != nil { + if err := agent.Stop(); err != nil { fmt.Printf("Error: %s", err) log.Error(fmt.Sprintf("Error: %s", err)) return diff --git a/cmd/leave.go b/cmd/leave.go new file mode 100644 index 000000000..0c1cf6428 --- /dev/null +++ b/cmd/leave.go @@ -0,0 +1,35 @@ +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/victorcoder/dkron/dkron" +) + +var rpcAddr string + +// versionCmd represents the version command +var leaveCmd = &cobra.Command{ + Use: "leave", + Short: "Force an agent to leave the cluster", + Long: `Stop stops an agent, if the agent is a server and is running for election + stop running for election, if this server was the leader + this will force the cluster to elect a new leader and start a new scheduler. + If this is a server and has the scheduler started stop it, ignoring if this server + was participating in leader election or not (local storage). + Then actually leave the cluster.`, + RunE: func(cmd *cobra.Command, args []string) error { + var gc dkron.DkronGRPCClient + gc = dkron.NewGRPCClient(nil) + + if err := gc.Leave(rpcAddr); err != nil { + return err + } + + return nil + }, +} + +func init() { + dkronCmd.AddCommand(leaveCmd) + leaveCmd.PersistentFlags().StringVar(&rpcAddr, "rpc-addr", "127.0.0.1:6868", "gRPC address of the agent") +} diff --git a/dkron/agent.go b/dkron/agent.go index b571631e1..bf8b9df82 100644 --- a/dkron/agent.go +++ b/dkron/agent.go @@ -106,11 +106,23 @@ func (a *Agent) Start() error { return nil } +// Stop stops an agent, if the agent is a server and is running for election +// stop running for election, if this server was the leader +// this will force the cluster to elect a new leader and start a new scheduler. +// If this is a server and has the scheduler started stop it, ignoring if this server +// was participating in leader election or not (local storage). +// Then actually leave the cluster. func (a *Agent) Stop() error { - if a.config.Server { + log.Info("agent: Called member stop, now stopping") + + if a.config.Server && a.candidate != nil { a.candidate.Stop() } + if a.config.Server && a.sched.Started { + a.sched.Stop() + } + if err := a.serf.Leave(); err != nil { return err } @@ -595,10 +607,6 @@ func (a *Agent) getRPCAddr() string { return fmt.Sprintf("%s:%d", bindIP, a.config.AdvertiseRPCPort) } -func (a *Agent) Leave() error { - return a.serf.Leave() -} - func (a *Agent) SetTags(tags map[string]string) error { if a.config.Server { tags["dkron_rpc_addr"] = a.getRPCAddr() diff --git a/dkron/api.go b/dkron/api.go index b11d446ae..6b5872c62 100644 --- a/dkron/api.go +++ b/dkron/api.go @@ -237,7 +237,7 @@ func (h *HTTPTransport) leaderHandler(c *gin.Context) { } func (h *HTTPTransport) leaveHandler(c *gin.Context) { - if err := h.agent.serf.Leave(); err != nil { + if err := h.agent.Stop(); err != nil { renderJSON(c, http.StatusOK, h.agent.listServers()) } } diff --git a/dkron/grpc.go b/dkron/grpc.go index ee86f4b8e..ff9f3f6da 100644 --- a/dkron/grpc.go +++ b/dkron/grpc.go @@ -8,6 +8,7 @@ import ( "github.com/abronan/valkeyrie/store" metrics "github.com/armon/go-metrics" + "github.com/golang/protobuf/ptypes/empty" "github.com/sirupsen/logrus" "github.com/victorcoder/dkron/proto" "golang.org/x/net/context" @@ -189,26 +190,36 @@ retry: return execDoneResp, nil } +func (grpcs *GRPCServer) Leave(ctx context.Context, in *empty.Empty) (*empty.Empty, error) { + return in, grpcs.agent.Stop() +} + type DkronGRPCClient interface { Connect(string) (*grpc.ClientConn, error) CallExecutionDone(string, *Execution) error CallGetJob(string, string) (*Job, error) + Leave(string) error } type GRPCClient struct { - dialOpt grpc.DialOption + dialOpt []grpc.DialOption } func NewGRPCClient(dialOpt grpc.DialOption) DkronGRPCClient { if dialOpt == nil { dialOpt = grpc.WithInsecure() } - return &GRPCClient{dialOpt: dialOpt} + return &GRPCClient{dialOpt: []grpc.DialOption{ + dialOpt, + grpc.WithBlock(), + grpc.WithTimeout(5 * time.Second), + }, + } } func (grpcc *GRPCClient) Connect(addr string) (*grpc.ClientConn, error) { // Initiate a connection with the server - conn, err := grpc.Dial(addr, grpcc.dialOpt) + conn, err := grpc.Dial(addr, grpcc.dialOpt...) if err != nil { return nil, err } @@ -267,3 +278,30 @@ func (grpcc *GRPCClient) CallGetJob(addr, jobName string) (*Job, error) { return NewJobFromProto(gjr), nil } + +func (grpcc *GRPCClient) Leave(addr string) error { + var conn *grpc.ClientConn + + // Initiate a connection with the server + conn, err := grpcc.Connect(addr) + if err != nil { + log.WithFields(logrus.Fields{ + "err": err, + "server_addr": addr, + }).Error("grpc: error dialing.") + return err + } + defer conn.Close() + + // Synchronous call + d := proto.NewDkronClient(conn) + _, err = d.Leave(context.Background(), &empty.Empty{}) + if err != nil { + log.WithFields(logrus.Fields{ + "error": err, + }).Warning("grpc: Error calling Leave") + return err + } + + return nil +} diff --git a/dkron/invoke.go b/dkron/invoke.go index f4e08b825..f3a5433c6 100644 --- a/dkron/invoke.go +++ b/dkron/invoke.go @@ -66,8 +66,13 @@ func (a *Agent) invokeJob(job *Job, execution *Execution) error { } func (a *Agent) selectServer() serf.Member { + var server serf.Member + servers := a.listServers() - server := servers[rand.Intn(len(servers))] + + if len(servers) > 0 { + server = servers[rand.Intn(len(servers))] + } return server } diff --git a/proto/dkron.pb.go b/proto/dkron.pb.go index f95ca3854..1e878ecde 100644 --- a/proto/dkron.pb.go +++ b/proto/dkron.pb.go @@ -6,6 +6,7 @@ package proto import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" +import empty "github.com/golang/protobuf/ptypes/empty" import timestamp "github.com/golang/protobuf/ptypes/timestamp" import ( @@ -35,7 +36,7 @@ func (m *GetJobRequest) Reset() { *m = GetJobRequest{} } func (m *GetJobRequest) String() string { return proto.CompactTextString(m) } func (*GetJobRequest) ProtoMessage() {} func (*GetJobRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dkron_3b739081e7b8d623, []int{0} + return fileDescriptor_dkron_53e25a55b3cc2668, []int{0} } func (m *GetJobRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJobRequest.Unmarshal(m, b) @@ -88,7 +89,7 @@ func (m *GetJobResponse) Reset() { *m = GetJobResponse{} } func (m *GetJobResponse) String() string { return proto.CompactTextString(m) } func (*GetJobResponse) ProtoMessage() {} func (*GetJobResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dkron_3b739081e7b8d623, []int{1} + return fileDescriptor_dkron_53e25a55b3cc2668, []int{1} } func (m *GetJobResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_GetJobResponse.Unmarshal(m, b) @@ -238,7 +239,7 @@ func (m *ExecutionDoneRequest) Reset() { *m = ExecutionDoneRequest{} } func (m *ExecutionDoneRequest) String() string { return proto.CompactTextString(m) } func (*ExecutionDoneRequest) ProtoMessage() {} func (*ExecutionDoneRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dkron_3b739081e7b8d623, []int{2} + return fileDescriptor_dkron_53e25a55b3cc2668, []int{2} } func (m *ExecutionDoneRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecutionDoneRequest.Unmarshal(m, b) @@ -326,7 +327,7 @@ func (m *ExecutionDoneResponse) Reset() { *m = ExecutionDoneResponse{} } func (m *ExecutionDoneResponse) String() string { return proto.CompactTextString(m) } func (*ExecutionDoneResponse) ProtoMessage() {} func (*ExecutionDoneResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dkron_3b739081e7b8d623, []int{3} + return fileDescriptor_dkron_53e25a55b3cc2668, []int{3} } func (m *ExecutionDoneResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ExecutionDoneResponse.Unmarshal(m, b) @@ -383,6 +384,7 @@ const _ = grpc.SupportPackageIsVersion4 type DkronClient interface { GetJob(ctx context.Context, in *GetJobRequest, opts ...grpc.CallOption) (*GetJobResponse, error) ExecutionDone(ctx context.Context, in *ExecutionDoneRequest, opts ...grpc.CallOption) (*ExecutionDoneResponse, error) + Leave(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) } type dkronClient struct { @@ -411,10 +413,20 @@ func (c *dkronClient) ExecutionDone(ctx context.Context, in *ExecutionDoneReques return out, nil } +func (c *dkronClient) Leave(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error) { + out := new(empty.Empty) + err := c.cc.Invoke(ctx, "/proto.Dkron/Leave", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // DkronServer is the server API for Dkron service. type DkronServer interface { GetJob(context.Context, *GetJobRequest) (*GetJobResponse, error) ExecutionDone(context.Context, *ExecutionDoneRequest) (*ExecutionDoneResponse, error) + Leave(context.Context, *empty.Empty) (*empty.Empty, error) } func RegisterDkronServer(s *grpc.Server, srv DkronServer) { @@ -457,6 +469,24 @@ func _Dkron_ExecutionDone_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Dkron_Leave_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(empty.Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DkronServer).Leave(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Dkron/Leave", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DkronServer).Leave(ctx, req.(*empty.Empty)) + } + return interceptor(ctx, in, info, handler) +} + var _Dkron_serviceDesc = grpc.ServiceDesc{ ServiceName: "proto.Dkron", HandlerType: (*DkronServer)(nil), @@ -469,54 +499,59 @@ var _Dkron_serviceDesc = grpc.ServiceDesc{ MethodName: "ExecutionDone", Handler: _Dkron_ExecutionDone_Handler, }, + { + MethodName: "Leave", + Handler: _Dkron_Leave_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "dkron.proto", } -func init() { proto.RegisterFile("dkron.proto", fileDescriptor_dkron_3b739081e7b8d623) } - -var fileDescriptor_dkron_3b739081e7b8d623 = []byte{ - // 644 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x6f, 0xdb, 0x38, - 0x10, 0x85, 0xe2, 0xd8, 0xb1, 0x47, 0xb6, 0x93, 0x65, 0x9c, 0x05, 0x57, 0xd9, 0x22, 0x82, 0x8b, - 0x02, 0x6a, 0x0f, 0x0e, 0x90, 0xa0, 0xe8, 0xd7, 0x29, 0x48, 0x8c, 0x02, 0x3e, 0xf4, 0x20, 0xe4, - 0x6e, 0x50, 0xd2, 0xd8, 0x51, 0x62, 0x91, 0x2a, 0x49, 0xb5, 0x75, 0x7f, 0x42, 0x7f, 0x49, 0x8f, - 0xfd, 0x89, 0x05, 0x49, 0xc9, 0x4d, 0x02, 0x03, 0x41, 0x4f, 0x9e, 0xf7, 0xe6, 0x69, 0xc8, 0x19, - 0xbe, 0x31, 0xf8, 0xd9, 0x9d, 0x14, 0x7c, 0x52, 0x4a, 0xa1, 0x05, 0x69, 0xdb, 0x9f, 0xe0, 0x64, - 0x29, 0xc4, 0x72, 0x85, 0xa7, 0x16, 0x25, 0xd5, 0xe2, 0x54, 0xe7, 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0xed, 0xc7, 0x35, 0x22, 0xc7, 0xd0, 0xe3, 0x22, - 0x43, 0x57, 0x6d, 0xd7, 0x8d, 0xda, 0x10, 0xb6, 0xdc, 0x08, 0xda, 0x4b, 0x29, 0xaa, 0x92, 0xb6, - 0x43, 0x2f, 0x6a, 0xc5, 0x0e, 0x98, 0x43, 0x98, 0xd6, 0x58, 0x94, 0x9a, 0x76, 0x9c, 0x3d, 0x6a, - 0x48, 0xde, 0x01, 0x28, 0xcd, 0xa4, 0xc6, 0x6c, 0xce, 0xb4, 0xdd, 0x05, 0xff, 0x2c, 0x98, 0xb8, - 0x3d, 0x9e, 0x34, 0x7b, 0x3c, 0xb9, 0x6e, 0xf6, 0x38, 0xee, 0xd5, 0xea, 0x0b, 0x4d, 0x3e, 0x80, - 0xbf, 0xc8, 0x79, 0xae, 0x6e, 0xdc, 0xb7, 0xdd, 0x27, 0xbf, 0x85, 0x46, 0x7e, 0xa1, 0xc7, 0x53, - 0x38, 0x7a, 0x34, 0xa9, 0x3f, 0x3b, 0xbe, 0x90, 0xa2, 0x68, 0x76, 0xdc, 0xc4, 0xe6, 0xfa, 0x25, - 0x5b, 0xaf, 0x04, 0xcb, 0xec, 0x8c, 0xfa, 0x71, 0x03, 0xcf, 0x7e, 0x78, 0xd0, 0xbe, 0x32, 0x7f, - 0x44, 0xe4, 0x35, 0x74, 0x9c, 0x8b, 0xc8, 0xe8, 0x91, 0xa9, 0xec, 0x13, 0x04, 0x47, 0x5b, 0xad, - 0x46, 0x66, 0x30, 0x78, 0x70, 0x0f, 0x72, 0x5c, 0xeb, 0xb6, 0xbd, 0x63, 0xf0, 0xff, 0xf6, 0xa4, - 0xab, 0x95, 0x74, 0x6c, 0xf2, 0xfc, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x92, 0x66, 0x1c, 0x16, - 0x1b, 0x05, 0x00, 0x00, +func init() { proto.RegisterFile("dkron.proto", fileDescriptor_dkron_53e25a55b3cc2668) } + +var fileDescriptor_dkron_53e25a55b3cc2668 = []byte{ + // 668 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x5d, 0x4f, 0xdb, 0x30, + 0x14, 0x55, 0x28, 0x29, 0xed, 0xed, 0x07, 0xcc, 0x14, 0xe4, 0x85, 0x4d, 0x44, 0x9d, 0x26, 0x75, + 0x7b, 0x28, 0x12, 0x68, 0x62, 0x1f, 0x4f, 0x08, 0xaa, 0x49, 0xd5, 0xb4, 0x87, 0x88, 0xf7, 0xca, + 0x49, 0x6e, 0x4b, 0xa0, 0xb5, 0x33, 0xdb, 0x61, 0xeb, 0x7e, 0xd1, 0x1e, 0xf7, 0x1f, 0xf6, 0xc7, + 0x26, 0xdb, 0x49, 0x07, 0xac, 0x13, 0xda, 0x53, 0xef, 0x39, 0xf7, 0xf4, 0xda, 0xf7, 0xfa, 0xdc, + 0x40, 0x2b, 0xbd, 0x91, 0x82, 0x0f, 0x73, 0x29, 0xb4, 0x20, 0xbe, 0xfd, 0x09, 0x0e, 0x67, 0x42, + 0xcc, 0xe6, 0x78, 0x64, 0x51, 0x5c, 0x4c, 0x8f, 0x74, 0xb6, 0x40, 0xa5, 0xd9, 0x22, 0x77, 0xba, + 0xe0, 0xe0, 0xa1, 0x00, 0x17, 0xb9, 0x5e, 0xba, 0x64, 0xff, 0x35, 0x74, 0x3e, 0xa2, 0x1e, 0x8b, + 0x38, 0xc2, 0x2f, 0x05, 0x2a, 0x4d, 0x9e, 0x42, 0xe3, 0x5a, 0xc4, 0x13, 0xce, 0x16, 0x48, 0xbd, + 0xd0, 0x1b, 0x34, 0xa3, 0xad, 0x6b, 0x11, 0x7f, 0x66, 0x0b, 0xec, 0xff, 0xf4, 0xa1, 0x5b, 0x89, + 0x55, 0x2e, 0xb8, 0x42, 0x42, 0x60, 0xf3, 0x8e, 0xd2, 0xc6, 0x24, 0x80, 0x86, 0xb9, 0xc2, 0x77, + 0xc1, 0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 0xab, 0x25, + 0x8f, 0x9a, 0xa5, 0xfa, 0x4c, 0x93, 0x0f, 0xd0, 0x9a, 0x66, 0x3c, 0x53, 0x57, 0xee, 0xbf, 0x8d, + 0x47, 0xff, 0x0b, 0x95, 0xfc, 0x4c, 0xf7, 0x47, 0xb0, 0xf7, 0x60, 0x52, 0x7f, 0x76, 0x7c, 0x2a, + 0xc5, 0xa2, 0xda, 0x71, 0x13, 0x9b, 0xeb, 0xe7, 0x6c, 0x39, 0x17, 0x2c, 0xb5, 0x33, 0x6a, 0x47, + 0x15, 0x3c, 0xfe, 0xe5, 0x81, 0x7f, 0x61, 0xbe, 0x52, 0xe4, 0x0d, 0xd4, 0x9d, 0x8b, 0x48, 0xef, + 0x81, 0xa9, 0xec, 0x13, 0x04, 0x7b, 0x6b, 0xad, 0x46, 0xc6, 0xd0, 0xb9, 0x77, 0x0f, 0x72, 0x50, + 0xea, 0xd6, 0xbd, 0x63, 0xf0, 0x6c, 0x7d, 0xb2, 0xac, 0x75, 0x0a, 0xfe, 0x27, 0x64, 0xb7, 0x48, + 0xf6, 0xff, 0x1a, 0xc2, 0xc8, 0x7c, 0x04, 0x83, 0x7f, 0xf0, 0x71, 0xdd, 0xe2, 0x93, 0xdf, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x14, 0x0c, 0x54, 0x28, 0x71, 0x05, 0x00, 0x00, } diff --git a/proto/dkron.proto b/proto/dkron.proto index e100d0b84..d2051bc9b 100644 --- a/proto/dkron.proto +++ b/proto/dkron.proto @@ -4,6 +4,7 @@ syntax = "proto3"; package proto; import "google/protobuf/timestamp.proto"; +import "google/protobuf/empty.proto"; message GetJobRequest { string job_name = 1; @@ -47,4 +48,5 @@ message ExecutionDoneResponse { service Dkron { rpc GetJob (GetJobRequest) returns (GetJobResponse); rpc ExecutionDone (ExecutionDoneRequest) returns (ExecutionDoneResponse); + rpc Leave (google.protobuf.Empty) returns (google.protobuf.Empty); } diff --git a/website/content/cli/dkron.md b/website/content/cli/dkron.md index 88e23d8c6..3ab4e3c06 100644 --- a/website/content/cli/dkron.md +++ b/website/content/cli/dkron.md @@ -1,5 +1,5 @@ --- -date: 2018-11-26 +date: 2019-02-21 title: "dkron" slug: dkron url: /cli/dkron/ @@ -26,6 +26,7 @@ If a machine fails (the leader), a follower will take over and keep running the * [dkron agent](/cli/dkron_agent/) - Start a dkron agent * [dkron doc](/cli/dkron_doc/) - Generate Markdown documentation for the Dkron CLI. * [dkron keygen](/cli/dkron_keygen/) - Generates a new encryption key +* [dkron leave](/cli/dkron_leave/) - Force an agent to leave the cluster * [dkron version](/cli/dkron_version/) - Show version -###### Auto generated by spf13/cobra on 26-Nov-2018 +###### Auto generated by spf13/cobra on 21-Feb-2019 diff --git a/website/content/cli/dkron_agent.md b/website/content/cli/dkron_agent.md index a943f6556..431dee213 100644 --- a/website/content/cli/dkron_agent.md +++ b/website/content/cli/dkron_agent.md @@ -1,5 +1,5 @@ --- -date: 2018-11-26 +date: 2019-02-21 title: "dkron agent" slug: dkron_agent url: /cli/dkron_agent/ @@ -20,35 +20,35 @@ dkron agent [flags] ### Options ``` - --advertise-addr string Address used to advertise to other nodes in the cluster. By default, the bind address is advertised. - --advertise-rpc-port int Use the value of rpc-port by default. - --backend string store backend (default "boltdb") - --backend-machine strings store backend machines addresses (default [./dkron.db]) - --bind-addr string Address to bind network listeners to. (default "0.0.0.0:8946") - --dog-statsd-addr string DataDog Agent address. + --advertise-addr string Address used to advertise to other nodes in the cluster. By default, the bind address is advertised + --advertise-rpc-port int Use the value of rpc-port by default + --backend string Store backend (etcd|etcdv3|consul|zk|redis|boltdb|dynamodb) (default "boltdb") + --backend-machine strings Store backend machines addresses (default [./dkron.db]) + --bind-addr string Address to bind network listeners to (default "0.0.0.0:8946") + --dog-statsd-addr string DataDog Agent address --dog-statsd-tags strings Datadog tags, specified as key:value - --encrypt string Key for encrypting network traffic. Must be a base64-encoded 16-byte key. + --encrypt string Key for encrypting network traffic. Must be a base64-encoded 16-byte key -h, --help help for agent - --http-addr string Address to bind the UI web server to. Only used when server. (default ":8080") - --join strings An initial agent to join with. This flag can be specified multiple times. - --keyspace string The keyspace to use. A prefix under all data is stored for this instance. (default "dkron") - --log-level string Log level (debug, info, warn, error, fatal, panic), defaults to info (default "info") - --mail-from string From email address to use. - --mail-host string Mail server host address to use for notifications. - --mail-password string Mail server password to use. - --mail-payload string Notification mail payload. - --mail-port string Mail server port. - --mail-subject-prefix string Notification mail subject prefix. (default "[Dkron]") - --mail-username string Mail server username used for authentication. - --node-name string Name of this node. Must be unique in the cluster. (default "pris.local") - --profile string Profile is used to control the timing profiles used. The default if not provided is lan. (default "lan") - --rpc-port int RPC Port used to communicate with clients. Only used when server. The RPC IP Address will be the same as the bind address. (default 6868) - --server This node is running in server mode. - --statsd-addr string Statsd Address. - --tag strings Tag can be specified multiple times to attach multiple key/value tag pairs to the given node. Specified as key=value - --webhook-header strings Headers to use when calling the webhook URL. Can be specified multiple times. - --webhook-payload string Body of the POST request to send on webhook call. - --webhook-url string Webhook url to call for notifications. + --http-addr string Address to bind the UI web server to. Only used when server (default ":8080") + --join strings An initial agent to join with. This flag can be specified multiple times + --keyspace string The keyspace to use. A prefix under all data is stored for this instance (default "dkron") + --log-level string Log level (debug|info|warn|error|fatal|panic) (default "info") + --mail-from string From email address to use + --mail-host string Mail server host address to use for notifications + --mail-password string Mail server password to use + --mail-payload string Notification mail payload + --mail-port uint16 Mail server port + --mail-subject-prefix string Notification mail subject prefix (default "[Dkron]") + --mail-username string Mail server username used for authentication + --node-name string Name of this node. Must be unique in the cluster (default "pris.local") + --profile string Profile is used to control the timing profiles used (default "lan") + --rpc-port int RPC Port used to communicate with clients. Only used when server. The RPC IP Address will be the same as the bind address (default 6868) + --server This node is running in server mode + --statsd-addr string Statsd address + --tag strings Tag can be specified multiple times to attach multiple key/value tag pairs to the given node, specified as key=value + --webhook-header strings Headers to use when calling the webhook URL. Can be specified multiple times + --webhook-payload string Body of the POST request to send on webhook call + --webhook-url string Webhook url to call for notifications ``` ### Options inherited from parent commands @@ -61,4 +61,4 @@ dkron agent [flags] * [dkron](/cli/dkron/) - Open source distributed job scheduling system -###### Auto generated by spf13/cobra on 26-Nov-2018 +###### Auto generated by spf13/cobra on 21-Feb-2019 diff --git a/website/content/cli/dkron_doc.md b/website/content/cli/dkron_doc.md index d34772612..4adbc3299 100644 --- a/website/content/cli/dkron_doc.md +++ b/website/content/cli/dkron_doc.md @@ -1,5 +1,5 @@ --- -date: 2018-11-26 +date: 2019-02-21 title: "dkron doc" slug: dkron_doc url: /cli/dkron_doc/ @@ -37,4 +37,4 @@ dkron doc [flags] * [dkron](/cli/dkron/) - Open source distributed job scheduling system -###### Auto generated by spf13/cobra on 26-Nov-2018 +###### Auto generated by spf13/cobra on 21-Feb-2019 diff --git a/website/content/cli/dkron_keygen.md b/website/content/cli/dkron_keygen.md index 159cdd246..f34d96302 100644 --- a/website/content/cli/dkron_keygen.md +++ b/website/content/cli/dkron_keygen.md @@ -1,5 +1,5 @@ --- -date: 2018-11-26 +date: 2019-02-21 title: "dkron keygen" slug: dkron_keygen url: /cli/dkron_keygen/ @@ -34,4 +34,4 @@ dkron keygen [flags] * [dkron](/cli/dkron/) - Open source distributed job scheduling system -###### Auto generated by spf13/cobra on 26-Nov-2018 +###### Auto generated by spf13/cobra on 21-Feb-2019 diff --git a/website/content/cli/dkron_leave.md b/website/content/cli/dkron_leave.md new file mode 100644 index 000000000..077a7595a --- /dev/null +++ b/website/content/cli/dkron_leave.md @@ -0,0 +1,41 @@ +--- +date: 2019-02-21 +title: "dkron leave" +slug: dkron_leave +url: /cli/dkron_leave/ +--- +## dkron leave + +Force an agent to leave the cluster + +### Synopsis + +Stop stops an agent, if the agent is a server and is running for election + stop running for election, if this server was the leader + this will force the cluster to elect a new leader and start a new scheduler. + If this is a server and has the scheduler started stop it, ignoring if this server + was participating in leader election or not (local storage). + Then actually leave the cluster. + +``` +dkron leave [flags] +``` + +### Options + +``` + -h, --help help for leave + --rpc-addr string gRPC address of the agent (default "127.0.0.1:6868") +``` + +### Options inherited from parent commands + +``` + --config string config file path +``` + +### SEE ALSO + +* [dkron](/cli/dkron/) - Open source distributed job scheduling system + +###### Auto generated by spf13/cobra on 21-Feb-2019 diff --git a/website/content/cli/dkron_version.md b/website/content/cli/dkron_version.md index 37aa89eaa..c069e27f5 100644 --- a/website/content/cli/dkron_version.md +++ b/website/content/cli/dkron_version.md @@ -1,5 +1,5 @@ --- -date: 2018-11-26 +date: 2019-02-21 title: "dkron version" slug: dkron_version url: /cli/dkron_version/ @@ -32,4 +32,4 @@ dkron version [flags] * [dkron](/cli/dkron/) - Open source distributed job scheduling system -###### Auto generated by spf13/cobra on 26-Nov-2018 +###### Auto generated by spf13/cobra on 21-Feb-2019