Skip to content

Commit

Permalink
Save VCluster library to K8s repo (#1017)
Browse files Browse the repository at this point in the history
Since we plan to remove the VCluster GitHub repository, we need to save
it within the K8s repository. Afterward, the CI/CD pipeline will update
the VCluster folder directly instead of updating the VCluster version in
go.mod.

Initially, I considered using "go mod vendor" to store the VCluster
library. However, "go mod vendor" attempts to download the entire
"Vertica Server" repository (where VCluster is located), which is
unnecessary. Therefore, I decided to manually copy the VCluster library
into the K8s repository instead.
  • Loading branch information
cchen-vertica authored Jan 30, 2025
1 parent 4b64534 commit 0367389
Show file tree
Hide file tree
Showing 248 changed files with 43,185 additions and 31 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ jobs:
docker buildx imagetools create --tag opentext/verticadb-operator-private:${{ github.sha }} ${{ needs.build.outputs.operator-image }}
sync-vcluster:
name: Sync-vcluster-repo
name: Sync-vcluster-code
needs: [
e2e-leg-1-vcluster,
e2e-leg-2-vcluster,
Expand All @@ -806,31 +806,37 @@ jobs:
runs-on: ubuntu-latest
if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && contains(github.ref, 'k8s-sync') && (github.event_name == 'push')}}
steps:
- name: Check out
uses: actions/checkout@v4
- name: Run Sync script
- name: Create a PR
run: |
echo "Running sync script"
scripts/vcluster-sync.sh ${{ github.ref }} main ${{ secrets.VCLUSTER_CICD }}
# Get the current branch name
current_branch="${GITHUB_REF#refs/heads/}"
# Define the API endpoint and PR details
api_url="https://api.github.com/repos/${{ github.repository }}/pulls"
title="CICD for VClusterOps Synchronization"
body="This PR was automatically generated by CICD pipeline to sync vclusterOps."
base="main"
head="$current_branch"
# Create the pull request via the GitHub API
curl -X POST "$api_url" \
-H "Authorization: token ${{ github.token }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "$(echo "{\"title\": \"$title\", \"body\": \"$body\", \"head\": \"$head\", \"base\": \"$base\"}")"
notification:
name: team-notification
needs: [sync-vcluster]
runs-on: ubuntu-latest
if: ${{ always() && contains(github.ref, 'k8s-sync') }}
steps:
- name: Get vcluster commit url
run: |
VCLUSTER_REF=$(echo ${{ github.event.head_commit.message }} | awk '{print $NF}')
echo "VCLUSTER_URL=${{ github.server_url }}/vertica/vcluster/commit/$VCLUSTER_REF" >> $GITHUB_ENV
- name: notification on success
if: ${{ always() && contains(needs.sync-vcluster.result, 'success') }}
uses: jdcargile/[email protected]
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: Success | worflow ${{ github.workflow }} on branch ${{ github.ref_name }} with <a href="${{ env.VCLUSTER_URL }}">VCluster commit changes</a>
notification-summary: Success | workflow ${{ github.workflow }} on branch ${{ github.ref_name }}
notification-color: 28a745
verbose-logging: true

