diff --git a/cmd/keel/main.go b/cmd/keel/main.go index 77f9f008..68e5806e 100644 --- a/cmd/keel/main.go +++ b/cmd/keel/main.go @@ -225,7 +225,15 @@ func setupProviders(k8sImplementer kubernetes.Implementer, sender notification.S "error": err, }).Fatal("main.setupProviders: failed to create kubernetes provider") } - go k8sProvider.Start() + go func() { + err := k8sProvider.Start() + if err != nil { + log.WithFields(log.Fields{ + "error": err, + }).Fatal("kubernetes provider stopped with an error") + } + }() + enabledProviders = append(enabledProviders, k8sProvider) if os.Getenv(EnvHelmProvider) == "1" { @@ -233,7 +241,15 @@ func setupProviders(k8sImplementer kubernetes.Implementer, sender notification.S helmImplementer := helm.NewHelmImplementer(tillerAddr) helmProvider := helm.NewProvider(helmImplementer, sender, approvalsManager) - go helmProvider.Start() + go func() { + err := helmProvider.Start() + if err != nil { + log.WithFields(log.Fields{ + "error": err, + }).Fatal("helm provider stopped with an error") + } + }() + enabledProviders = append(enabledProviders, helmProvider) } @@ -253,7 +269,15 @@ func setupTriggers(ctx context.Context, providers provider.Providers, approvalsM ApprovalManager: approvalsManager, }) - go whs.Start() + go func() { + err := whs.Start() + if err != nil { + log.WithFields(log.Fields{ + "error": err, + "port": types.KeelDefaultPort, + }).Fatal("trigger server stopped") + } + }() // checking whether pubsub (GCR) trigger is enabled if os.Getenv(EnvTriggerPubSub) != "" { diff --git a/trigger/http/registry_notifications.go b/trigger/http/registry_notifications.go index 7ec89c69..ba48799b 100644 --- a/trigger/http/registry_notifications.go +++ b/trigger/http/registry_notifications.go @@ -2,7 +2,6 @@ package http import ( "encoding/json" - "fmt" "net/http" "time" @@ -99,18 +98,18 @@ func (s *TriggerServer) registryNotificationHandler(resp http.ResponseWriter, re return } + log.WithFields(log.Fields{ + "event": rn, + }).Debug("registryNotificationHandler: received event, looking for a push tag") + for _, e := range rn.Events { if e.Action != "push" { - // ignoring non-push events - resp.WriteHeader(200) - return + continue } if e.Target.Tag == "" { - resp.WriteHeader(http.StatusBadRequest) - fmt.Fprintf(resp, "tag cannot be empty") - return + continue } dockerURL := e.Request.Host + "/" + e.Target.Repository @@ -122,10 +121,16 @@ func (s *TriggerServer) registryNotificationHandler(resp http.ResponseWriter, re event.Repository.Tag = e.Target.Tag event.Repository.Digest = e.Target.Digest + log.WithFields(log.Fields{ + "action": e.Action, + "tag": e.Target.Tag, + "repository": dockerURL, + "digest": e.Target.Digest, + }).Debug("registryNotificationHandler: got registry notification, processing") + s.trigger(event) newRegistryNotificationWebhooksCounter.With(prometheus.Labels{"image": event.Repository.Name}).Inc() - } }