Skip to content

Commit

Permalink
fix things
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lamarre <[email protected]>
  • Loading branch information
alexandreLamarre committed Apr 18, 2024
1 parent 9b65659 commit 7ae836b
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 140 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/e2e-test.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/e2e/scripts/setup-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ wait_for_nodes(){
done
}

k3d cluster delete ${CLUSTER_NAME} || true
k3d cluster create ${CLUSTER_NAME}


Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ builds:
- -extldflags
- -static
- -s
- -X main.Version={{.Version}} -X main.GitCommit={{.Commit}}
flags:
- -trimpath
env:
- CGO_ENABLED=0
# same archives as opentelemetry-collector releases
archives:
- id: backup-restore-operator
builds:
Expand Down
28 changes: 14 additions & 14 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ RUN if [ "${ARCH}" != "s390x" ]; then \
helm plugin install https://github.com/quintush/helm-unittest; \
fi

ENV K3S_BINARY_amd64=k3s \
K3S_BINARY_arm64=k3s-arm64 \
K3S_BINARY=K3S_BINARY_${ARCH}
# ENV K3S_BINARY_amd64=k3s \
# K3S_BINARY_arm64=k3s-arm64 \
# K3S_BINARY=K3S_BINARY_${ARCH}

ARG K8S_VERSION_FROM_CI
ENV K8S_VERSION $K8S_VERSION_FROM_CI
Expand All @@ -29,17 +29,17 @@ RUN if [ -z "${K8S_VERSION}" ]; then export K8S_VERSION="v1.24" && echo $(date +

RUN echo "${K8S_VERSION}"

RUN curl -sL https://github.com/rancher/k3s/releases/download/$(curl -Ls -o /dev/null -w %{url_effective} https://update.k3s.io/v1-release/channels/${K8S_VERSION} | awk -F/ '{ print $NF }')/${!K3S_BINARY} > /usr/local/bin/k3s && \
chmod +x /usr/local/bin/k3s

RUN if [ "${ARCH}" != "s390x" ]; then \
curl -sL https://dl.min.io/client/mc/release/linux-${ARCH}/mc > /usr/local/bin/mc && \
chmod +x /usr/local/bin/mc; \
fi
RUN curl --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.4.6 K3D_INSTALL_DIR="/usr/local/bin" bash
RUN curl -LO --fail "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${ARCH}/kubectl" && \
chmod +x kubectl && \
mv kubectl /usr/local/bin/kubectl
# RUN curl -sL https://github.com/rancher/k3s/releases/download/$(curl -Ls -o /dev/null -w %{url_effective} https://update.k3s.io/v1-release/channels/${K8S_VERSION} | awk -F/ '{ print $NF }')/${!K3S_BINARY} > /usr/local/bin/k3s && \
# chmod +x /usr/local/bin/k3s

# RUN if [ "${ARCH}" != "s390x" ]; then \
# curl -sL https://dl.min.io/client/mc/release/linux-${ARCH}/mc > /usr/local/bin/mc && \
# chmod +x /usr/local/bin/mc; \
# fi
# RUN curl --fail https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.4.6 K3D_INSTALL_DIR="/usr/local/bin" bash
# RUN curl -LO --fail "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${ARCH}/kubectl" && \
# chmod +x kubectl && \
# mv kubectl /usr/local/bin/kubectl

ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS CROSS_ARCH USE_DOCKER_BUILDX
ENV DAPPER_SOURCE /go/src/github.com/rancher/backup-restore-operator/
Expand Down
22 changes: 22 additions & 0 deletions docs/integration-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Integration testing

### Requirements

- [mc](https://min.io/docs/minio/linux/reference/minio-mc.html), a command line client for minio
- [k3d](https://k3d.io/v5.6.3/), a command line tool for managing k3s clusters in docker

See CI install scripts in `./.github/workflows/e2e/scripts/`

### Running

Set up a test cluster:

```bash
CLUSTER_NAME="test-cluster" ./.github/workflows/e2e/scripts/setup-cluster.sh
```

Run:

```bash
./scripts/integration
```
10 changes: 3 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ const (
)

var (
version = "v0.0.0-dev"
commit = "HEAD"
date = "1970-01-01T00:00:00Z"
)

var (
Version = "v0.0.0-dev"
GitCommit = "HEAD"
LocalBackupStorageLocation = "/var/lib/backups" // local within the pod, this is the mountPath for PVC
KubeConfig string
OperatorPVEnabled string
Expand Down Expand Up @@ -85,7 +81,7 @@ func main() {
logrus.Tracef("Loglevel set to [%v]", logrus.TraceLevel)
}

logrus.Infof("Starting backup-restore controller version %s (%s), built at : %s", version, commit, date)
logrus.Infof("Starting backup-restore controller version %s (%s)", Version, GitCommit)
ctx := signals.SetupSignalContext()
restKubeConfig, err := kubeconfig.GetNonInteractiveClientConfig(KubeConfig).ClientConfig()
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ if [ "$(uname)" = "Linux" ]; then
OTHER_LINKFLAGS="-extldflags -static -s"
fi

LINKFLAGS="-X main.version=$VERSION"
LINKFLAGS="-X main.commit=$COMMIT $LINKFLAGS"
LINKFLAGS="-X main.date=$DATE $LINKFLAGS"
LINKFLAGS="-X main.Version=$VERSION"
LINKFLAGS="-X main.GitCommit=$COMMIT $LINKFLAGS"


ARCHES=( "$ARCH" )
Expand Down
6 changes: 0 additions & 6 deletions scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@ set -e

cd $(dirname $0)

export CLUSTER_NAME="backup-restore-operator"

./build
./test
./validate
./validate-ci
./package
./chart/test
./hull
# integration tests
# ./cleanup-cluster.sh
# ./setup-cluster.sh
# ./integration
4 changes: 0 additions & 4 deletions scripts/cleanup-cluster.sh

This file was deleted.

28 changes: 0 additions & 28 deletions scripts/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ EOF
)

KUBECTL_CMD="kubectl"
# if command -v k3s &> /dev/null ; then
# KUBECTL_CMD="k3s kubectl"
# else
check_kubeconfig
# fi

helm repo add minio https://charts.min.io/
helm repo update
Expand All @@ -66,11 +62,7 @@ EOF

list_minio_files() {
KUBECTL_CMD="kubectl"
# if command -v k3s &> /dev/null ; then
# KUBECTL_CMD="k3s kubectl"
# else
check_kubeconfig
# fi

local POD_NAME
POD_NAME=$("${KUBECTL_CMD}" get pods --namespace minio -l "release=minio" -o jsonpath="{.items[0].metadata.name}")
Expand All @@ -88,11 +80,7 @@ list_minio_files() {

retrieve_minio_files() {
KUBECTL_CMD="kubectl"
# if command -v k3s &> /dev/null ; then
# KUBECTL_CMD="k3s kubectl"
# else
check_kubeconfig
# fi

local POD_NAME
POD_NAME=$("${KUBECTL_CMD}" get pods --namespace minio -l "release=minio" -o jsonpath="{.items[0].metadata.name}")
Expand All @@ -115,11 +103,7 @@ retrieve_minio_files() {

copy_minio_files() {
KUBECTL_CMD="kubectl"
# if command -v k3s &> /dev/null ; then
# KUBECTL_CMD="k3s kubectl"
# else
check_kubeconfig
# fi

local POD_NAME
POD_NAME=$("${KUBECTL_CMD}" get pods --namespace minio -l "release=minio" -o jsonpath="{.items[0].metadata.name}")
Expand All @@ -142,11 +126,7 @@ copy_minio_files() {

reset_minio_bucket() {
KUBECTL_CMD="kubectl"
# if command -v k3s &> /dev/null ; then
# KUBECTL_CMD="k3s kubectl"
# else
check_kubeconfig
# fi

local POD_NAME
POD_NAME=$("${KUBECTL_CMD}" get pods --namespace minio -l "release=minio" -o jsonpath="{.items[0].metadata.name}")
Expand Down Expand Up @@ -190,11 +170,7 @@ deploy_backup_restore() {
create_backup() {
KUBECTL_CMD="kubectl"

# if command -v k3s &> /dev/null ; then
# KUBECTL_CMD="k3s kubectl"
# else
check_kubeconfig
# fi

if [[ "$1" = "insecure" ]]; then
${KUBECTL_CMD} create -f - <<EOF
Expand Down Expand Up @@ -249,11 +225,7 @@ create_restore() {
fi
BACKUP="$1"

# if command -v k3s &> /dev/null ; then
# KUBECTL_CMD="k3s kubectl"
# else
check_kubeconfig
# fi

if [[ "$insecure" = "true" ]]; then
${KUBECTL_CMD} create -f - <<EOF
Expand Down
24 changes: 0 additions & 24 deletions scripts/integration
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,6 @@ source ./scripts/version

echo_with_time "INFO - Running $0"

# == Comment out cluster specific setup code for now ==

# cd $(dirname $0)/..

# k3s server --disable servicelb --disable traefik --disable local-storage --disable metrics-server > /tmp/k3s.log 2>&1 &
# k3s_pid=$!

# export KUBECONFIG=/etc/rancher/k3s/k3s.yaml

# echo_with_time 'Waiting for node to be ready ...'
# time timeout 300 bash -c 'while ! (k3s kubectl wait --for condition=ready node/$(hostname) 2>/dev/null); do sleep 5; done'
# time timeout 300 bash -c 'while ! (k3s kubectl --namespace kube-system rollout status --timeout 10s deploy/coredns 2>/dev/null); do sleep 5; done'

# echo_with_time "using kubectl and kubernetes versions:"
# k3s kubectl version

# k3s kubectl get nodes -o wide --show-labels

# docker image save rancher/backup-restore-operator:$TAG -o /tmp/bro.img

# k3s ctr images import /tmp/bro.img

## == End of cluster specific setup code ==

ls -la ./dist/artifacts

# In case short commit only conists of numbers, it is regarded valid by Helm when packaging
Expand Down
1 change: 0 additions & 1 deletion scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ fi

COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
Expand Down

0 comments on commit 7ae836b

Please sign in to comment.