Skip to content

Commit

Permalink
Revert "Implement systemd notification support after all templates ha…
Browse files Browse the repository at this point in the history
…ve been rendered (#1794)" (#1837)

This reverts commit 6b9060e.
  • Loading branch information
roncodingenthusiast committed Nov 10, 2023
1 parent 6b9060e commit 8593a9c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 109 deletions.
21 changes: 0 additions & 21 deletions manager/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/hashicorp/consul-template/config"
dep "github.com/hashicorp/consul-template/dependency"
"github.com/hashicorp/consul-template/renderer"
"github.com/hashicorp/consul-template/systemd"
"github.com/hashicorp/consul-template/template"
"github.com/hashicorp/consul-template/watch"

Expand All @@ -33,10 +32,6 @@ const (
viewLimit = 128
)

type notifier interface {
Notify(string) error
}

// Runner responsible rendering Templates and invoking Commands.
type Runner struct {
// ErrCh and DoneCh are channels where errors and finish notifications occur.
Expand Down Expand Up @@ -113,12 +108,6 @@ type Runner struct {
// NOTE this is only used when CT is being used as a library.
Env map[string]string

// notifier is called after all templates have been successfully rendered
notifier notifier

// ready indicates that the runner has rendered each template at least once
ready bool

// stopLock is the lock around checking if the runner can be stopped
stopLock sync.Mutex

Expand Down Expand Up @@ -388,13 +377,6 @@ func (r *Runner) Start() {
r.Stop()
return
}

if r.notifier != nil && !r.ready {
if notifErr := r.notifier.Notify(systemd.Ready); notifErr != nil {
log.Printf("[DEBUG] (runner) systemd notify failed: %v", notifErr)
}
}
r.ready = true
}

OUTER:
Expand Down Expand Up @@ -1018,9 +1000,6 @@ func (r *Runner) init(clients *dep.ClientSet) error {
}
}

r.notifier = &systemd.Notifier{}
r.ready = false

return nil
}

Expand Down
53 changes: 0 additions & 53 deletions manager/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package manager
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand All @@ -21,13 +20,6 @@ import (
"github.com/hashicorp/consul-template/template"
)

type mockNotifier struct{ s string }

func (n *mockNotifier) Notify(state string) error {
n.s = state
return nil
}

func TestRunner_initTemplates(t *testing.T) {
c := config.TestConfig(
&config.Config{
Expand Down Expand Up @@ -557,51 +549,6 @@ func TestRunner_Start(t *testing.T) {
}
})

t.Run("notify", func(t *testing.T) {
t.Parallel()

out, err := ioutil.TempFile("", "")
if err != nil {
t.Fatal(err)
}
defer os.Remove(out.Name())

c := config.DefaultConfig().Merge(&config.Config{
Templates: &config.TemplateConfigs{
&config.TemplateConfig{
Contents: config.String(`test`),
Destination: config.String(out.Name()),
},
},
})
c.Finalize()

r, err := NewRunner(c, false)
if err != nil {
t.Fatal(err)
}

notify := &mockNotifier{}
r.notifier = notify

go r.Start()
defer r.Stop()

select {
case err := <-r.ErrCh:
t.Fatal(err)
case <-r.renderedCh:
if !r.ready {
t.Errorf("\nexp: %#v\nact: %#v", true, r.ready)
}
if exp, act := "READY=1", notify.s; exp != act {
t.Errorf("\nexp: %#v\nact: %#v", exp, act)
}
case <-time.After(2 * time.Second):
t.Fatal("timeout")
}
})

t.Run("run_no_deps", func(t *testing.T) {
out, err := os.CreateTemp("", "")
if err != nil {
Expand Down
35 changes: 0 additions & 35 deletions systemd/notifier.go

This file was deleted.

0 comments on commit 8593a9c

Please sign in to comment.