Skip to content

Commit

Permalink
Merge branch 'main' into EVEREST-1799-rbac-groups-claim
Browse files Browse the repository at this point in the history
  • Loading branch information
recharte authored Jan 21, 2025
2 parents d8bf614 + 0732e17 commit 9ecaf78
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 178 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/auto-update-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Auto-Update PR Base

on:
push:
branches:
- main

jobs:
auto-update-base:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
try {
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
});
for (const pull of pulls) {
const hasAutoUpdateLabel = pull.labels.some(label => label.name === "auto-update-base");
if (hasAutoUpdateLabel) {
try {
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull.number,
});
if (pr.data.mergeable_state === 'dirty') {
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - Skipping update due to merge conflict.`);
continue;
}
if (pr.data.mergeable_state !== 'behind') {
console.log(`[INFO] PR #${pull.number}: "${pull.title}" - Base branch is up-to-date.`);
continue;
}
console.log(`[UPDATE] PR #${pull.number}: "${pull.title}" - Updating base branch...`);
try {
await github.rest.pulls.updateBranch({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull.number,
});
console.log(`[SUCCESS] PR #${pull.number}: "${pull.title}" - Base branch updated.`);
} catch (updateError) {
console.error(`[ERROR] PR #${pull.number}: Failed to update base branch - ${updateError.message}`);
}
} catch (diffError) {
console.error(`[ERROR] PR #${pull.number}: Failed to compare commits - ${diffError.message}`);
}
}
}
} catch (error) {
console.error(`[ERROR] Failed to list pull requests - ${error.message}`);
}
103 changes: 35 additions & 68 deletions .github/workflows/feature-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ jobs:
echo "VERSION_TAG=v$V" >> $GITHUB_ENV
echo "VS_TAG=everest-test$TIMESTAMP" >> $GITHUB_ENV
- name: Create temporary directory for storing artifacts
run: |
mkdir -p /tmp/${VERSION}
- name: Set GO_VERSION environment variable
run: |
Expand Down Expand Up @@ -211,15 +214,9 @@ jobs:
CRD_VERSION=${{ env.VERSION_TAG }} make crds-gen
make release-dev
- name: Helm - Create tar.gz archive
- name: Helm - copy chart
run: |
tar -czvf helm.tar.gz percona-helm-charts/charts/everest
- name: Helm - Upload artifact
uses: actions/upload-artifact@v4
with:
name: helm
path: helm.tar.gz
cp -r percona-helm-charts/charts/everest /tmp/${{ env.VERSION }}/helm-chart
- name: Operator - check out again
uses: actions/checkout@v4
Expand Down Expand Up @@ -353,45 +350,19 @@ jobs:
RELEASE_VERSION=${VERSION_TAG} CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make rc
RELEASE_VERSION=${VERSION_TAG} make release-cli
- name: Upload CLI artefacts
uses: actions/upload-artifact@v4
id: cli-upload-step-1
with:
name: everestctl.exe
path: ./dist/everestctl.exe
retention-days: ${{ env.ARTIFACTS_RETENTION_DAYS }}

- name: Upload CLI artefacts
uses: actions/upload-artifact@v4
id: cli-upload-step-2
with:
name: everestctl-darwin-amd64
path: ./dist/everestctl-darwin-amd64
retention-days: ${{ env.ARTIFACTS_RETENTION_DAYS }}

- name: Upload CLI artefacts
uses: actions/upload-artifact@v4
id: cli-upload-step-3
with:
name: everestctl-darwin-arm64
path: ./dist/everestctl-darwin-arm64
retention-days: ${{ env.ARTIFACTS_RETENTION_DAYS }}

