Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add airbyte rock #12

Merged
merged 12 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
3 changes: 2 additions & 1 deletion .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
with:
channel: 1.28-strict/stable
modules: '["test_charm.py"]'
juju-channel: 3.1/stable
juju-channel: 3.4/stable
self-hosted-runner: true
self-hosted-runner-label: "xlarge"
microk8s-addons: "dns ingress rbac storage metallb:10.15.119.2-10.15.119.4 registry"
trivy-severity-config: CRITICAL
4 changes: 4 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# stdlib CVEs
CVE-2024-24790

Check notice on line 2 in .trivyignore

View workflow job for this annotation

GitHub Actions / integration-tests / Scan Image (ghcr.io-canonical-airbyte-ui-094dba97ae91cc558dad264dbbff1b426090ad32-_1.0_amd64.tar)

CVE-2024-24790 not present anymore, can be safely removed.
CVE-2023-24538

Check notice on line 3 in .trivyignore

View workflow job for this annotation

GitHub Actions / integration-tests / Scan Image (ghcr.io-canonical-airbyte-ui-094dba97ae91cc558dad264dbbff1b426090ad32-_1.0_amd64.tar)

CVE-2023-24538 not present anymore, can be safely removed.
CVE-2023-24540

Check notice on line 4 in .trivyignore

View workflow job for this annotation

GitHub Actions / integration-tests / Scan Image (ghcr.io-canonical-airbyte-ui-094dba97ae91cc558dad264dbbff1b426090ad32-_1.0_amd64.tar)

CVE-2023-24540 not present anymore, can be safely removed.
4 changes: 4 additions & 0 deletions airbyte_ui_rock/.trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore vulnerabilities on stdlib
CVE-2024-24790
CVE-2023-24538
CVE-2023-24540
15 changes: 15 additions & 0 deletions airbyte_ui_rock/patches/vite-config-http.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

