Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
964635c
Added go mod
mmontes11 May 26, 2023
e330eca
Initial scaffolding
mmontes11 May 26, 2023
2db8194
HTTP server setup
mmontes11 May 28, 2023
0aaee7b
Moved server to a pkg
mmontes11 May 29, 2023
036ce55
Added logger
mmontes11 May 30, 2023
a71dddf
Router scaffolding
mmontes11 May 30, 2023
675331a
Added filemanager and examples
mmontes11 May 31, 2023
407712a
Get galerastate endpoint
mmontes11 May 31, 2023
4f05150
404 when grastate.dat not exists
mmontes11 May 31, 2023
cdc5e20
Set safe to bootstrap
mmontes11 May 31, 2023
43460a6
Adding and deleting bootstrap file
mmontes11 May 31, 2023
31abbbd
Added galera local setup
mmontes11 May 31, 2023
07f5cf9
More reliable galera state unmarshaler
mmontes11 May 31, 2023
3c19a1e
Reloading mariadbd process after bootstrap
mmontes11 May 31, 2023
5989cf0
Added recovery
mmontes11 Jun 1, 2023
a5429a5
Recover from log file
mmontes11 Jun 2, 2023
8ac22f9
Setting UUID and seqno when bootstrapping
mmontes11 Jun 2, 2023
2f92ae5
Avoid issues with JSON Marshaler by not implementing TextMarshaler
mmontes11 Jun 2, 2023
9fd167f
Fix validation
mmontes11 Jun 2, 2023
ab397a1
Validating UUIDs
mmontes11 Jun 2, 2023
daf08cb
Mariadbd reload retries
mmontes11 Jun 3, 2023
c637f5c
Bootstrap and recovery mutually exclusive
mmontes11 Jun 3, 2023
caf74e3
Support for retry configuration
mmontes11 Jun 3, 2023
568d394
Retry flags for bootstrap and recovery
mmontes11 Jun 3, 2023
55b9b88
Added mutex for preventing race conditions on config/state files
mmontes11 Jun 3, 2023
cc93bfe
Improved error handling notably by introducing response writer
mmontes11 Jun 3, 2023
021a5a6
Added galera tests
mmontes11 Jun 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
testbin/
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug
about: Create a bug report to help us improve
title: "[Bug] "
labels: bug
assignees: mmontes11

---

<!--
Bugs should be filed for issues encountered whilst operating mariadb-operator/agent.
Please provide as much detail as possible.
-->

**Describe the bug**
<!--
A clear and concise description of what the bug is.
Tip: you can use
```
<code here>
```
for code blocks of your kubectl output or YAML files.
-->

**Expected behaviour**
<!--A concise description of what you expected to happen.-->

**Steps to reproduce the bug**
<!--Steps to reproduce the bug should be clear and easily reproducible to help people
gain an understanding of the problem.-->

**Additional context**
<!--Add any other context here.-->

**Environment details**:
- Kubernetes version:
- mariadb-operator version:
- agent version:
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature]"
labels: feature
assignees: mmontes11

---

**Is your feature request related to a problem? Please describe.**
<!--A clear and concise description of what the problem is-->

**Describe the solution you'd like**
<!--A clear and concise description of what you want to happen.-->

**Describe alternatives you've considered**
<!--A clear and concise description of any alternative solutions or features you've considered.-->

**Additional context**
<!--Add any other context here.-->

**Environment details**:
- Kubernetes version:
- mariadb-operator version:
- agent version:
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI

on:
push:
branches:
- main
pull_request: {}

env:
GOLANGCI_VERSION: "v1.52.2"

jobs:
detect-noop:
runs-on: ubuntu-latest
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
steps:
- name: Detect no-op changes
id: noop
uses: fkirc/skip-duplicate-actions@v5.3.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
paths_ignore: '["**.md"]'
concurrent_skipping: false

lint:
name: Lint
runs-on: ubuntu-latest
needs: detect-noop
if: ${{ needs.detect-noop.outputs.noop != 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true

- name: GolangCI Lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCI_VERSION }}

build:
name: Build
runs-on: ubuntu-latest
needs: detect-noop
if: ${{ needs.detect-noop.outputs.noop != 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true

- name: Build
run: make build

- name: Build Docker
run: make docker-build
env:
PLATFORM: linux/amd64

test:
name: Test
runs-on: ubuntu-latest
needs: detect-noop
if: ${{ needs.detect-noop.outputs.noop != 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true

- name: Test
run: make test
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release

on:
push:
tags:
- "v*"

env:
GORELEASER_VERSION: "v1.18.2"

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Fetch tags
run: git fetch --force --tags

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx

- name: Login to container Registry
uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io

- name: Prepare
id: prep
run: |
VERSION=sha-${GITHUB_SHA::8}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF/refs\/tags\//}
fi
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=VERSION::${VERSION}

- name: Publish multi-arch Docker image
uses: docker/build-push-action@v2
with:
push: true
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/arm64,linux/amd64
tags: |
ghcr.io/${{ github.repository_owner }}/agent:${{ steps.prep.outputs.VERSION }}
ghcr.io/${{ github.repository_owner }}/agent:latest
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}

- name: Set GORELEASER_PREVIOUS_TAG
run: echo "GORELEASER_PREVIOUS_TAG=$(git tag -l "v*" --sort=-version:refname | head -n 2 | tail -n 1)" >> $GITHUB_ENV

- name: GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: ${{ env.GORELEASER_VERSION }}
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 10 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
Expand All @@ -13,9 +10,16 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.html

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/

# Go workspace file
go.work
# Binaries
bin/

# Packaged Helm charts
*.tgz

# Directory to keep MariaDB files used for development
mariadb/
31 changes: 31 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
linters-settings:
gocyclo:
min-complexity: 20
lll:
line-length: 140
misspell:
locale: US

linters:
disable-all: true
enable:
- unused
- errcheck
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nestif
- staticcheck
- typecheck
- unused
- bodyclose
- noctx

run:
timeout: 5m
go: "1.20"
14 changes: 14 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changelog:
use: github-native
builds:
- id: agent
main: main.go
binary: "agent_{{ .Version }}_{{ .Arch }}"
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "main.go"
}
]
}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.4-alpine3.18 AS builder

ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH}

WORKDIR /app

COPY go.mod go.sum /app/
RUN go mod download

COPY . /app
RUN go build -o agent main.go

FROM gcr.io/distroless/static AS app

WORKDIR /
COPY --from=builder /app/agent /bin/agent
USER 65532:65532

ENTRYPOINT ["/bin/agent"]
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

.PHONY: all
all: help

##@ General

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

include make/deploy.mk
include make/dev.mk
include make/tooling.mk
Loading