<p>I have set up a custom docker image registry on Gitlab and AKS for some reason fails to pull the image from there.<br />
Error that is being thrown out is:</p>
<pre><code>Failed to pull image &quot;{registry}/{image}:latest&quot;: rpc error: code = FailedPrecondition desc = 
failed to pull and unpack image &quot;{registry}/{image}:latest&quot;: failed commit on ref &quot;layer-sha256:e1acddbe380c63f0de4b77d3f287b7c81cd9d89563a230692378126b46ea6546&quot;: &quot;layer-sha256:e1acddbe380c63f0de4b77d3f287b7c81cd9d89563a230692378126b46ea6546&quot; failed size validation: 0 != 27145985: failed precondition
</code></pre>
<p>What is interesting is that the image does not have the layer with id</p>
<pre><code>sha256:e1acddbe380c63f0de4b77d3f287b7c81cd9d89563a230692378126b46ea6546
</code></pre>
<p>Perhaps something is cached on AKS side? I deleted the pod along with the deployment before redeploying.</p>
<p>I couldn't find much about this kind of errors and I have no idea what may be causing that. Pulling the same image from local docker environment works flawlessly.<br />
Any tip would be much appreciated!</p>

szachmat
<p>•   You can try scaling up the registry to run on all nodes. Kubernetes controller tries to be smart and routes node requests internally, instead of sending traffic to the loadbalancer IP. The issue though that if there is no registry service on that node, the packets go nowhere. So, scale up or route through a non-AKS LB.</p>
<p>•   Also, clean the image layer cache folder in ${containerd folder}/io.containerd.content.v1.content/ingest.Containerd would not clean this cache automatically when some layer data broken. You can also try purging the contents in this path ${containerd folder}/io.containerd.content.v1.content/ingest.</p>
<p>•   Might be this can be a TCP network connection issue between the AKS cluster and the docker image registry on Gitlab, so you can try using a proxy and configure it to close the connection between them after ‘X’ bytes of data are transferred as the retry of the pull starts over at 0% for the layer which then results in the same error because after some time we get a connection close and the layer was again not pulled completely. So, will recommend using a registry which is located near their cluster to have the higher throughput.</p>
<p>•   Also try restarting the communication pipeline between AKS cluster and the docker image registry on gitlab, it fixes this issue for the time being until it re-occurs.</p>
<p>Please find the below link for more information: -</p>
<p><a href="https://docs.gitlab.com/ee/user/packages/container_registry/" rel="nofollow noreferrer">https://docs.gitlab.com/ee/user/packages/container_registry/</a></p>