Expand All @@ -840,6 +846,6 @@ jobs:
with:
github-token: ${{ github.token }}
ms-teams-webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
notification-summary: Failure | worflow ${{ github.workflow }} on branch ${{ github.ref_name }} with <a href="${{ env.VCLUSTER_URL }}">VCluster commit changes</a>
notification-summary: Failure | workflow ${{ github.workflow }} on branch ${{ github.ref_name }}
notification-color: dc3545
verbose-logging: true
1 change: 1 addition & 0 deletions docker-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ COPY cmd/operator/*.go-generate.txt .
COPY cmd/operator/main.go main.go
COPY api/ api/
COPY pkg/ pkg/
COPY local-libs/ local-libs/

# Build
# the GOARCH has not a default value to allow the binary be built according to
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/onsi/gomega v1.24.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/vertica/vcluster v1.2.1-0.20241217143203-210ca4ab9119
github.com/vertica/vcluster v1.0.0
github.com/vertica/vertica-sql-go v1.1.1
go.uber.org/zap v1.25.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
Expand Down Expand Up @@ -100,3 +100,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

replace github.com/vertica/vcluster => ./local-libs/vcluster
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ github.com/theckman/yacspin v0.13.12 h1:CdZ57+n0U6JMuh2xqjnjRq5Haj6v1ner2djtLQRz
github.com/theckman/yacspin v0.13.12/go.mod h1:Rd2+oG2LmQi5f3zC3yeZAOl245z8QOvrH4OPOJNZxLg=
github.com/tonglil/buflogr v1.0.1 h1:WXFZLKxLfqcVSmckwiMCF8jJwjIgmStJmg63YKRF1p0=
github.com/tonglil/buflogr v1.0.1/go.mod h1:yYWwvSpn/3uAaqjf6mJg/XMiAciaR0QcRJH2gJGDxNE=
github.com/vertica/vcluster v1.2.1-0.20241217143203-210ca4ab9119 h1:lbHJN3wjPWZNrVrJ0SkFBiqjQ4yrop/kPD2icKYE3ms=
github.com/vertica/vcluster v1.2.1-0.20241217143203-210ca4ab9119/go.mod h1:yZ3lnvlwuXWgyCZ9Z6bMYisVjP6Ecffl+Lk5wGX/lPQ=
github.com/vertica/vertica-sql-go v1.1.1 h1:sZYijzBbvdAbJcl4cYlKjR+Eh/X1hGKzukWuhh8PjvI=
github.com/vertica/vertica-sql-go v1.1.1/go.mod h1:fGr44VWdEvL+f+Qt5LkKLOT7GoxaWdoUCnPBU9h6t04=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
20 changes: 20 additions & 0 deletions local-libs/vcluster/.github/workflows/merge_branch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Merge branch
on:
repository_dispatch:
types: curl_request_merge
jobs:
unit-test:
uses: ./.github/workflows/unittests.yaml

sync-branch:
needs: [unit-test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Merge branch ${{ github.event.client_payload.source_branch }} -> ${{ github.event.client_payload.target_branch }}
uses: everlytic/[email protected]
with:
source_ref: ${{ github.event.client_payload.source_branch }}
target_branch: ${{ github.event.client_payload.target_branch }}
github_token: ${{ github.token }}
commit_message_template: '[Automated] Merged {source_ref} into target {target_branch}'
24 changes: 24 additions & 0 deletions local-libs/vcluster/.github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Unit tests

on:
workflow_dispatch:
workflow_call:
push:

jobs:

ut:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
# When changing this, be sure to update the version at:
# vertica/make/build-container/*Dockerfile
go-version: "1.22.5"

- name: Run unit tests
run: make vet lint test

2 changes: 2 additions & 0 deletions local-libs/vcluster/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage.out
bin/
141 changes: 141 additions & 0 deletions local-libs/vcluster/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
linters-settings:
depguard:
rules:
main:
allow:
- $gostd
- github.com
- vertica.com
- k8s.io
dupl:
threshold: 100
funlen:
lines: 100
statements: 50
gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
gci:
local-prefixes: github.com/golangci/golangci-lint
goconst:
min-len: 2
min-occurrences: 2
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
gocyclo:
min-complexity: 15
goimports:
local-prefixes: github.com/golangci/golangci-lint
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]
govet:
check-shadowing: true
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-leading-space: false
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
- exhaustive
- funlen
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- revive
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- nolintlint
- staticcheck
- stylecheck
- typecheck
- unconvert
- unused
- whitespace

# don't enable:
# - asciicheck
# - scopelint
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - interfacer
# - maligned
# - nestif
# - prealloc
# - testpackage
# - revive
# - wsl

# disabled because of go 1.18
# in May 2022
# - bodyclose
# - noctx
# - rowserrcheck
# - structcheck
# - unparam
#

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd

# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"

run:
concurrency: 4
timeout: 5m
28 changes: 28 additions & 0 deletions local-libs/vcluster/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This document guides you through the contribution process:

- [Bug Reports](#bug-reports)
- [Feature Requests](#feature-requests)
- [Code Contributions](#code-contributions)

# Bug Reports

If you find a bug, [submit an issue](https://github.com/vertica/vcluster/issues)
with a complete and reproducible bug report.

For issues that are **not suitable** to be reported publicly on the GitHub
issue system (e.g., security related issues), report your issues to [Vertica
open source team](mailto:[email protected]) directly or file a
case with Vertica support, if you have a support account.

# Feature Requests

The Vertica team is always open to suggestions--feel free to share your ideas
about how to improve *vcluster-ops*. To provide suggestions, [open an
issue](https://github.com/vertica/vcluster/issues) with details describing
what feature(s) you would like added or changed.

# Code Contributions

At this time we are not accepting any code contributions. All development for
this repository is done internally at Vertica. Code is periodically
synchronized from the internal server repository to this public repository.
Loading

0 comments on commit 0367389

Please sign in to comment.