Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

EVEREST-489 Added version endpoint #235

Merged
merged 14 commits into from
Oct 17, 2023
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**
!bin/percona-everest-backend
!cmd
!migrations
!model
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
cp -rf ${GITHUB_WORKSPACE}/front/* ${GITHUB_WORKSPACE}/backend/public/dist/
cd ${GITHUB_WORKSPACE}/backend

- name: Build Everest
run: GOOS=linux GOARCH=amd64 make build

- name: Set tag from inputs
run: echo "IMAGE_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
if: ${{ github.event.inputs.tag != '' }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/rc_rebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ jobs:
mkdir ${GITHUB_WORKSPACE}/front
cp -rf build/percona.apps_everest/react-common-js/everest/public/* ${GITHUB_WORKSPACE}/front/

- name: Build Everest
run: GOOS=linux GOARCH=amd64 make release

- name: Check out Everest Backend
uses: actions/checkout@v4
with:
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Everest Frontend - create tag
run: |
cd percona-everest-frontend
git tag $TAG
git tag -a $TAG -m "Release ${TAG}"
git push origin $TAG

- name: Everest Frontend - run with Node 16
Expand Down Expand Up @@ -93,14 +93,17 @@ jobs:
echo "$(git diff deploy/quickstart-compose.yml deploy/quickstart-k8s.yaml)"
git commit -a -m "update scripts"

git tag $TAG
git tag -a $TAG -m "Release ${TAG}"
git push origin $TAG

- name: Everest Backend - Embed Everest Frontend app into backend
run: |
cp -rf ${GITHUB_WORKSPACE}/front/* ${GITHUB_WORKSPACE}/backend/public/dist/
cd ${GITHUB_WORKSPACE}/backend

- name: Build Everest release
run: GOOS=linux GOARCH=amd64 make release

- name: Everest - Setup docker build metadata
uses: docker/metadata-action@v5
id: meta
Expand All @@ -122,5 +125,3 @@ jobs:
context: backend
push: true
tags: ${{ steps.meta.outputs.tags }}
build-args: |
"IS_RELEASE=1"
18 changes: 1 addition & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,13 @@ WORKDIR /everest

COPY . .

ARG IS_RELEASE
gen1us2k marked this conversation as resolved.
Show resolved Hide resolved

ARG TELEMETRY_URL="https://check.percona.com"
ARG TELEMETRY_INTERVAL="24h"

RUN if [[ $IS_RELEASE = 1 ]]; then \
# for the release builds set up the production telemetry parameters
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -ldflags "\
-X 'github.com/percona/percona-everest-backend/cmd/config.TelemetryURL=$TELEMETRY_URL' \
-X 'github.com/percona/percona-everest-backend/cmd/config.TelemetryInterval=$TELEMETRY_INTERVAL'" \
-o /everest-api cmd/main.go; \
else \
# for all the other builds no telemetry parameters are provided by default
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /everest-api cmd/main.go; \
fi

recharte marked this conversation as resolved.
Show resolved Hide resolved
RUN apk add -U --no-cache ca-certificates

FROM scratch

WORKDIR /

COPY --from=build /everest-api /everest-api
COPY ./bin/percona-everest-backend /everest-api
recharte marked this conversation as resolved.
Show resolved Hide resolved
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY migrations /migrations

Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FILES = $(shell find . -type f -name '*.go')

RELEASE_VERSION ?= $(shell git describe --always --tags --dirty | cut -b2-)
RELEASE_FULLCOMMIT ?= $(shell git rev-parse HEAD)

FLAGS = -X 'github.com/percona/percona-everest-backend/pkg/version.ProjectName=Everest Backend' \
-X 'github.com/percona/percona-everest-backend/pkg/version.Version=$(RELEASE_VERSION)' \
-X 'github.com/percona/percona-everest-backend/pkg/version.FullCommit=$(RELEASE_FULLCOMMIT)' \

LD_FLAGS = -ldflags " $(FLAGS) "

default: help

help: ## Display this help message
Expand All @@ -11,10 +20,15 @@ init: ## Install development tools
cd tools && go generate -x -tags=tools

build: ## Build binaries
go build -race -o bin/percona-everest-backend ./cmd
go build -v $(LD_FLAGS) -o bin/percona-everest-backend ./cmd

release: FLAGS += -X 'github.com/percona/percona-everest-backend/cmd/config.TelemetryURL=https://check.percona.com/'\ -X 'github.com/percona/percona-everest-backend/cmd/config.TelemetryInterval=24h'

release: build ## Build release version


build-debug: ## Build binaries
go build -tags debug -race -o bin/percona-everest-backend-debug ./cmd
go build -tags debug -v $(LD_FLAGS) -race -o bin/percona-everest-backend-debug ./cmd

gen: ## Generate code
go generate ./...
Expand Down
16 changes: 0 additions & 16 deletions api-tests/tests/database-cluster.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { expect, test } from '@fixtures'
const testPrefix = `${(Math.random() + 1).toString(36).substring(10)}`

let kubernetesId
let recommendedVersion
const monitoringConfigName1 = `a${testPrefix}-1`
const monitoringConfigName2 = `b${testPrefix}-2`

Expand All @@ -30,17 +29,6 @@ test.beforeAll(async ({ request }) => {

kubernetesId = (await kubernetesList.json())[0].id

const engineResponse = await request.get(`/v1/kubernetes/${kubernetesId}/database-engines/percona-server-mongodb-operator`)
const availableVersions = (await engineResponse.json()).status.availableVersions.engine

for (const k in availableVersions) {
if (availableVersions[k].status === 'recommended' && k.startsWith('6')) {
recommendedVersion = k
}
}

expect(recommendedVersion).not.toBe('')

const miData = {
type: 'pmm',
name: monitoringConfigName1,
Expand Down Expand Up @@ -84,7 +72,6 @@ test('create db cluster with monitoring config', async ({ request }) => {
engine: {
type: 'psmdb',
replicas: 1,
version: recommendedVersion,
storage: {
size: '4G',
},
Expand Down Expand Up @@ -139,7 +126,6 @@ test('update db cluster with a new monitoring config', async ({ request }) => {
engine: {
type: 'psmdb',
replicas: 1,
version: recommendedVersion,
storage: {
size: '4G',
},
Expand Down Expand Up @@ -205,7 +191,6 @@ test('update db cluster without monitoring config with a new monitoring config',
engine: {
type: 'psmdb',
replicas: 1,
version: recommendedVersion,
storage: {
size: '4G',
},
Expand Down Expand Up @@ -274,7 +259,6 @@ test('update db cluster monitoring config with an empty monitoring config', asyn
engine: {
type: 'psmdb',
replicas: 1,
version: recommendedVersion,
storage: {
size: '4G',
},
Expand Down
4 changes: 2 additions & 2 deletions api-tests/tests/database-engines.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ test('get/edit database engine versions', async ({ request }) => {
const availableVersions = engineData.status.availableVersions

expect(availableVersions.engine['6.0.5-4'].imageHash).toBe('b6f875974c59d8ea0174675c85f41668460233784cbf2cbe7ce5eca212ac5f6a')
expect(availableVersions.backup['2.0.5'].status).toBe('recommended')
expect(availableVersions.backup['2.3.0'].status).toBe('recommended')

const allowedVersions = ['6.0.5-4', '6.0.4-3', '5.0.7-6']
const allowedVersions = ['6.0.5-4', '6.0.4-3', '5.0.7-6', '6.0.9-7']

delete engineData.status
engineData.spec.allowedVersions = allowedVersions
Expand Down
46 changes: 20 additions & 26 deletions api-tests/tests/psmdb-clusters.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// percona-everest-backend

Check failure on line 1 in api-tests/tests/psmdb-clusters.spec.ts

View workflow job for this annotation

GitHub Actions / API Integration Tests

[api] › psmdb-clusters.spec.ts:191:5 › expose psmdb cluster on EKS to the public internet and scale up

2) [api] › psmdb-clusters.spec.ts:191:5 › expose psmdb cluster on EKS to the public internet and scale up Test timeout of 30000ms exceeded.
// Copyright (C) 2023 Percona LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,7 +15,6 @@
import { test, expect } from '@fixtures'

let kubernetesId
let recommendedVersion

test.beforeAll(async ({ request }) => {
const kubernetesList = await request.get('/v1/kubernetes')
Expand All @@ -25,13 +24,6 @@
const engineResponse = await request.get(`/v1/kubernetes/${kubernetesId}/database-engines/percona-server-mongodb-operator`)
const availableVersions = (await engineResponse.json()).status.availableVersions.engine

for (const k in availableVersions) {
if (availableVersions[k].status === 'recommended' && k.startsWith('6')) {
recommendedVersion = k
}
}

expect(recommendedVersion).not.toBe('')
})

test('create/edit/delete single node psmdb cluster', async ({ request, page }) => {
Expand All @@ -46,7 +38,6 @@
engine: {
type: 'psmdb',
replicas: 1,
version: recommendedVersion,
storage: {
size: '25G',
},
Expand Down Expand Up @@ -84,18 +75,17 @@
expect(result.metadata.name).toBe(clusterName)
expect(result.spec).toMatchObject(psmdbPayload.spec)
expect(result.status.size).toBe(1)

// psmdbPayload should be overriden because kubernetes adds data into metadata field
// and uses metadata.generation during updation. It returns 422 HTTP status code if this field is not present
//
// kubectl under the hood merges everything hence the UX is seemless
psmdbPayload.spec = result.spec
psmdbPayload.metadata = result.metadata
break
}

psmdbPayload.spec.engine.config = 'operationProfiling:\nmode: slowOp'

let psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)
expect(psmdbCluster.ok()).toBeTruthy()
const result = (await psmdbCluster.json())
psmdbPayload.spec = result.spec
psmdbPayload.metadata = result.metadata

// Update PSMDB cluster

const updatedPSMDBCluster = await request.put(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`, {
Expand All @@ -104,7 +94,7 @@

expect(updatedPSMDBCluster.ok()).toBeTruthy()

let psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)
psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)

expect(psmdbCluster.ok()).toBeTruthy()

Expand All @@ -128,7 +118,6 @@
engine: {
type: 'psmdb',
replicas: 3,
version: recommendedVersion,
storage: {
size: '25G',
},
Expand Down Expand Up @@ -168,11 +157,14 @@
expect(result.spec).toMatchObject(psmdbPayload.spec)
expect(result.status.size).toBe(3)

psmdbPayload.spec = result.spec
psmdbPayload.metadata = result.metadata
break
}

let psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)
expect(psmdbCluster.ok()).toBeTruthy()
const result = (await psmdbCluster.json())
psmdbPayload.spec = result.spec
psmdbPayload.metadata = result.metadata
psmdbPayload.spec.proxy.expose.type = 'external'

// Update PSMDB cluster
Expand All @@ -182,8 +174,9 @@
})

expect(updatedPSMDBCluster.ok()).toBeTruthy()
await page.waitForTimeout(1000)

let psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)
psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)

expect(psmdbCluster.ok()).toBeTruthy()

Expand All @@ -207,7 +200,6 @@
engine: {
type: 'psmdb',
replicas: 3,
version: recommendedVersion,
storage: {
size: '25G',
},
Expand Down Expand Up @@ -245,13 +237,15 @@
expect(result.metadata.name).toBe(clusterName)
expect(result.spec).toMatchObject(psmdbPayload.spec)
expect(result.status.size).toBe(3)

psmdbPayload.spec = result.spec
psmdbPayload.metadata = result.metadata
break
}

psmdbPayload.spec.engine.replicas = 5
let psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)
expect(psmdbCluster.ok()).toBeTruthy()
const result = (await psmdbCluster.json())
psmdbPayload.spec = result.spec
psmdbPayload.metadata = result.metadata

// Update PSMDB cluster

Expand All @@ -261,7 +255,7 @@

expect(updatedPSMDBCluster.ok()).toBeTruthy()

let psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)
psmdbCluster = await request.get(`/v1/kubernetes/${kubernetesId}/database-clusters/${clusterName}`)

expect(psmdbCluster.ok()).toBeTruthy()

Expand Down
29 changes: 29 additions & 0 deletions api-tests/tests/version.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

// percona-everest-backend
// Copyright (C) 2023 Percona LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { expect, test } from '@fixtures'

test('version endpoint', async ({ request, cli }) => {
const version = await request.get(`/v1/version`)
expect(version.ok()).toBeTruthy()

const versionJSON = await version.json()

const gitVersion = await cli.exec('git describe --always --tags | cut -b2-')
await gitVersion.assertSuccess()

expect(versionJSON.projectName).toEqual("Everest Backend")
expect(versionJSON.version).toEqual(gitVersion.getStdOutLines()[0])
})
Loading
Loading