Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ip changes #2

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,38 @@ dockers:
build_flag_templates:
- --platform=linux/arm/v7

- image_templates:
- dkron/{{ .ProjectName }}:{{ .Version }}-light-amd64
dockerfile: Dockerfile.release
use: buildx
goos: linux
goarch: amd64
ids: &docker-ids
- dkron
build_flag_templates:
- --platform=linux/amd64

- image_templates:
- dkron/{{ .ProjectName }}:{{ .Version }}-light-arm64
dockerfile: Dockerfile.release
use: buildx
goos: linux
goarch: arm64
ids: *docker-ids
build_flag_templates:
- --platform=linux/arm64/v8

- image_templates:
- dkron/{{ .ProjectName }}:{{ .Version }}-light-armv7
dockerfile: Dockerfile.release
use: buildx
goos: linux
goarch: arm
goarm: '7'
ids: *docker-ids
build_flag_templates:
- --platform=linux/arm/v7

docker_manifests:
- name_template: dkron/{{ .ProjectName }}:{{ .Version }}
image_templates:
Expand All @@ -174,6 +206,12 @@ docker_manifests:
- dkron/{{ .ProjectName }}:{{ .Version }}-arm64
- dkron/{{ .ProjectName }}:{{ .Version }}-armv7

- name_template: dkron/{{ .ProjectName }}:{{ .Version }}-light
image_templates:
- dkron/{{ .ProjectName }}:{{ .Version }}-light-amd64
- dkron/{{ .ProjectName }}:{{ .Version }}-light-arm64
- dkron/{{ .ProjectName }}:{{ .Version }}-light-armv7

changelog:
sort: asc
filters:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM golang:1.18
LABEL maintainer="Victor Castell <victor@victorcastell.com>"
FROM golang:1.21
LABEL maintainer="Victor Castell <0x@vcastellm.xyz>"

EXPOSE 8080 8946

Expand Down
15 changes: 15 additions & 0 deletions Dockerfile.light.hub
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine:3.19
LABEL maintainer="Victor Castell <0x@vcastellm.xyz>"

RUN set -x \
&& buildDeps='bash ca-certificates openssl tzdata' \
&& apk add --no-cache --update $buildDeps

EXPOSE 8080 8946

ENV SHELL /bin/bash
COPY dkron /usr/local/bin/

ENTRYPOINT ["/usr/local/bin/dkron"]

CMD ["--help"]
4 changes: 2 additions & 2 deletions Dockerfile.release
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM alpine:3.15
LABEL maintainer="Victor Castell <victor@victorcastell.com>"
FROM alpine:3.19
LABEL maintainer="Victor Castell <0x@vcastellm.xyz>"

RUN set -x \
&& buildDeps='bash ca-certificates openssl tzdata' \
Expand Down
34 changes: 0 additions & 34 deletions builtin/bins/dkron-executor-shell/main.go

This file was deleted.

16 changes: 10 additions & 6 deletions cmd/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,37 @@ func (p *Plugins) DiscoverPlugins() error {
}

for _, file := range processors {

pluginName, ok := getPluginName(file)
if !ok {
continue
}

raw, err := p.pluginFactory(file, dkplugin.ProcessorPluginName)
raw, err := p.pluginFactory(file, []string{}, dkplugin.ProcessorPluginName)
if err != nil {
return err
}
p.Processors[pluginName] = raw.(dkplugin.Processor)
}

for _, file := range executors {

pluginName, ok := getPluginName(file)
if !ok {
continue
}

raw, err := p.pluginFactory(file, dkplugin.ExecutorPluginName)
raw, err := p.pluginFactory(file, []string{}, dkplugin.ExecutorPluginName)
if err != nil {
return err
}
p.Executors[pluginName] = raw.(dkplugin.Executor)
}

raw, err := p.pluginFactory(exePath, []string{"shell"}, dkplugin.ExecutorPluginName)
if err != nil {
return err
}
p.Executors["shell"] = raw.(dkplugin.Executor)

return nil
}

Expand All @@ -113,10 +117,10 @@ func getPluginName(file string) (string, bool) {
return name, true
}

