Skip to content

Commit

Permalink
Fix cache overshoot (#200)
Browse files Browse the repository at this point in the history
* count by hostname

* changelog
  • Loading branch information
yuval-k authored Oct 13, 2020
1 parent 07d5303 commit dc2174e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions tools/wasme/changelog/v0.0.28/cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changelog:
- type: FIX
description: Fix a bug where the operator miscounted cache events.
issueLink: https://github.com/solo-io/wasm/issues/199
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ spec:
- /etc/wasme-cache/images.txt
- --cache-ns
- '{{ .Release.Namespace }}'
{{- if $wasmeCache.env }}
env:
- name: NODE_HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
{{- if $wasmeCache.env }}
{{ toYaml $wasmeCache.env | indent 10 }}
{{- end }}
volumeMounts:
Expand Down
2 changes: 2 additions & 0 deletions tools/wasme/cli/pkg/cache/notifying_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cache
import (
"crypto/md5"
"fmt"
"os"

"github.com/hashicorp/go-multierror"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -56,6 +57,7 @@ func (n *Notifier) Notify(err error, image string) error {
Message: message,
Source: v1.EventSource{
Component: "wasme-cache",
Host: os.Getenv("NODE_HOSTNAME"),
},
})

Expand Down
6 changes: 3 additions & 3 deletions tools/wasme/cli/pkg/deploy/istio/istio_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,17 @@ func (p *Provider) waitForCacheEvents(image string) error {
return errors.Wrapf(err, "getting events for image %v", image)
}
// expect an event for each cache instance
var successEvents int32
successEvents := map[string]bool{}

for _, evt := range events {
if evt.Reason == cache.Reason_ImageError {
logrus.Warnf("event %v was in Error state: %+v", evt.Name, evt)
continue
}
successEvents++
successEvents[evt.Source.Host] = true
}

if successEvents != cacheDaemonset.Status.NumberReady {
if len(successEvents) != int(cacheDaemonset.Status.NumberReady) {
eventsErr = errors.Errorf("expected %v image-ready events for image %v, only found %v", cacheDaemonset.Status.NumberReady, image, successEvents)
logrus.Warnf("event err: %v", eventsErr)
continue
Expand Down

0 comments on commit dc2174e

Please sign in to comment.