Skip to content

Commit

Permalink
pillar/zedagent,zedcloud: create separate deferred context for the LO…
Browse files Browse the repository at this point in the history
…C reqs

LOC has different URL, so controller and LOC deferred requests can't be
placed into the same queue due to the same requests keys. Having two
destinations (controller + LOC), the second sender overrides a deferred
item, so first one destination will be never reached.

First attempt to fix this was made here:

   62b00e2 ("zedcloud/deferred: respect URL argument as a key on starting new deferred")

But this introduces more problems then fixes them (for example
`RemoveDeferred()` was not covered at all).

This is the proper way to deal with different destinations.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
  • Loading branch information
rouming authored and milan-zededa committed Jul 1, 2024
1 parent fa86bc1 commit 713af84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 4 additions & 1 deletion pkg/pillar/cmd/zedagent/zedagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func queueInfoToDest(ctx *zedagentContext, dest destinationBitset,
devUUID, "info")
// Ignore errors for all the LOC info messages
const ignoreErr = true
zedcloudCtx.DeferredPeriodicCtx.SetDeferred(key, buf, size, url,
zedcloudCtx.DeferredLOCPeriodicCtx.SetDeferred(key, buf, size, url,
bailOnHTTPErr, withNetTracing, ignoreErr, itemType)
}
}
Expand Down Expand Up @@ -437,6 +437,9 @@ func Run(ps *pubsub.PubSub, loggerArg *logrus.Logger, logArg *base.LogObject, ar
zedcloudCtx.DeferredPeriodicCtx = zedcloud.CreateDeferredCtx(zedcloudCtx,
zedagentCtx.ps, agentName, "DeferredPeriodic",
warningTime, errorTime, nil)
zedcloudCtx.DeferredLOCPeriodicCtx = zedcloud.CreateDeferredCtx(zedcloudCtx,
zedagentCtx.ps, agentName, "DeferredLOCPeriodic",
warningTime, errorTime, nil)
// XXX defer this until we have some config from cloud or saved copy
getconfigCtx.pubAppInstanceConfig.SignalRestarted()

Expand Down
19 changes: 12 additions & 7 deletions pkg/pillar/zedcloud/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,20 @@ type ZedCloudContext struct {
serverSigningCertHash []byte
onBoardCertBytes []byte
log *base.LogObject
// All HTTP requests which can't be dropped and send should be
// repeated in case of a transmission error are added to this
// queue.
// All controller HTTP requests which can't be dropped and send
// should be repeated in case of a transmission error are added to
// this queue.
DeferredEventCtx *DeferredContext
// All periodic HTTP requests are added to this queue, sending
// errors of which can be ignored. This means even the request has
// failed, it will be removed from the queue, so there is no need
// to `kick` this queue once connectivity has restored.
// All periodic controller HTTP requests are added to this queue,
// sending errors of which can be ignored. This means even the
// request has failed, it will be removed from the queue, so there
// is no need to `kick` this queue once connectivity has restored.
DeferredPeriodicCtx *DeferredContext
// All periodic LOC HTTP requests are added to this queue,
// sending errors of which can be ignored. This means even the
// request has failed, it will be removed from the queue, so there
// is no need to `kick` this queue once connectivity has restored.
DeferredLOCPeriodicCtx *DeferredContext
}

// ContextOptions - options to be passed at NewContext
Expand Down

0 comments on commit 713af84

Please sign in to comment.