Skip to content

Commit

Permalink
fix: not a real fix, simply extend the timeout to 24 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
Massimo Gengarelli committed Jun 29, 2024
1 parent 4d84775 commit ab03319
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TERRAFORM := $(shell which terraform)
DOCKER := $(shell which docker)
APPNAME ?= chaos-monkey
IMAGE ?= chaos-monkey
TAG ?= 2.0.1
TAG ?= 2.0.3

all: bin/$(APPNAME)
.PHONY: clean generate bin/$(APPNAME) image-version cluster-test
Expand Down
6 changes: 5 additions & 1 deletion internal/watcher/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ func (c *CrdWatcher) Start(ctx context.Context) error {
var err error
var wg sync.WaitGroup

watchTimeout := int64((24 * time.Hour).Seconds())
w, err := c.ChaosMonkeyConfigurationInterface.Watch(ctx, metav1.ListOptions{
Watch: true,
Watch: true,
TimeoutSeconds: &watchTimeout,
})
if err != nil {
return err
}

defer w.Stop()

c.setRunning(true)

for c.IsRunning() {
Expand Down
8 changes: 7 additions & 1 deletion internal/watcher/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ func (n *NamespaceWatcher) Start(ctx context.Context) error {

logrus.Infof("Starting namespace watcher for %s", n.RootNamespace)

w, err := n.Watch(ctx, v1.ListOptions{})
timeoutSeconds := int64((24 * time.Hour).Seconds())
w, err := n.Watch(ctx, v1.ListOptions{
Watch: true,
TimeoutSeconds: &timeoutSeconds,
})
if err != nil {
return err
}

defer w.Stop()

n.setRunning(true)

for n.IsRunning() {
Expand Down
13 changes: 6 additions & 7 deletions internal/watcher/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ func (p *PodWatcher) IsRunning() bool {
func (p *PodWatcher) Start(ctx context.Context) error {
var err error
logrus.Infof("Starting pod watcher in namespace %s", p.Namespace)

watchTimeout := int64((24 * time.Hour).Seconds())
w, err := p.Watch(ctx, metav1.ListOptions{
Watch: true,
LabelSelector: p.LabelSelector,
Watch: true,
LabelSelector: p.LabelSelector,
TimeoutSeconds: &watchTimeout,
})
if err != nil {
return err
Expand All @@ -116,14 +119,10 @@ func (p *PodWatcher) Start(ctx context.Context) error {

for p.IsRunning() {
select {
case evt, ok := <-w.ResultChan():
case evt := <-w.ResultChan():
logrus.Debugf("Pod Watcher received event: %s", evt.Type)
pod := evt.Object.(*apicorev1.Pod)

if !ok {
return errors.New("Pod Watcher channel closed")
}

switch evt.Type {
case "", watch.Error:
logrus.Errorf("Received empty event or error from pod watcher: %+v", evt)
Expand Down

0 comments on commit ab03319

Please sign in to comment.