Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init: fix restart and downgrade for yum #1092

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

huww98
Copy link
Contributor

@huww98 huww98 commented Jun 25, 2024

yum install is not idempotent, so we need to check if the package is already installed. yum also fails if the already installed version is newer, so we need to downgrade. dnf do all of these automatically.

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes c67535f

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 25, 2024
@huww98
Copy link
Contributor Author

huww98 commented Jun 25, 2024

Manual tests

Alinux 2

Upgrade

# "${PKG_CMD[@]}" ./aliyun-alinas-utils-1.1-8.20240527201444.2012cc.al7.noarch.rpm 
package aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64 is not installed
Loaded plugins: fastestmirror, langpacks, releasever-adapter, update-motd
Examining ./aliyun-alinas-utils-1.1-8.20240527201444.2012cc.al7.noarch.rpm: aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64
Marking ./aliyun-alinas-utils-1.1-8.20240527201444.2012cc.al7.noarch.rpm as an update to aliyun-alinas-utils-1.1-8.al7.x86_64
Resolving Dependencies
--> Running transaction check
---> Package aliyun-alinas-utils.x86_64 0:1.1-8.al7 will be updated
---> Package aliyun-alinas-utils.x86_64 0:1.1-8.20240527201444.2012cc.alios7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================================================================================================================================================================================================
 Package                                                                Arch                                                      Version                                                                                Repository                                                                                                      Size
==============================================================================================================================================================================================================================================================================================================================================
Updating:
 aliyun-alinas-utils                                                    x86_64                                                    1.1-8.20240527201444.2012cc.alios7                                                     /aliyun-alinas-utils-1.1-8.20240527201444.2012cc.al7.noarch                                                     12 M

Transaction Summary
==============================================================================================================================================================================================================================================================================================================================================
Upgrade  1 Package

Total size: 12 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                                                                                                                                                                                              1/2 
  Cleanup    : aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                                                                                                                                                                                       2/2 
  Verifying  : aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                                                                                                                                                                                              1/2 
  Verifying  : aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                                                                                                                                                                                       2/2 

Updated:
  aliyun-alinas-utils.x86_64 0:1.1-8.20240527201444.2012cc.alios7                                                                                                                                                                                                                                                                             

Complete!

Restart

# "${PKG_CMD[@]}" ./aliyun-alinas-utils-1.1-8.20240527201444.2012cc.al7.noarch.rpm 
aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64
./aliyun-alinas-utils-1.1-8.20240527201444.2012cc.al7.noarch.rpm already installed

Downgrade

# "${PKG_CMD[@]}" ./aliyun-alinas-utils-1.1-8.al7.noarch.rpm 
package aliyun-alinas-utils-1.1-8.al7.x86_64 is not installed
Loaded plugins: fastestmirror, langpacks, releasever-adapter, update-motd
Examining ./aliyun-alinas-utils-1.1-8.al7.noarch.rpm: aliyun-alinas-utils-1.1-8.al7.x86_64
./aliyun-alinas-utils-1.1-8.al7.noarch.rpm: does not update installed package.
Error: Nothing to do
Loaded plugins: fastestmirror, langpacks, releasever-adapter, update-motd
Examining ./aliyun-alinas-utils-1.1-8.al7.noarch.rpm: aliyun-alinas-utils-1.1-8.al7.x86_64
Resolving Dependencies
--> Running transaction check
---> Package aliyun-alinas-utils.x86_64 0:1.1-8.al7 will be a downgrade
---> Package aliyun-alinas-utils.x86_64 0:1.1-8.20240527201444.2012cc.alios7 will be erased
--> Finished Dependency Resolution
base/2.1903/x86_64                                                                                                                                                                                                                                                                                                     | 3.1 kB  00:00:00     
epel/x86_64                                                                                                                                                                                                                                                                                                            | 4.3 kB  00:00:00     
epel/x86_64/updateinfo                                                                                                                                                                                                                                                                                                 | 1.0 MB  00:00:00     
epel/x86_64/primary_db                                                                                                                                                                                                                                                                                                 | 8.7 MB  00:00:00     
extras/2.1903/x86_64                                                                                                                                                                                                                                                                                                   | 2.5 kB  00:00:00     
plus/2.1903/x86_64                                                                                                                                                                                                                                                                                                     | 2.9 kB  00:00:00     
updates/2.1903/x86_64                                                                                                                                                                                                                                                                                                  | 2.9 kB  00:00:00     

Dependencies Resolved

==============================================================================================================================================================================================================================================================================================================================================
 Package                                                                            Arch                                                                  Version                                                                  Repository                                                                                            Size
==============================================================================================================================================================================================================================================================================================================================================
Downgrading:
 aliyun-alinas-utils                                                                x86_64                                                                1.1-8.al7                                                                /aliyun-alinas-utils-1.1-8.al7.noarch                                                                 12 M

Transaction Summary
==============================================================================================================================================================================================================================================================================================================================================
Downgrade  1 Package

Total size: 12 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                                                                                                                                                                                       1/2 
  Cleanup    : aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                                                                                                                                                                                              2/2 
  Verifying  : aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                                                                                                                                                                                       1/2 
  Verifying  : aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                                                                                                                                                                                              2/2 

