Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/platform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## 更新环境、过程检查或修复结果:
| 事件名称 | 变量 | 公网 API | 内网 API |
|----|--- | ----| ----|
|检查更新前 | preUpdateCheck | ✗ | /api/v1/process/events |
|检查更新后|postUpdateCheck | ✗ | /api/v1/process/events |
|下载更新前|preDownloadCheck | ✗ | /api/v1/process/events |
|下载更新后|postDownloadCheck| ✗ | /api/v1/process/events |
|备份前|preBackupCheck | ✗ | /api/v1/process/events |
|备份后|postBackupCheck | ✗ | /api/v1/process/events |
|系统升级前|preCheck | ✗ | /api/v1/process/events |
|系统升级后|midCheck | ✗ | /api/v1/process/events |
|系统升级完成重启后|postCheck | ✗ | /api/v1/process/events |

## 更新事件上报:
|描述 | 公网 API | 内网 API |
|----|---- | ----|
|检查到更新 | /api/v1/process | /api/v1/process/events |
|检查更新失败 | /api/v1/process | /api/v1/process/events |
|开始下载 | ✗ | /api/v1/process/events |
|下载完成 | /api/v1/process | /api/v1/process/events |
|下载失败 | /api/v1/process | /api/v1/process/events |
|开始备份 | ✗ | /api/v1/process/events |
|备份成功 | /api/v1/process | /api/v1/process/events |
|备份失败 | ✗ | /api/v1/process/events |
|开始安装 | /api/v1/process | /api/v1/process/events |
|安装失败 | /api/v1/process | /api/v1/process/events |

> 上述结果只代表当前代码逻辑状态
15 changes: 14 additions & 1 deletion src/internal/updateplatform/message_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type ProcessEvent struct {
EventType int `json:"eventType"`
EventStatus bool `json:"eventStatus"`
EventContent string `json:"eventContent"`
ExecAct int64 `json:"execAct"`
}

const (
Expand All @@ -55,6 +56,16 @@ const (
StartBackUp int = 5
BackUpComplete int = 6
StartInstall int = 7

PreUpdateCheck int = 101
PostUpdateCheck int = 102
PreDownloadCheck int = 103
PostDownloadCheck int = 104
PreBackupCheck int = 105
PostBackupCheck int = 106
PreUpgradeCheck int = 107
MidUpgradeCheck int = 108
PostUpgradeCheck int = 109
)

type ShellCheck struct {
Expand Down Expand Up @@ -1445,6 +1456,9 @@ func (m *UpdatePlatformManager) PostProcessEventMessage(body ProcessEvent) {
}
logger.Debug("post process event msg:", body)
body.TaskID = m.taskID
if body.ExecAct == 0 {
body.ExecAct = time.Now().Unix()
}
if (m.config.PlatformDisabled & DisabledProcess) != 0 {
logger.Warning("platform is disabled")
return
Expand Down Expand Up @@ -1488,7 +1502,6 @@ func (m *UpdatePlatformManager) PostProcessEventMessage(body ProcessEvent) {
if err != nil {
logger.Warningf("get post process event msg response failed:%v", err)
}
return
}

// PostStatusMessage 将检查\下载\安装过程中所有异常状态和每个阶段成功的正常状态上报
Expand Down
5 changes: 2 additions & 3 deletions src/lastore-daemon/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,12 @@ func NewManager(service *dbusutil.Service, updateApi system.System, c *config.Co
Type: "error",
Detail: msg,
}, true)
procEvent := updateplatform.ProcessEvent{
m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.GetUpdateEvent,
EventStatus: false,
EventContent: msg,
}
m.updatePlatform.PostProcessEventMessage(procEvent)
})

err = m.delRebootCheckOption(all)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions src/lastore-daemon/manager_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,12 @@ func (m *Manager) checkUpgrade(sender dbus.Sender, checkMode system.UpdateType,
Detail: msg,
}, false)