diff --git a/airbyte-webapp/vite.config.mts b/airbyte-webapp/vite.config.mts
index 4cf29fa0de..6359ab2a55 100644
--- a/airbyte-webapp/vite.config.mts
+++ b/airbyte-webapp/vite.config.mts
@@ -118,6 +118,7 @@ export default defineConfig(() => {
},
},
server: {
+ https: false,
host: true,
port: Number(process.env.PORT) || 3000,
strictPort: true,
75 changes: 75 additions & 0 deletions airbyte_ui_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

name: airbyte-ui
summary: Airbyte UI rock
description: Airbyte UI OCI image for the Airbyte UI charm
version: "1.0"
base: ubuntu@22.04
build-base: ubuntu@22.04
kelkawi-a marked this conversation as resolved.
Show resolved Hide resolved
license: Apache-2.0
platforms:
amd64:

services:
airbyte-webapp:
override: replace
summary: "airbyte-webapp service"
startup: disabled
command: "/usr/bin/pnpm -C airbyte-webapp start"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: any reason this needs to be executed by the root user? And not set up permissions as outlined here: https://discourse.ubuntu.com/t/unifying-user-identity-across-snaps-and-rocks/36469

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of a specific reason. Once I set permissions, would I run it as /bin/pnpm?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd run it the same way, it would just be run by the daemon user as opposed to root.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per MM conversation, this seems to have introduced a permission issue with the staged binaries. Will defer for now.

environment:
PORT: "8080"

parts:
patches:
kelkawi-a marked this conversation as resolved.
Show resolved Hide resolved
plugin: dump
source: ./patches
organize:
vite-config-http.patch: patches/vite-config-http.patch
stage:
- patches/vite-config-http.patch
prime:
- "-*"

airbyte-webapp:
after: [patches]
plugin: dump
source: https://github.com/airbytehq/airbyte-platform.git # yamllint disable-line
source-type: git
source-tag: v0.63.8
build-packages:
- jq
- curl
- nodejs
- npm
- coreutils
- bash
override-build: |
git apply ${CRAFT_STAGE}/patches/*.patch

curl https://raw.githubusercontent.com/creationix/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
cd airbyte-webapp
nvm install
kelkawi-a marked this conversation as resolved.
Show resolved Hide resolved
npm install -g pnpm@8.6.12 --force

pnpm install
pnpm run build

mkdir -p ${CRAFT_PART_INSTALL}/bin ${CRAFT_PART_INSTALL}/lib

# Copy build directory files to app
cp -r . ${CRAFT_PART_INSTALL}/airbyte-webapp
cp -r ../airbyte-connector-builder-resources/ ${CRAFT_PART_INSTALL}/airbyte-connector-builder-resources
cp -r /root/.nvm/versions/node/v20.11.0/bin/node ${CRAFT_PART_INSTALL}/node
cp -r /root/.nvm/versions/node/v20.11.0/bin/pnpm ${CRAFT_PART_INSTALL}/pnpm
cp -r /root/.nvm/versions/node/v20.11.0/lib ${CRAFT_PART_INSTALL}/
organize:
node: bin/node
pnpm: bin/pnpm
stage:
- airbyte-webapp
- airbyte-connector-builder-resources
- bin/node
- bin/pnpm
- lib
1 change: 0 additions & 1 deletion charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ resources:
airbyte-webapp:
type: oci-image
description: OCI image for Airbyte web UI
upstream-source: airbyte/webapp:0.60.0
3 changes: 2 additions & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def _update(self, event):
"CONNECTOR_BUILDER_API_HOST": f"{server_svc}:{CONNECTOR_BUILDER_API_PORT}",
"CONNECTOR_BUILDER_API_URL": "/connector-builder-api",
"KEYCLOAK_INTERNAL_HOST": "localhost",
"PORT": WEB_UI_PORT,
}

self.model.unit.set_ports(WEB_UI_PORT)
Expand All @@ -207,7 +208,7 @@ def _update(self, event):
"services": {
self.name: {
"summary": self.name,
"command": "./docker-entrypoint.sh nginx",
"command": "/usr/bin/pnpm -C airbyte-webapp start",
"startup": "enabled",
"override": "replace",
# Including config values here so that a change in the
Expand Down
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ def pytest_addoption(parser: pytest.Parser):
"""
# The prebuilt charm file.
parser.addoption("--charm-file", action="append", default=[])
# The charm image name:tag.
parser.addoption("--airbyte-ui-image", action="store", default="")
28 changes: 24 additions & 4 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,48 @@

import asyncio
import logging
from pathlib import Path

import pytest
import pytest_asyncio
from helpers import (
APP_NAME_AIRBYTE_SERVER,
APP_NAME_AIRBYTE_UI,
APP_NAME_TEMPORAL_ADMIN,
APP_NAME_TEMPORAL_SERVER,
METADATA,
create_default_namespace,
perform_airbyte_integrations,
perform_temporal_integrations,
)
from pytest import FixtureRequest
from pytest_operator.plugin import OpsTest

logger = logging.getLogger(__name__)


@pytest.fixture(scope="module", name="charm_image")
def charm_image_fixture(request: FixtureRequest) -> str:
"""The OCI image for charm."""
charm_image = request.config.getoption("--airbyte-ui-image")
assert charm_image, "--airbyte-ui-image argument is required which should contain the name of the OCI image."
return charm_image


@pytest_asyncio.fixture(scope="module", name="charm")
async def charm_fixture(request: FixtureRequest, ops_test: OpsTest) -> str | Path:
"""The path to charm."""
charms = request.config.getoption("--charm-file")
if not charms:
charm = await ops_test.build_charm(".")
assert charm, "Charm not built"
return charm
return charms[0]


@pytest_asyncio.fixture(name="deploy", scope="module")
async def deploy(ops_test: OpsTest):
async def deploy(ops_test: OpsTest, charm: str, charm_image: str):
"""Test the app is up and running."""
charm = await ops_test.build_charm(".")
resources = {"airbyte-webapp": METADATA["resources"]["airbyte-webapp"]["upstream-source"]}
resources = {"airbyte-webapp": charm_image}

asyncio.gather(
ops_test.model.deploy(charm, resources=resources, application_name=APP_NAME_AIRBYTE_UI),
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ async def perform_airbyte_integrations(ops_test: OpsTest):
apps=[APP_NAME_AIRBYTE_SERVER, APP_NAME_AIRBYTE_UI, "nginx-ingress-integrator"],
status="active",
raise_on_blocked=False,
timeout=600,
timeout=240,
)

assert ops_test.model.applications[APP_NAME_AIRBYTE_SERVER].units[0].workload_status == "active"
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_ready(self):
"services": {
APP_NAME: {
"summary": APP_NAME,
"command": "./docker-entrypoint.sh nginx",
"command": "/usr/bin/pnpm -C airbyte-webapp start",
"startup": "enabled",
"override": "replace",
"environment": {
Expand All @@ -141,6 +141,7 @@ def test_ready(self):
"INTERNAL_API_HOST": f"airbyte-k8s:{INTERNAL_API_PORT}",
"CONNECTOR_BUILDER_API_HOST": f"airbyte-k8s:{CONNECTOR_BUILDER_API_PORT}",
"KEYCLOAK_INTERNAL_HOST": "localhost",
"PORT": 8080,
},
"on-check-failure": {"up": "ignore"},
}
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ commands =
description = Run integration tests
deps =
ipdb==0.13.9
juju==3.2.0.1
juju==3.5.2.0
pytest==7.1.3
pytest-operator==0.35.0
temporalio==1.1.0
Expand Down
Loading