Skip to content

Commit dc2174e

Browse files
authored
Fix cache overshoot (#200)
* count by hostname * changelog
1 parent 07d5303 commit dc2174e

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
changelog:
2+
- type: FIX
3+
description: Fix a bug where the operator miscounted cache events.
4+
issueLink: https://github.com/solo-io/wasm/issues/199

tools/wasme/cli/operator/install/wasme/templates/deployment.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,12 @@ spec:
122122
- /etc/wasme-cache/images.txt
123123
- --cache-ns
124124
- '{{ .Release.Namespace }}'
125-
{{- if $wasmeCache.env }}
126125
env:
126+
- name: NODE_HOSTNAME
127+
valueFrom:
128+
fieldRef:
129+
fieldPath: spec.nodeName
130+
{{- if $wasmeCache.env }}
127131
{{ toYaml $wasmeCache.env | indent 10 }}
128132
{{- end }}
129133
volumeMounts:

tools/wasme/cli/pkg/cache/notifying_cache.go

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cache
33
import (
44
"crypto/md5"
55
"fmt"
6+
"os"
67

78
"github.com/hashicorp/go-multierror"
89
v1 "k8s.io/api/core/v1"
@@ -56,6 +57,7 @@ func (n *Notifier) Notify(err error, image string) error {
5657
Message: message,
5758
Source: v1.EventSource{
5859
Component: "wasme-cache",
60+
Host: os.Getenv("NODE_HOSTNAME"),
5961
},
6062
})
6163

tools/wasme/cli/pkg/deploy/istio/istio_provider.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,17 @@ func (p *Provider) waitForCacheEvents(image string) error {
290290
return errors.Wrapf(err, "getting events for image %v", image)
291291
}
292292
// expect an event for each cache instance
293-
var successEvents int32
293+
successEvents := map[string]bool{}
294294

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

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

0 commit comments

Comments
 (0)