func (p *Plugins) pluginFactory(path string, pluginType string) (interface{}, error) {
func (p *Plugins) pluginFactory(path string, args []string, pluginType string) (interface{}, error) {
// Build the plugin client configuration and init the plugin
var config plugin.ClientConfig
config.Cmd = exec.Command(path)
config.Cmd = exec.Command(path, args...)
config.HandshakeConfig = dkplugin.Handshake
config.Managed = true
config.Plugins = dkplugin.PluginMap
Expand Down
30 changes: 30 additions & 0 deletions cmd/shell.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
dkplugin "github.com/distribworks/dkron/v3/plugin"
"github.com/distribworks/dkron/v3/plugin/shell"
"github.com/hashicorp/go-plugin"
"github.com/spf13/cobra"
)

var shellCmd = &cobra.Command{
Hidden: true,
Use: "shell",
Short: "Shell plugin for dkron",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
plugin.Serve(&plugin.ServeConfig{
HandshakeConfig: dkplugin.Handshake,
Plugins: map[string]plugin.Plugin{
"executor": &dkplugin.ExecutorPlugin{Executor: &shell.Shell{}},
},

// A non-nil value here enables gRPC serving for this plugin...
GRPCServer: plugin.DefaultGRPCServer,
})
},
}

func init() {
dkronCmd.AddCommand(shellCmd)
}
25 changes: 18 additions & 7 deletions dkron/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ type Agent struct {

// peers is used to track the known Dkron servers. This is
// used for region forwarding and clustering.
peers map[string][]*ServerParts
localPeers map[raft.ServerAddress]*ServerParts
peerLock sync.RWMutex
peers map[string][]*ServerParts
localPeers map[raft.ServerAddress]*ServerParts
peerLock sync.RWMutex
serverLookup *ServerLookup

activeExecutions sync.Map

Expand All @@ -142,8 +143,9 @@ type AgentOption func(agent *Agent)
// and running a Dkron instance.
func NewAgent(config *Config, options ...AgentOption) *Agent {
agent := &Agent{
config: config,
retryJoinCh: make(chan error),
config: config,
retryJoinCh: make(chan error),
serverLookup: NewServerLookup(),
}

for _, option := range options {
Expand Down Expand Up @@ -316,7 +318,13 @@ func (a *Agent) setupRaft() error {
logger = a.logger.Logger.Writer()
}

transport := raft.NewNetworkTransport(a.raftLayer, 3, raftTimeout, logger)
transConfig := &raft.NetworkTransportConfig{
Stream: a.raftLayer,
MaxPool: 3,
Timeout: raftTimeout,
ServerAddressProvider: a.serverLookup,
}
transport := raft.NewNetworkTransportWithConfig(transConfig)
a.raftTransport = transport

config := raft.DefaultConfig()
Expand Down Expand Up @@ -710,7 +718,10 @@ func (a *Agent) eventLoop() {
a.localMemberEvent(me)
case serf.EventMemberReap:
a.localMemberEvent(me)
case serf.EventMemberUpdate, serf.EventUser, serf.EventQuery: // Ignore
case serf.EventMemberUpdate:
a.lanNodeUpdate(me)
a.localMemberEvent(me)
case serf.EventUser, serf.EventQuery: // Ignore
default:
a.logger.WithField("event", e.String()).Warn("agent: Unhandled serf event")
}
Expand Down
2 changes: 1 addition & 1 deletion dkron/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var (
logLevel = "error"
logLevel = "info"
)

func TestAgentCommand_runForElection(t *testing.T) {
Expand Down
3 changes: 0 additions & 3 deletions dkron/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func NewTransport(a *Agent, log *logrus.Entry) *HTTPTransport {

func (h *HTTPTransport) ServeHTTP() {
h.Engine = gin.Default()
h.Engine.HTMLRender = CreateMyRender(h.logger)
h.Engine.Use(h.Options)

rootPath := h.Engine.Group("/")
Expand All @@ -66,8 +65,6 @@ func (h *HTTPTransport) ServeHTTP() {
h.APIRoutes(rootPath)
if h.agent.config.UI {
h.UI(rootPath)
} else {
h.agent.DashboardRoutes(rootPath)
}

h.logger.WithFields(logrus.Fields{
Expand Down
10 changes: 0 additions & 10 deletions dkron/assets/assets.go

This file was deleted.

12,589 changes: 0 additions & 12,589 deletions dkron/assets/assets_vfsdata.go

This file was deleted.

3 changes: 0 additions & 3 deletions dkron/assets/generate.go

This file was deleted.

Loading