自动更新和手动回滚

Fedora CoreOS provides atomic updates and rollbacks via OSTree deployments.

默认情况下,操作系统通过两个组件执行持续的自动更新:

  • rpm-ostree 可处理多个磁盘上的 OSTree 部署,并可在启动时在它们之间切换。

  • Zincati 持续检查操作系统更新,并通过 rpm-ostree 进行应用。

对更新的警惕性

本地 Zincati 代理会定期检查远程服务,查看更新何时可用。 可以提供一个自定义的 "rollout wariness "值(参见 文档),让服务器知道节点对接收更新的渴望程度或规避风险的程度。

rollout_wariness 参数可设置为介于`0.0`(最急切)和 1.0(最保守)之间的浮点数值。 为了在分阶段推出周期的早期接收更新,可将节点配置为低值(如 0.001)。 这可以在配置过程中通过使用下图所示的 Butane 配置片段来实现:

Example: configuring Zincati rollout wariness
variant: fcos
version: 1.5.0
storage:
  files:
    - path: /etc/zincati/config.d/51-rollout-wariness.toml
      contents:
        inline: |
          [identity]
          rollout_wariness = 0.001

操作系统更新完成

要完成操作系统更新,机器必须重新启动。 由于这是一个可能导致服务中断的侵入性操作,Zincati 允许集群管理员控制何时允许节点重启以完成更新。

可采用以下完成更新的策略:

  • 一旦下载更新并在本地暂存,立即重启以应用更新。

  • 使用外部锁管理器来协调机群的重启。

  • 仅允许在配置的维护窗口内重启,维护窗口按每周 UTC 计划定义。

可在每个节点上配置特定的最终处理策略。

下面的 Butane代码段显示了如何在周末日定义两个维护窗口,从 22:30 UTC 开始,每个窗口持续一小时:

示例:配置 Zincati 更新策略
variant: fcos
version: 1.5.0
storage:
  files:
    - path: /etc/zincati/config.d/55-updates-strategy.toml
      contents:
        inline: |
          [updates]
          strategy = "periodic"
          [[updates.periodic.window]]
          days = [ "Sat", "Sun" ]
          start_time = "22:30"
          length_minutes = 60

有关完成更新的更多详情,请查阅 Zincati 文档

Manual Rollbacks

When an update is complete, the previous OS deployment remains on disk. If an update causes issues, you can use it as a fallback. This is a manual operation that requires human intervention and console access.

Temporary rollback

To temporarily boot the previous OS deployment, hold down Shift during the OS boot process. When the bootloader menu appears, select the relevant OS entry in the menu.

Permanent rollback

To permanently revert to the previous OS deployment, log into the target node and run the following commands:

# Stop the service that performs automatic updates
sudo systemctl stop zincati.service

# Mark the previous OS deployment as the default, and immediately reboots into it
sudo rpm-ostree rollback -r

Please note that Zincati will keep looking for updates and upgrade to any new available OS deployment, other than the one you just reverted.

If you prefer, you can temporarily turn off auto-updates. Later on, you can re-enable them in order to let the machine catch up with the usual flow of updates:

# Disable Zincati in order to opt-out from future auto-updates
sudo systemctl disable --now zincati.service

[...]

# At a later point, re-enable it to re-align with the tip of stream
sudo systemctl enable --now zincati.service