File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ FROM quay.io/openshift/origin-must-gather:4.15.0 as builder
2
2
3
3
FROM quay.io/centos/centos:stream9
4
4
5
+ ARG OS_GIT_VERSION
6
+
5
7
RUN dnf update -y && dnf install jq xz rsync python3-pyyaml openssh-clients -y && dnf clean all
6
8
7
9
COPY --from=builder /usr/bin/oc /usr/bin/oc
@@ -15,5 +17,9 @@ COPY collection-scripts/* /usr/bin/
15
17
# Copy the python script used to mask sensitive data
16
18
COPY pyscripts/mask.py /usr/bin/
17
19
20
+ # Set openstack-must-gather image version based on
21
+ # the current git info
22
+ ENV OS_GIT_VERSION=${OS_GIT_VERSION}
23
+
18
24
# Entrypoint not used when calling `oc adm must-gather`
19
25
ENTRYPOINT /usr/bin/gather
Original file line number Diff line number Diff line change 1
1
IMAGE_REGISTRY ?= quay.io/openstack-k8s-operators
2
2
IMAGE_TAG ?= latest
3
3
4
+ OS_GIT_COMMIT := $(shell git rev-parse --short "HEAD^{commit}")
5
+ OS_GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
6
+ OS_GIT_COMMIT_COUNT := $(shell git rev-list HEAD --count)
7
+ OS_GIT_VERSION := $(OS_GIT_BRANCH ) -$(OS_GIT_COMMIT_COUNT ) -g$(OS_GIT_COMMIT )
8
+
9
+ BUILD_ARGS ?= --build-arg OS_GIT_VERSION=${OS_GIT_VERSION}
10
+
4
11
check-image : # # Check if the MUST_GATHER_IMAGE variable is set
5
12
ifndef MUST_GATHER_IMAGE
6
13
$(error MUST_GATHER_IMAGE is not set.)
@@ -15,7 +22,7 @@ pytest: ## Run sanity check against python scripts in pydir
15
22
tox -c pyscripts/tox.ini
16
23
17
24
podman-build : check-image # # build the must-gather image
18
- podman build -t ${IMAGE_REGISTRY} /${MUST_GATHER_IMAGE} :${IMAGE_TAG} .
25
+ podman build -t ${IMAGE_REGISTRY} /${MUST_GATHER_IMAGE} :${IMAGE_TAG} ${BUILD_ARGS} .
19
26
20
27
podman-push : check-image # # push the must-gather image to the image registry
21
28
podman push ${IMAGE_REGISTRY} /${MUST_GATHER_IMAGE} :${IMAGE_TAG}
Original file line number Diff line number Diff line change @@ -236,6 +236,35 @@ The targets for `make` are as follows:
236
236
- `podman-build`: builds the must-gather image
237
237
- `podman-push`: pushes an already-built `must-gather` image
238
238
239
+ As per the [must-gather
240
+ guidelines](https://github.com/openshift/must-gather/blob/master/must-gather.md#must-gather-images),
241
+ when a must-gather image is built, a `OS_GIT_VERSION` environment variable is
242
+ set within the image in the form `major.minor.micro.qualifier`, so that
243
+ programmatic analysis can be developed.
244
+ For OpenStack must-gather, instad, the version is created starting from the
245
+ last commit, and it creates a qualifier based on the following commands:
246
+
247
+ ```bash
248
+ OS_GIT_COMMIT=$(git rev-parse --short "HEAD^{commit}")
249
+ OS_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
250
+ OS_GIT_COMMIT_COUNT=$(git rev-list HEAD --count)
251
+ OS_GIT_VERSION=$(OS_GIT_BRANCH)-$(OS_GIT_COMMIT_COUNT)-g$(OS_GIT_COMMIT)
252
+ ```
253
+ The resulting format is in the form: `<branch>-<number-of-commits>-g<commit-hash>`
254
+
255
+ For example, if you are on `18.0-FR2` branch, a potential output might look
256
+ like:
257
+
258
+ ```
259
+ 18.0-FR2-165-g1234567
260
+ ```
261
+
262
+ Where:
263
+
264
+ - 18.0-FR2 is the current branch
265
+ - The middle number (165) is how many commits are present in the branch
266
+ - g1234567 is the abbreviated commit hash
267
+
239
268
### Debugging container
240
269
241
270
One possible workflow that can be used for development is to run the openstack
You can’t perform that action at this time.
0 commit comments