Bug: Dockerfiles reusing stale apt sources info
Status: Resolved | Priority: Major | Resolution: Fixed
Created: 12/Mar/20 22:52
Affects Version/s: 2.3.0

We're seeing failed builds on jenkins that look like

{noformat} 
[2020-03-12T21:27:06.369Z] ---> 368a6d22e8da 
[2020-03-12T21:27:06.369Z] Step 41/62 : RUN DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y bash=4.4.18-2ubuntu1.2 build-essential=12.4ubuntu1 curl=7.58.0-2ubuntu3.8 diffutils=1:3.6-1 git=1:2.17.1-1ubuntu0.5 rsync=3.1.2-2.1ubuntu1 tar=1.29b-2ubuntu0.1 wget=1.19.4-1ubuntu2.2 
[2020-03-12T21:27:12.818Z] ---> Running in fe5d7602e278 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/gcc-7-base_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/cpp-7_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-8/libcc1-0_8.3.0-6ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-8/libgomp1_8.3.0-6ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-8/libitm1_8.3.0-6ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-8/libatomic1_8.3.0-6ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/libasan4_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-8/liblsan0_8.3.0-6ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-8/libtsan0_8.3.0-6ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/libubsan0_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/libcilkrts5_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-8/libmpx2_8.3.0-6ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-8/libquadmath0_8.3.0-6ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/libgcc-7-dev_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/gcc-7_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/libstdc++-7-dev_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-7/g++-7_7.4.0-1ubuntu1~18.04.1_amd64.deb 404 Not Found [IP: 91.189.88.174 80] 
[2020-03-12T21:27:20.643Z] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? 
{noformat}

Logs from earlier in the docker build pipeline show use of a cached layer containing apt repository sources, while the earlier layer is bring rebuilt.

{noformat}
[2020-03-12T21:27:06.368Z] Step 3/62 : RUN DEBIAN_FRONTEND=noninteractive apt-get -qq update &&   DEBIAN_FRONTEND=noninteractive apt-get -qq install --no-install-recommends -y     ca-certificates=20180409     curl=7.58.0-2ubuntu3.8     locales=2.27-3ubuntu1
[2020-03-12T21:27:06.368Z]  ---> Using cache
[2020-03-12T21:27:06.368Z]  ---> 04ad316a4951
{noformat}

Thus, I suspect the later layer has stale repository info. Seems a best practice is that anyone one does {{apt-get install}}, one must first {{apt-get update}} in the same layer. I was hoping to avoid repetitive {{update}} invocations and save some bandwidth... premature optimizations, and all that.