procEvent := updateplatform.ProcessEvent{
m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.CheckEnv,
EventStatus: false,
EventContent: msg,
}
m.updatePlatform.PostProcessEventMessage(procEvent)
})
m.reportLog(upgradeStatusReport, false, job.Description)
}()
inhibit(false)
Expand Down
87 changes: 51 additions & 36 deletions src/lastore-daemon/manager_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ func (m *Manager) prepareDistUpgrade(sender dbus.Sender, origin system.UpdateTyp
if m.config.IntranetUpdate {
msg := gettext.Tr("New version available! The download of the update package will begin shortly")
go m.sendNotify(updateNotifyShow, 0, "preferences-system", "", msg, nil, nil, system.NotifyExpireTimeoutPrivate)
procEvent := updateplatform.ProcessEvent{
m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.StartDownload,
EventStatus: true,
EventContent: msg,
}
m.updatePlatform.PostProcessEventMessage(procEvent)
})
}
job.initiator = initiator
currentJob := job
Expand Down Expand Up @@ -167,16 +166,24 @@ func (m *Manager) prepareDistUpgrade(sender dbus.Sender, origin system.UpdateTyp
}
j.setPreHooks(map[string]func() error{
string(system.RunningStatus): func() error {
systemErr := dut.CheckSystem(dut.PreDownloadCheck, nil)
if systemErr != nil {
checkType := dut.PreDownloadCheck
if systemErr := dut.CheckSystem(checkType, nil); systemErr != nil {
logger.Warning(systemErr)
go func(err *system.JobError) {
m.updatePlatform.PostStatusMessage(updateplatform.StatusMessage{
Type: "error",
JobDescription: err.ErrType.String(),
Detail: err.ErrDetail,
}, true)
m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.PreDownloadCheck,
EventStatus: false,
EventContent: err.ErrDetail,
})
}(systemErr)
} else {
go m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.PreDownloadCheck,
EventStatus: true,
EventContent: fmt.Sprintf("%v success", checkType),
})
}

return nil
Expand Down Expand Up @@ -239,44 +246,44 @@ func (m *Manager) prepareDistUpgrade(sender dbus.Sender, origin system.UpdateTyp
JobDescription: job.Description,
Detail: msg,
}, true)
procEvent := updateplatform.ProcessEvent{
m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.StartDownload,
EventStatus: false,
EventContent: msg,
}
m.updatePlatform.PostProcessEventMessage(procEvent)
})
}()

systemErr := dut.CheckSystem(dut.PostDownloadCheck, nil)
if systemErr != nil {
checkType := dut.PostDownloadCheck
if systemErr := dut.CheckSystem(checkType, nil); systemErr != nil {
logger.Warning(systemErr)
go func(err *system.JobError) {
m.updatePlatform.PostStatusMessage(updateplatform.StatusMessage{
Type: "error",
JobDescription: err.ErrType.String(),
Detail: err.ErrDetail,
}, true)
m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.PostDownloadCheck,
EventStatus: false,
EventContent: err.ErrDetail,
})
}(systemErr)
} else {
go m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.PostDownloadCheck,
EventStatus: true,
EventContent: fmt.Sprintf("%v success", checkType),
})
}

return nil
},
string(system.SucceedStatus): func() error {
msg := fmt.Sprintf("download %v package success", j.updateTyp.JobType())
m.updatePlatform.PostStatusMessage(updateplatform.StatusMessage{
Type: "info",
UpdateType: mode.JobType(),
JobDescription: j.Description,
Detail: msg,
}, false) // 上报下载成功状态
procEvent := updateplatform.ProcessEvent{
m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.DownloadComplete,
EventStatus: true,
EventContent: msg,
}
m.updatePlatform.PostProcessEventMessage(procEvent) // 上报下载成功状态
}) // 上报下载成功状态
logger.Infof("enter download job succeed callback, UpdateNowForce: %v", m.updatePlatform.UpdateNowForce)
m.statusManager.SetUpdateStatus(j.updateTyp, system.CanUpgrade)
if j.next == nil {
Expand Down Expand Up @@ -313,16 +320,24 @@ func (m *Manager) prepareDistUpgrade(sender dbus.Sender, origin system.UpdateTyp
m.reportLog(downloadStatusReport, true, "")
}()

systemErr := dut.CheckSystem(dut.PostDownloadCheck, nil)
if systemErr != nil {
checkType := dut.PostDownloadCheck
if systemErr := dut.CheckSystem(checkType, nil); systemErr != nil {
logger.Warning(systemErr)
go func(err *system.JobError) {
m.updatePlatform.PostStatusMessage(updateplatform.StatusMessage{
Type: "error",
JobDescription: err.ErrType.String(),
Detail: err.ErrDetail,
}, true)
m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.PostDownloadCheck,
EventStatus: false,
EventContent: err.ErrDetail,
})
}(systemErr)
} else {
go m.updatePlatform.PostProcessEventMessage(updateplatform.ProcessEvent{
TaskID: 1,
EventType: updateplatform.PostDownloadCheck,
EventStatus: true,
EventContent: fmt.Sprintf("%v success", checkType),
})
}

if m.updatePlatform.UpdateNowForce {
Expand Down
Loading
Loading