- name: Upload CLI artefacts
uses: actions/upload-artifact@v4
id: cli-upload-step-4
with:
name: everestctl-linux-amd64
path: ./dist/everestctl-linux-amd64
retention-days: ${{ env.ARTIFACTS_RETENTION_DAYS }}
- name: Everest - copy CLI builds
run: |
cp dist/everestctl.exe /tmp/${VERSION}/everestctl.exe
cp dist/everestctl-darwin-amd64 /tmp/${VERSION}/everestctl-darwin-amd64
cp dist/everestctl-darwin-arm64 /tmp/${VERSION}/everestctl-darwin-arm64
cp dist/everestctl-linux-amd64 /tmp/${VERSION}/everestctl-linux-amd64
cp dist/everestctl-linux-arm64 /tmp/${VERSION}/everestctl-linux-arm64
- name: Upload CLI artefacts
uses: actions/upload-artifact@v4
id: cli-upload-step-5
with:
name: everestctl-linux-arm64
path: ./dist/everestctl-linux-arm64
retention-days: ${{ env.ARTIFACTS_RETENTION_DAYS }}
- name: Everest - copy feature build helper scripts
run: |
cp dev/fb/cli.sh /tmp/${VERSION}/cli.sh
cp dev/fb/helm.sh /tmp/${VERSION}/helm.sh
cp dev/fb/vs.sh /tmp/${VERSION}/vs.sh
- name: Everest - push Everest image
uses: docker/build-push-action@v6
Expand All @@ -402,41 +373,37 @@ jobs:

- name: Create vs_tag file
run: |
echo "$VS_TAG" > vs_tag.txt
echo "$VERSION" > fb.txt
echo "$VS_TAG" > /tmp/${VERSION}/vs_tag.txt
echo "$VERSION" > /tmp/${VERSION}/version.txt
- name: Upload VS tag info artefact
uses: actions/upload-artifact@v4
id: vs_file
with:
name: vs_tag.txt
path: ./vs_tag.txt
retention-days: ${{ env.ARTIFACTS_RETENTION_DAYS }}
- name: Version Service - create deployment manifest
run: |
curl https://raw.githubusercontent.com/Percona-Lab/percona-version-service/main/deploy.yaml > /tmp/${VERSION}/vs_deploy.yaml
sed -i "s/perconalab\/version-service:.*/perconalab\/version-service:$VS_TAG/g" /tmp/${VERSION}/vs_deploy.yaml
- name: Upload FB info artefact
- name: Upload artifacts
uses: actions/upload-artifact@v4
id: fb_file
with:
name: fb.txt
path: ./fb.txt
name: ${{ env.VERSION }}
path: /tmp/${{ env.VERSION }}
retention-days: ${{ env.ARTIFACTS_RETENTION_DAYS }}

