in cmd/aotutil/ssm.go [160:188]
func (s *SSMWrapper) WaitPatchReported(ctx context.Context, instanceId string, timeout time.Duration) error {
logger := s.logger.With(zap.String("InstanceId", instanceId), zap.String("Action", "WaitPatchReported"))
logger.Info("Start waiting patch report")
// Force the minial wait time for patch report
if timeout < waitPatchReportMinimalTimeout {
timeout = waitPatchReportMinimalTimeout
}
return Wait(waitInterval, timeout, func() (WaitAction, error) {
infos, err := describeInstanceAssocStatus(ctx, s.client, instanceId)
if err != nil {
return WaitDone, err
}
var patchTime, reportTime time.Time
for _, assoc := range infos {
switch aws.ToString(assoc.Name) {
case SSMPatchDocument:
patchTime = aws.ToTime(assoc.ExecutionDate)
case SSMReportDocument:
reportTime = aws.ToTime(assoc.ExecutionDate)
}
}
logger.Info("waiting patch report", zap.Time("PatchTime", patchTime), zap.Time("ReportTime", reportTime))
if patchTime.IsZero() || reportTime.IsZero() || reportTime.Before(patchTime) {
return WaitContinue, nil
}
logger.Info("patch reported")
return WaitDone, nil
})
}