@@ -10,7 +10,6 @@ import (
1010 "github.com/Azure/azure-container-networking/cns/logger"
1111 "github.com/Azure/azure-container-networking/cns/types"
1212 "github.com/Azure/azure-container-networking/nmagent"
13- "github.com/patrickmn/go-cache"
1413 "github.com/pkg/errors"
1514)
1615
@@ -50,14 +49,25 @@ func (h *HomeAzMonitor) updateCacheValue(resp cns.GetHomeAzResponse) {
5049
5150// readCacheValue reads home az cache value
5251func (h * HomeAzMonitor ) readCacheValue () cns.GetHomeAzResponse {
53- cachedResp , found := h .values .Get (homeAzCacheKey )
54- if ! found {
55- return cns.GetHomeAzResponse {Response : cns.Response {
52+ if cachedResp , found := h .values .Get (homeAzCacheKey ); found {
53+ return cachedResp .(cns.GetHomeAzResponse )
54+ }
55+
56+ ctx , cancel := context .WithTimeout (context .Background (), ContextTimeOut )
57+ defer cancel ()
58+ h .Populate (ctx )
59+
60+ if cachedResp , found := h .values .Get (homeAzCacheKey ); found {
61+ return cachedResp .(cns.GetHomeAzResponse )
62+ }
63+
64+ return cns.GetHomeAzResponse {
65+ Response : cns.Response {
5666 ReturnCode : types .NotFound ,
5767 Message : "HomeAz Cache is unavailable" ,
58- }, HomeAzResponse : cns.HomeAzResponse {IsSupported : false }}
68+ },
69+ HomeAzResponse : cns.HomeAzResponse {IsSupported : false },
5970 }
60- return cachedResp .(cns.GetHomeAzResponse )
6171}
6272
6373// Start starts a new thread to refresh home az cache
0 commit comments