Skip to content

Commit

Permalink
ci: ovn-kubernetes: Figure out dependencies dynamically.
Browse files Browse the repository at this point in the history
This avoids manual intervention when upstream ovn-kubernetes changes
its dependency versions.

Signed-off-by: Patryk Diak <pdiak@redhat.com>
Co-authored-by: Patryk Diak <pdiak@redhat.com>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Acked-by: Aaron Conole <aconole@redhat.com>
  • Loading branch information
dceara and kyrtapz committed Jun 22, 2023
1 parent 3d0f68f commit 1f36e8b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
16 changes: 9 additions & 7 deletions .ci/ovn-kubernetes/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG OVNKUBE_COMMIT=master
ARG LIBOVSDB_COMMIT=a6a173993830
ARG GO_VERSION

FROM fedora:37 AS ovnbuilder

Expand Down Expand Up @@ -34,12 +34,9 @@ RUN rm rpm/rpmbuild/RPMS/x86_64/*debug*
RUN rm rpm/rpmbuild/RPMS/x86_64/*docker*

# Build ovn-kubernetes
FROM golang:1.18 as ovnkubebuilder
ARG GO_VERSION
FROM golang:$GO_VERSION as ovnkubebuilder
ARG OVNKUBE_COMMIT
ARG LIBOVSDB_COMMIT

# Get a working version of libovsdb (for modelgen).
RUN GO111MODULE=on go install github.com/ovn-org/libovsdb/cmd/modelgen@${LIBOVSDB_COMMIT}

# Clone OVN Kubernetes and build the binary based on the commit passed as argument
WORKDIR /root
Expand All @@ -52,9 +49,14 @@ RUN git checkout ${OVNKUBE_COMMIT} && git log -n 1
RUN mkdir -p /tmp/ovn/.ci/ovn-kubernetes
COPY .ci/ovn-kubernetes /tmp/ovn/.ci/ovn-kubernetes
WORKDIR /tmp/ovn
RUN .ci/ovn-kubernetes/prepare.sh /root/ovn-kubernetes
RUN .ci/ovn-kubernetes/prepare.sh /root/ovn-kubernetes /dev/null

WORKDIR /root/ovn-kubernetes/go-controller
# Get a working version of libovsdb (for modelgen).
RUN GO111MODULE=on go install github.com/ovn-org/libovsdb/cmd/modelgen@$( \
go list -mod=mod -m -f '{{ .Version }}' github.com/ovn-org/libovsdb \
)

# Make sure we use the OVN NB/SB schema from the local code.
COPY --from=ovnbuilder /tmp/ovn/ovn-nb.ovsschema pkg/nbdb/ovn-nb.ovsschema
COPY --from=ovnbuilder /tmp/ovn/ovn-sb.ovsschema pkg/sbdb/ovn-sb.ovsschema
Expand Down
11 changes: 11 additions & 0 deletions .ci/ovn-kubernetes/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@
set -ev

ovnk8s_path=$1
env_path=$2
topdir=$PWD

function extract_ci_var() {
local name=$1

grep "$name:" .github/workflows/test.yml | awk '{print $2}' | tr -d '"'
}

pushd ${ovnk8s_path}

# Add here any custom operations that need to performed on the
# ovn-kubernetes cloned repo, e.g., custom patches.

# Set up the right GO_VERSION and K8S_VERSION.
echo "GO_VERSION=$(extract_ci_var GO_VERSION)" >> $env_path
echo "K8S_VERSION=$(extract_ci_var K8S_VERSION)" >> $env_path

# git apply --allow-empty is too new so not all git versions from major
# distros support it, just check if the custom patch file is not empty
# before applying it.
Expand Down
31 changes: 19 additions & 12 deletions .github/workflows/ovn-kubernetes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: "1.18.4"
K8S_VERSION: v1.24.0
OVNKUBE_COMMIT: "master"
LIBOVSDB_COMMIT: "a6a173993830"
KIND_CLUSTER_NAME: ovn
KIND_INSTALL_INGRESS: true
KIND_ALLOW_SYSTEM_WRITES: true
Expand All @@ -39,10 +36,20 @@ jobs:
with:
submodules: recursive

- name: Check out ovn-kubernetes
uses: actions/checkout@v3
with:
path: src/github.com/ovn-org/ovn-kubernetes
repository: ovn-org/ovn-kubernetes

- name: Prepare
run: |
.ci/ovn-kubernetes/prepare.sh src/github.com/ovn-org/ovn-kubernetes $GITHUB_ENV
- name: Build ovn-kubernetes container
run: |
docker build --build-arg OVNKUBE_COMMIT=${{ env.OVNKUBE_COMMIT }} \
--build-arg LIBOVSDB_COMMIT=${{ env.LIBOVSDB_COMMIT }} \
--build-arg GO_VERSION=${{ env.GO_VERSION }} \
--squash -t ovn-daemonset-f:dev -f .ci/ovn-kubernetes/Dockerfile .
mkdir /tmp/_output
docker save ovn-daemonset-f:dev > /tmp/_output/image.tar
Expand Down Expand Up @@ -91,12 +98,6 @@ jobs:
- name: Free up disk space
run: sudo eatmydata apt-get remove --auto-remove -y aspnetcore-* dotnet-* libmono-* mono-* msbuild php-* php7* ghc-* zulu-*

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out ovn
uses: actions/checkout@v3

Expand All @@ -108,9 +109,15 @@ jobs:

- name: Prepare
run: |
.ci/ovn-kubernetes/prepare.sh src/github.com/ovn-org/ovn-kubernetes
.ci/ovn-kubernetes/prepare.sh src/github.com/ovn-org/ovn-kubernetes $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Set up environment
- name: Set up GOPATH
run: |
export GOPATH=$(go env GOPATH)
echo "GOPATH=$GOPATH" >> $GITHUB_ENV
Expand Down

0 comments on commit 1f36e8b

Please sign in to comment.