Removed:
  aliyun-alinas-utils.x86_64 0:1.1-8.20240527201444.2012cc.alios7                                                                                                                                                                                                                                                                             

Installed:
  aliyun-alinas-utils.x86_64 0:1.1-8.al7                                                                                                                                                                                                                                                                                                      

Complete!

Alinux 3

Upgrade

# "${PKG_CMD[@]}" ./aliyun-alinas-utils-1.1-8.20240527201444.2012cc.al7.noarch.rpm
上次元数据过期检查:3:03:28 前,执行于 2024年06月25日 星期二 08时44分25秒。
依赖关系解决。
======================================================================================================================================================================
 软件包                                   架构                        版本                                                    仓库                               大小
======================================================================================================================================================================
升级:
 aliyun-alinas-utils                      x86_64                      1.1-8.20240527201444.2012cc.alios7                      @commandline                      3.9 M

事务概要
======================================================================================================================================================================
升级  1 软件包

总计:3.9 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                       1/1
  运行脚本: aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                         1/1
  升级    : aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                         1/2
  运行脚本: aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                         1/2
  运行脚本: aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                  2/2
  清理    : aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                  2/2
  运行脚本: aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                  2/2
  验证    : aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                         1/2
  验证    : aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                  2/2

已升级:
  aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64

完毕!

Restart

# "${PKG_CMD[@]}" ./aliyun-alinas-utils-1.1-8.al7.noarch.rpm
上次元数据过期检查:3:02:36 前,执行于 2024年06月25日 星期二 08时44分25秒。
软件包 aliyun-alinas-utils-1.1-8.al7.x86_64 已安装。
依赖关系解决。
无需任何处理。
完毕!

Downgrade

# "${PKG_CMD[@]}" ./aliyun-alinas-utils-1.1-8.al7.noarch.rpm
上次元数据过期检查:2:20:24 前,执行于 2024年06月25日 星期二 08时44分25秒。
依赖关系解决。
======================================================================================================================================================================
 软件包                                         架构                              版本                                  仓库                                     大小
======================================================================================================================================================================
降级:
 aliyun-alinas-utils                            x86_64                            1.1-8.al7                             @commandline                            3.9 M

事务概要
======================================================================================================================================================================
降级  1 软件包

总计:3.9 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                       1/1
  运行脚本: aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                  1/1
  降级    : aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                  1/2
  运行脚本: aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                  1/2
  运行脚本: aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                         2/2
  清理    : aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                         2/2
  运行脚本: aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                         2/2
  验证    : aliyun-alinas-utils-1.1-8.al7.x86_64                                                                                                                  1/2
  验证    : aliyun-alinas-utils-1.1-8.20240527201444.2012cc.alios7.x86_64                                                                                         2/2

已降级:
  aliyun-alinas-utils-1.1-8.al7.x86_64

完毕!

Ubuntu 22.04

Upgrade

# "${PKG_CMD[@]}" ./aliyun-alinas-utils-1.1-8.deb > /tmp/test.out 2>&1
# cat /tmp/test.out
Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
  libntfs-3g89
Use 'apt autoremove' to remove it.
The following packages will be upgraded:
  aliyun-alinas-utils
1 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.
Need to get 0 B/4,897 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 /root/aliyun-alinas-utils-1.1-8.deb aliyun-alinas-utils all 1.1-8 [4,897 kB]
(Reading database ... 82408 files and directories currently installed.)
Preparing to unpack .../aliyun-alinas-utils-1.1-8.deb ...
Unpacking aliyun-alinas-utils (1.1-8) over (1.1-3) ...
Setting up aliyun-alinas-utils (1.1-8) ...

Restart

# apt-get install -y ./aliyun-alinas-utils-1.1-8.deb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'aliyun-alinas-utils' instead of './aliyun-alinas-utils-1.1-8.deb'
aliyun-alinas-utils is already the newest version (1.1-8).
The following package was automatically installed and is no longer required:
  libntfs-3g89
Use 'apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

Downgrade

# "${PKG_CMD[@]}" ./2.deb > /tmp/test.out 2>&1
# cat /tmp/test.out
Reading package lists...
Building dependency tree...
Reading state information...
The following package was automatically installed and is no longer required:
  libntfs-3g89
Use 'apt autoremove' to remove it.
The following packages will be DOWNGRADED:
  aliyun-alinas-utils
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 14 not upgraded.
Need to get 0 B/4,897 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 /root/2.deb aliyun-alinas-utils all 1.1-3 [4,897 kB]
dpkg: warning: downgrading aliyun-alinas-utils from 1.1-8 to 1.1-3
(Reading database ... 82408 files and directories currently installed.)
Preparing to unpack /root/2.deb ...
Unpacking aliyun-alinas-utils (1.1-3) over (1.1-8) ...
Setting up aliyun-alinas-utils (1.1-3) ...

yum install is not idempotent, so we need to check if the package is already installed.
yum also fails if the already installed version is newer, so we need to downgrade.
dnf do all of these automatically.

Fixes: c67535f
@huww98 huww98 marked this pull request as ready for review June 25, 2024 04:02
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 25, 2024
@mowangdk
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 25, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: huww98, mowangdk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 25, 2024
@k8s-ci-robot k8s-ci-robot merged commit b13491f into kubernetes-sigs:master Jun 25, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants