Skip to content

Commit

Permalink
[yum] Clear cached data and add retry loop (elastic#19182)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mgreau authored and melchiormoulin committed Oct 14, 2020
1 parent 794cce1 commit f18530d
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}" \
Expand Down

0 comments on commit f18530d

Please sign in to comment.