Skip to content

Commit

Permalink
Also fetch certs on types.SenderStatusCertInvalid
Browse files Browse the repository at this point in the history
Signed-off-by: eriknordmark <erik@zededa.com>
Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
  • Loading branch information
eriknordmark authored and rouming committed Feb 10, 2023
1 parent ac5999d commit 336c23c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/pillar/cmd/zedagent/handleconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,12 @@ func getLatestConfig(getconfigCtx *getconfigContext, url string,
log.Errorf("getLatestConfig failed: %s", err)
}
switch senderStatus {
case types.SenderStatusUpgrade, types.SenderStatusRefused, types.SenderStatusCertInvalid, types.SenderStatusNotFound:
case types.SenderStatusCertInvalid:
// trigger to acquire new controller certs from cloud
log.Noticef("%s trigger", senderStatus.String())
triggerControllerCertEvent(ctx)
fallthrough
case types.SenderStatusUpgrade, types.SenderStatusRefused, types.SenderStatusNotFound:
newCount = types.LedBlinkConnectedToController // Almost connected to controller!
// Don't treat as upgrade failure
if getconfigCtx.updateInprogress {
Expand All @@ -505,7 +510,7 @@ func getLatestConfig(getconfigCtx *getconfigContext, url string,
}
case types.SenderStatusCertMiss:
// trigger to acquire new controller certs from cloud
log.Noticef("SenderStatusCertMiss trigger")
log.Noticef("%s trigger", senderStatus.String())
triggerControllerCertEvent(ctx)
}
if getconfigCtx.ledBlinkCount == types.LedBlinkOnboarded {
Expand Down Expand Up @@ -589,9 +594,10 @@ func getLatestConfig(getconfigCtx *getconfigContext, url string,
url, contents, false, senderStatus)
if err != nil {
log.Errorf("RemoveAndVerifyAuthContainer failed: %s", err)
if rv.Status == types.SenderStatusCertMiss {
switch senderStatus {
case types.SenderStatusCertMiss, types.SenderStatusCertInvalid:
// trigger to acquire new controller certs from cloud
log.Noticef("SenderStatusCertMiss trigger")
log.Noticef("%s trigger", senderStatus.String())
triggerControllerCertEvent(ctx)
}
// Inform ledmanager about problem
Expand Down
36 changes: 36 additions & 0 deletions pkg/pillar/types/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,42 @@ const (
SenderStatusDebug // Not a failure
)

// String prints ASCII
func (status SenderResult) String() string {
switch status {
case SenderStatusNone:
return "SenderStatusNone"
case SenderStatusRefused:
return "SenderStatusRefused"
case SenderStatusUpgrade:
return "SenderStatusUpgrade"
case SenderStatusCertInvalid:
return "SenderStatusCertInvalid"
case SenderStatusCertMiss:
return "SenderStatusCertMiss"
case SenderStatusSignVerifyFail:
return "SenderStatusSignVerifyFail"
case SenderStatusAlgoFail:
return "SenderStatusAlgoFail"
case SenderStatusHashSizeError:
return "SenderStatusHashSizeError"
case SenderStatusCertUnknownAuthority:
return "SenderStatusCertUnknownAuthority"
case SenderStatusCertUnknownAuthorityProxy:
return "SenderStatusCertUnknownAuthorityProxy"
case SenderStatusNotFound:
return "SenderStatusNotFound"
case SenderStatusForbidden:
return "SenderStatusForbidden"
case SenderStatusFailed:
return "SenderStatusFailed"
case SenderStatusDebug:
return "SenderStatusDebug"
default:
return fmt.Sprintf("Unknown status %d", status)
}
}

const (
// MinuteInSec is number of seconds in a minute
MinuteInSec = 60
Expand Down

0 comments on commit 336c23c

Please sign in to comment.