ubuntu更新报错解决:File has unexpected size -Mirror sync in progress?

此文首发于我的个人博客:zhang0peter的个人博客


在晚上打算安装k8s在ubuntu 18.04,进行更新apt update的时候报错如下:

root@ubuntu:/home/ubuntu# apt update
Get:1 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial InRelease [8,993 B]
Hit:2 http://mirrors.zju.edu.cn/ubuntu bionic InRelease    
Get:3 http://mirrors.zju.edu.cn/ubuntu bionic-updates InRelease [88.7 kB]
Ign:4 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial/main amd64 Packages
Get:4 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial/main amd64 Packages [31.3 kB]
Err:4 http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial/main amd64 Packages     
  File has unexpected size (29885 != 31290). Mirror sync in progress? [IP: 202.141.176.110 80]
  Hashes of expected file:
   - Filesize:31290 [weak]
   - SHA256:9b086de79d1687956dda7c6efddd61604160a837ddf0d376895d249ba429809e
   - SHA1:3b24fb7e15cd10ef8076413ccd67d4e36e4c95b4 [weak]
   - MD5Sum:0e3c3cae24994300680465716da8005a [weak]
  Release file created at: Wed, 13 Nov 2019 20:22:09 +0000
Get:5 http://mirrors.zju.edu.cn/ubuntu bionic-backports InRelease [74.6 kB]               
Get:6 http://mirrors.zju.edu.cn/ubuntu bionic-security InRelease [88.7 kB]
Fetched 261 kB in 1s (336 kB/s)    
Reading package lists... Done
E: Failed to fetch http://mirrors.ustc.edu.cn/kubernetes/apt/dists/kubernetes-xenial/main/binary-amd64/Packages.gz  File has unexpected size (29885 != 31290). Mirror sync in progress? [IP: 202.141.176.110 80]
   Hashes of expected file:
    - Filesize:31290 [weak]
    - SHA256:9b086de79d1687956dda7c6efddd61604160a837ddf0d376895d249ba429809e
    - SHA1:3b24fb7e15cd10ef8076413ccd67d4e36e4c95b4 [weak]
    - MD5Sum:0e3c3cae24994300680465716da8005a [weak]
   Release file created at: Wed, 13 Nov 2019 20:22:09 +0000
E: Some index files failed to download. They have been ignored, or old ones used instead.

报错:File has unexpected size (29885 != 31290). Mirror sync in progress? [IP: E: Some index files failed to download. They have been ignored, or old ones used instead.

我本来以为是http的原因,把更新源换成了HTTPS后仍没解决问题。

然后我把中科大的源换成了阿里的源:

echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list

更换源后问题就解决了,看来真的是更新源的问题。