From f18530de788e24ab925698b8793d35c3c50aef8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Gr=C3=A9au?= Date: Sat, 13 Jun 2020 16:02:45 -0400 Subject: [PATCH] [yum] Clear cached data and add retry loop (#19182) This commit makes the yum commands more robust by: - clearing the cache after the install command is finished - adding a retry loop so that the installation is retried in case of transient network issues Without this fix, the Unified Release Process can't complete any Stack/Solution snapshots or staging builds because of the following error: ``` "[Errno -1] repomd.xml does not match metalink for epel" ``` This is related to this [Slack discussion for building the 7.8.0 BC7](https://elastic.slack.com/archives/C0JFN9HJL/p1592055371477200) and related to this https://serverfault.com/questions/1021273/yum-install-jq-is-failing-intermittently-on-centos7 This is inspired by what the Elasticsearch team is doing for building the Elasticsearch Docker image - https://github.com/elastic/dockerfiles/blob/a5749cb11d8b38491c40efa476c576ab60a3a9f8/elasticsearch/Dockerfile#L16 --- .../templates/docker/Dockerfile.elastic-agent.tmpl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl b/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl index 52b0870d7193..a38ea8701a3f 100644 --- a/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl +++ b/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl @@ -5,10 +5,8 @@ FROM {{ .from }} # Installing jq needs to be installed after epel-release and cannot be in the same yum install command. -RUN yum -y --setopt=tsflags=nodocs update && \ - yum install epel-release -y && \ - yum install jq -y && \ - yum clean all +RUN for iter in {1..10}; do yum update --setopt=tsflags=nodocs -y && yum install --setopt=tsflags=nodocs -y epel-release && yum clean all && exit_code=0 && break || exit_code=$? && echo "yum error: retry $iter in 10s" && sleep 10; done; (exit $exit_code) +RUN for iter in {1..10}; do yum update -y && yum install -y jq && yum clean all && exit_code=0 && break || exit_code=$? && echo "yum error: retry $iter in 10s" && sleep 10; done; (exit $exit_code) LABEL \ org.label-schema.build-date="{{ date }}" \