mmumshad / kubernetes-the-hard-way

Bootstrap Kubernetes the hard way on Vagrant on Local Machine. No scripts.
Apache License 2.0
4.7k stars 4.54k forks source link

Issue with ubuntu mirrors sync #69

Closed sudhirrs closed 4 years ago

sudhirrs commented 4 years ago

Ran into this strange issue with mirrors today when setting up from scratch

I was receiving errors like these

    worker-1: Reading package lists...
    worker-1: E
    worker-1: :
    worker-1: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/universe/i18n/by-hash/SHA256/9fc21dfcc2639dc719471cdc93179e47479a193e9b8fc46e55e90c87f2ca0122  File has unexpected size (13217 != 4940820). Mirror sync in progress? [IP: 91.189.88.174 80]
    worker-1:
    worker-1: Hashes of expected file:
    worker-1:
    worker-1:  - Filesize:4940820 [weak]
    worker-1:
    worker-1:  - SHA256:9fc21dfcc2639dc719471cdc93179e47479a193e9b8fc46e55e90c87f2ca0122
    worker-1:
    worker-1:  - SHA1:4d360e4f87adc149a7832a73e367fd9717e782a8 [weak]
    worker-1:
    worker-1:  - MD5Sum:481a75f2fc2f4a02df60bcde8604a788 [weak]
    worker-1:    Release file created at: Thu, 26 Apr 2018 23:37:48 +0000
    worker-1: E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/multiverse/binary-amd64/by-hash/SHA256/6f613efa2fcdd62f9708766c7d371db57f43710105bb99f5f55fbf9ee0db6c40

The solution seems to be to use a mirror that is up to date. The up to date status can be checked here. https://launchpad.net/ubuntu/+archivemirrors

In my case since I am in India I found one that is up to date https://launchpad.net/ubuntu/+mirror/repos.del.extreme-ix.org+archive

For bionic64 the relevant sources.list entries are deb http://repos.del.extreme-ix.org/ubuntu/ bionic main deb-src http://repos.del.extreme-ix.org/ubuntu/ bionic main

In Vagrant file so I added this line config.vm.provision :shell, :inline => "sed -i 's/archive.ubuntu.com/repos.del.extreme-ix.org/g' /etc/apt/sources.list"

What followed was an error with security.ubuntu.com

   worker-1: Reading package lists...
    worker-1: E
# -*- mode: ruby -*-
    worker-1: :
    worker-1: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/main/binary-amd64/by-hash/SHA256/c0dffd9d6d2e0cc74bd9a533a5464c936dfff08f19ba08aabd3fc0a307e2e3ea  File has unexpected size (13247 != 592540). Mirror sync in progress? [IP: 91.189.88.174 80]
    worker-1:
    worker-1: Hashes of expected file:
    worker-1:
    worker-1:  - Filesize:592540 [weak]
    worker-1:
    worker-1:  - SHA256:c0dffd9d6d2e0cc74bd9a533a5464c936dfff08f19ba08aabd3fc0a307e2e3ea
    worker-1:

So updated the Vagrantfile with this (I don't think it is recommended though to change the security.ubuntu.com repo url)

  $script = <<-SCRIPT
    sed -i 's/archive.ubuntu.com/repos.del.extreme-ix.org/g' /etc/apt/sources.list
    sed -i 's/security.ubuntu.com/repos.del.extreme-ix.org/g' /etc/apt/sources.list
  SCRIPT
  config.vm.provision "shell", inline: $script

Now all works. Although I am not sure if this was the right fix.