- name: Info
run: |
printf "To install FB using helm:\n\
1. Download the 'helm' artifact below.\n\
2. Navigate to \`/everest/dev/fb directory\`.\n\
3. Run the command:\n\`\`\`VS_IMAGE=$VS_TAG HELM_PATH=<path_to_your_helmchart> sh helm.sh\`\`\`\n\
\nexample:\n\`\`\`VS_IMAGE=$VS_TAG HELM_PATH=/Users/oxana/Downloads/percona-helm-charts sh helm.sh\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
1. Download and unzip the \`$VERSION\` artifact below.\n\
2. Run the command:\n\`\`\`./helm.sh\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
printf "____________________\n" >> "$GITHUB_STEP_SUMMARY"
printf "To install FB using CLI:\n\
1. Download the 'helm' artifact below.\n\
2. Download a CLI build from artifacts below.\n\
3. Navigate to \`/everest/dev/fb\` directory.\n\
4. Run the command:\n\`\`\`VS_IMAGE=$VS_TAG VERSION=$VERSION EVEREST_CTL_PATH=<path_to_everestctl> HELM_PATH=<path_to_your_helmchart> sh cli.sh\`\`\`\n\
\nexample:\n\`\`\`VS_IMAGE=$VS_TAG VERSION=$VERSION HELM_PATH=/Users/oxana/Downloads/percona-helm-charts EVEREST_CTL_PATH=/Users/oxana/Downloads/everestctl-darwin-arm64 sh cli.sh\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
1. Download and unzip the \`$VERSION\` artifact below.\n\
2. Run the command:\n\`\`\`./cli.sh\`\`\`\n" >> "$GITHUB_STEP_SUMMARY"
printf "____________________\n" >> "$GITHUB_STEP_SUMMARY"
printf "To clean up the environment after a FB:\n\
1. Delete VS: \`kubectl delete deployment percona-version-service && kubectl delete svc percona-version-service\`\n\
2. Uninstall Everest using the FB everestctl build: \`./<everestctl-OS-ARCH> uninstall --assume-yes --force\` \n" >> "$GITHUB_STEP_SUMMARY"
10 changes: 3 additions & 7 deletions commands/namespaces/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ var (
// NewAddCommand returns a new command to add a new namespace.
func NewAddCommand(l *zap.SugaredLogger) *cobra.Command {
cmd := &cobra.Command{
Use: "add",
Use: "add [flags] NAMESPACES",
Long: "Add a new namespace",
Short: "Add a new namespace",
Example: `everestctl namespaces add [NAMESPACE] [FLAGS]`,
Example: `everestctl namespaces add --operator.mongodb=true --operator.postgresql=false --operator.xtradb-cluster=false --skip-wizard ns-1,ns-2`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
initAddViperFlags(cmd)
c := &namespaces.NamespaceAddConfig{}
Expand All @@ -39,12 +40,7 @@ func NewAddCommand(l *zap.SugaredLogger) *cobra.Command {
}
bindInstallHelmOpts(c)

if len(args) != 1 {
output.PrintError(fmt.Errorf("invalid number of arguments: expected 1, got %d", len(args)), l, true)
os.Exit(1)
}
c.Namespaces = args[0]

enableLogging := viper.GetBool("verbose") || viper.GetBool("json")
c.Pretty = !enableLogging

Expand Down
29 changes: 14 additions & 15 deletions commands/namespaces/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ const forceUninstallHint = "HINT: use --force to remove the namespace and all it
// NewRemoveCommand returns a new command to remove an existing namespace.
func NewRemoveCommand(l *zap.SugaredLogger) *cobra.Command {
cmd := &cobra.Command{
Use: "remove",
Long: "Remove an existing namespace",
Short: "Remove an existing namespace",
Example: `everestctl namespaces remove [NAMESPACE] [FLAGS]`,
Use: "remove [flags] NAMESPACES",
Long: "Remove existing and managed by Everest namespaces",
Short: "Remove existing and managed by Everest namespaces",
Example: `everestctl namespaces remove --keep-namespace --force ns-1,ns-2`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
initRemoveViperFlags(cmd)
c := &namespaces.NamespaceRemoveConfig{}
Expand All @@ -32,28 +33,26 @@ func NewRemoveCommand(l *zap.SugaredLogger) *cobra.Command {
l.Error(err)
return
}

if len(args) != 1 {
output.PrintError(fmt.Errorf("invalid number of arguments: expected 1, got %d", len(args)), l, true)
os.Exit(1)
}

namespace := args[0]
c.Namespaces = []string{namespace}
c.Namespaces = args[0]

enableLogging := viper.GetBool("verbose") || viper.GetBool("json")
c.Pretty = !enableLogging

if err := c.Populate(cmd.Context()); err != nil {
if errors.Is(err, namespaces.ErrNamespaceNotEmpty) {
err = fmt.Errorf("%w. %s", err, forceUninstallHint)
}
output.PrintError(err, l, !enableLogging)
os.Exit(1)
}

op, err := namespaces.NewNamespaceRemove(*c, l)
if err != nil {
output.PrintError(err, l, !enableLogging)
return
}

if err := op.Run(cmd.Context()); err != nil {
if errors.Is(err, namespaces.ErrNamespaceNotEmpty) {
err = fmt.Errorf("%w. %s", err, forceUninstallHint)
}
output.PrintError(err, l, !enableLogging)
os.Exit(1)
}
Expand Down
20 changes: 12 additions & 8 deletions commands/namespaces/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package namespaces

import (
"errors"
"fmt"
"os"

Expand All @@ -18,10 +19,11 @@ import (
// NewUpdateCommand returns a new command to update an existing namespace.
func NewUpdateCommand(l *zap.SugaredLogger) *cobra.Command {
cmd := &cobra.Command{
Use: "update",
Long: "Update an existing Everest namespace",
Short: "Update an existing Everest namespace",
Example: `everestctl update add [NAMESPACE] [FLAGS]`,
Use: "update [flags] NAMESPACES",
Long: "Add database operator to existing namespace managed by Everest",
Short: "Add database operator to existing namespace managed by Everest",
Example: `everestctl namespaces update --operator.mongodb=true --skip-wizard ns-1,ns-2`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
initUpdateViperFlags(cmd)
c := &namespaces.NamespaceAddConfig{}
Expand All @@ -33,10 +35,6 @@ func NewUpdateCommand(l *zap.SugaredLogger) *cobra.Command {
bindInstallHelmOpts(c)
c.Update = true

if len(args) != 1 {
output.PrintError(fmt.Errorf("invalid number of arguments: expected 1, got %d", len(args)), l, true)
os.Exit(1)
}
c.Namespaces = args[0]

enableLogging := viper.GetBool("verbose") || viper.GetBool("json")
Expand All @@ -47,6 +45,12 @@ func NewUpdateCommand(l *zap.SugaredLogger) *cobra.Command {
cmd.Flags().Lookup("operator.xtradb-cluster").Changed)

if err := c.Populate(cmd.Context(), false, askOperators); err != nil {
if errors.Is(err, namespaces.ErrNamespaceNotManagedByEverest) {
err = fmt.Errorf("%w. HINT: use 'everestctl namespaces add --%s %s' first to make namespace managed by Everest",
err,
cli.FlagTakeNamespaceOwnership,
c.Namespaces)
}
output.PrintError(err, l, !enableLogging)
os.Exit(1)
}
Expand Down
36 changes: 15 additions & 21 deletions dev/fb/cli.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
#!/usr/bin/env bash

if [[ -z "$VS_IMAGE" ]]; then
echo "Error: VS_IMAGE environment variable is empty." >&2
exit 1
fi

if [[ -z "$VERSION" ]]; then
echo "Error: VERSION environment variable is empty." >&2
exit 1
fi
# deploy VS and get it's internal IP
SERVICE_IP=$(./vs.sh)

if [[ -z "$HELM_PATH" ]]; then
echo "Error: HELM_PATH environment variable is empty. Please add the absolute path to your helm build to the HELM_PATH environment variable." >&2
exit 1
fi
kubectl port-forward svc/percona-version-service 8081:80 &

if [[ -z "$EVEREST_CTL_PATH" ]]; then
echo "Error: EVEREST_CTL_PATH environment variable is empty." >&2
exit 1
fi
# sleep for 2 seconds to make sure the port-forward is ready
sleep 2

# deploy VS and get it's internal IP
SERVICE_IP=$(curl -sfL https://raw.githubusercontent.com/percona/everest/main/dev/fb/vs.sh | bash -s)
os=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | tr '[:upper:]' '[:lower:]')

kubectl port-forward svc/percona-version-service 8081:80 &
if [[ ($os == "linux" || $os == "darwin") && $arch == "x86_64" ]]
then
arch="amd64"
elif [[ $os == "linux" && $arch == "aarch64" ]]
then
arch="arm64"
fi

# run everest installation with everest CLI
"$EVEREST_CTL_PATH" install --chart-dir "$HELM_PATH/charts/everest" --version "$VERSION" --version-metadata-url http://localhost:8081 --operator.xtradb-cluster --operator.mongodb --operator.postgresql --skip-wizard --namespaces everest -v --helm.set "versionMetadataURL=http://$SERVICE_IP"
"./everestctl-$os-$arch" install --chart-dir "helm-chart" --version "$(cat version.txt)" --version-metadata-url http://localhost:8081 --operator.xtradb-cluster --operator.mongodb --operator.postgresql --skip-wizard --namespaces everest -v --helm.set "versionMetadataURL=http://$SERVICE_IP"
Loading

0 comments on commit 9ecaf78

Please sign in to comment.