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 #18

Merged
merged 32 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
add6093
add airbyte rock
kelkawi-a Oct 7, 2024
14b061d
test updated operator workflow with security nesting
kelkawi-a Oct 9, 2024
db47c38
attempt to fix rock build hanging
kelkawi-a Oct 9, 2024
bd0b0ea
test updated operator workflow with security nesting
kelkawi-a Oct 9, 2024
c672e4f
split parts into assemble and organize
kelkawi-a Oct 9, 2024
e068ecc
split assemble and tar parts
kelkawi-a Oct 9, 2024
6977576
split assemble part
kelkawi-a Oct 10, 2024
a85b6cf
test github runner
kelkawi-a Oct 10, 2024
c922b45
update charm code
kelkawi-a Oct 10, 2024
0e42e56
modify pebble command
kelkawi-a Oct 10, 2024
aedadae
enable self-hosted runners
kelkawi-a Oct 10, 2024
a33f43f
remove services from rock file
kelkawi-a Oct 10, 2024
8e2c4a8
install airbyte cdk library
kelkawi-a Oct 10, 2024
96d9187
add kubectl part
kelkawi-a Oct 10, 2024
70bc4e8
install kubectl with apt
kelkawi-a Oct 10, 2024
ccab187
install kubectl with snap
kelkawi-a Oct 10, 2024
ecbe839
stage snap bin in kubectl
kelkawi-a Oct 11, 2024
a6ebfe1
install kubectl using apt
kelkawi-a Oct 11, 2024
6755bb2
attempt to fix kubectl staging
kelkawi-a Oct 11, 2024
7f871d6
update airbyte version to address compatibility issues
kelkawi-a Oct 11, 2024
330b030
update airbyte to v0.64.7
kelkawi-a Oct 11, 2024
9d97a8d
update airbyte to v1.1.0
kelkawi-a Oct 11, 2024
1632f92
test airbyte v0.63.8
kelkawi-a Oct 11, 2024
88d5886
add logs to integration tests
kelkawi-a Oct 11, 2024
53a7a32
set orchestrator launcher to false
kelkawi-a Oct 11, 2024
a6469ad
update orchestrator container version
kelkawi-a Oct 11, 2024
6fb03bf
update api urls in itests
kelkawi-a Oct 11, 2024
87e1012
update api port in itest
kelkawi-a Oct 11, 2024
aadd131
refactor rock part and remove redundant artifacts
kelkawi-a Oct 11, 2024
6fe7361
address review comments
kelkawi-a Oct 14, 2024
ad21197
revert change of pull-repo step
kelkawi-a Oct 14, 2024
f686cd9
remove redundant pod sweeper script
kelkawi-a Oct 15, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/integration_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ jobs:
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
rockcraft-enable-security-nesting: true
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ header:
- 'LICENSE'
- 'trivy.yaml'
- 'lib/**'
- '**/*.patch'
comment: on-failure
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-77c5727f12de3a9b75be103960390ffa362f2d83-_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-77c5727f12de3a9b75be103960390ffa362f2d83-_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-77c5727f12de3a9b75be103960390ffa362f2d83-_1.0_amd64.tar)

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

Choose a reason for hiding this comment

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

If they are not present anymore, we can remove it

File renamed without changes.
110 changes: 110 additions & 0 deletions airbyte_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.

name: airbyte
summary: Airbyte rock
description: Airbyte OCI image for the Airbyte charm
version: "1.0"
base: [email protected]
license: Apache-2.0
platforms:
amd64:

environment:
JAVA_HOME: /usr/lib/jvm/java-21-openjdk-amd64
CDK_PYTHON: /usr/bin/python3.10
CDK_ENTRYPOINT: /usr/lib/python3.10/dist-packages/airbyte_cdk/connector_builder/main.py
CDK_VERSION: "5.12.0"


parts:
install-dependencies:
plugin: nil
stage-packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- python3.10-venv
override-build: |
# Install kubectl
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.31/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list
chmod 644 /etc/apt/sources.list.d/kubernetes.list # helps tools such as command-not-found to work correctly
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.31/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg # allow unprivileged APT programs to read this keyring
apt-get update
apt-get install -y kubectl

Choose a reason for hiding this comment

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

Can this not be a build-package?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It actually needs to be included in the final build as the application itself uses kubectl. Including it as a stage-snap did not work for some reason, so I opted to install it manually.

mkdir -p ${CRAFT_PART_INSTALL}/usr/local/bin
mkdir -p ${CRAFT_PART_INSTALL}/usr/local/lib/python3.10/dist-packages
cp -r $(which kubectl) ${CRAFT_PART_INSTALL}/usr/local/bin/kubectl

pip install --upgrade setuptools pip airbyte-cdk==5.12.0 \

Choose a reason for hiding this comment

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

If you end up having more of these in future you can add a requirements.txt file. Not necessary now.

--target=/${CRAFT_PART_INSTALL}/usr/local/lib/python3.10/dist-packages
stage:
- usr/local/bin/kubectl
- usr/local/lib/python3.10/dist-packages

pull-airbyte-repo:
after: [install-dependencies]
plugin: dump
source: https://github.com/airbytehq/airbyte-platform.git # yamllint disable-line
source-type: git
source-tag: v0.63.8
override-build: |
cp -r . ${CRAFT_PART_INSTALL}/airbyte-platform
kelkawi-a marked this conversation as resolved.
Show resolved Hide resolved
stage:
- airbyte-platform

assemble:
after: [pull-airbyte-repo]
plugin: nil
build-packages:
- jq
- curl
- coreutils
- bash
- gradle
- openjdk-21-jdk-headless
- npm
build-snaps:
- docker
kelkawi-a marked this conversation as resolved.
Show resolved Hide resolved
stage-packages:
- openjdk-21-jdk-headless
override-build: |
cd ${CRAFT_STAGE}/airbyte-platform
./gradlew assemble -x dockerBuildImage --continue --max-workers 1
./gradlew --stop

organize-tars:
after: [assemble]
plugin: nil
override-build: |
mkdir ${CRAFT_PART_INSTALL}/airbyte-server
mkdir ${CRAFT_PART_INSTALL}/airbyte-api-server
mkdir ${CRAFT_PART_INSTALL}/airbyte-workers
mkdir ${CRAFT_PART_INSTALL}/airbyte-bootloader
mkdir ${CRAFT_PART_INSTALL}/airbyte-cron
mkdir ${CRAFT_PART_INSTALL}/airbyte-connector-builder-server

tar -xvf ${CRAFT_STAGE}/airbyte-platform/airbyte-server/build/distributions/airbyte-app.tar -C ${CRAFT_PART_INSTALL}/airbyte-server
tar -xvf ${CRAFT_STAGE}/airbyte-platform/airbyte-api-server/build/distributions/airbyte-app.tar -C ${CRAFT_PART_INSTALL}/airbyte-api-server
tar -xvf ${CRAFT_STAGE}/airbyte-platform/airbyte-workers/build/distributions/airbyte-app.tar -C ${CRAFT_PART_INSTALL}/airbyte-workers
tar -xvf ${CRAFT_STAGE}/airbyte-platform/airbyte-bootloader/build/distributions/airbyte-app.tar -C ${CRAFT_PART_INSTALL}/airbyte-bootloader
tar -xvf ${CRAFT_STAGE}/airbyte-platform/airbyte-cron/build/distributions/airbyte-app.tar -C ${CRAFT_PART_INSTALL}/airbyte-cron
tar -xvf ${CRAFT_STAGE}/airbyte-platform/airbyte-connector-builder-server/build/distributions/airbyte-app.tar -C ${CRAFT_PART_INSTALL}/airbyte-connector-builder-server
stage:
- airbyte-server
- airbyte-api-server
- airbyte-workers
- airbyte-bootloader
- airbyte-cron
- airbyte-connector-builder-server

local-files:
after: [organize-tars]

Choose a reason for hiding this comment

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

Does this really need to go after organize-tars?

plugin: dump
source: ./local-files
organize:
pod-sweeper.sh: airbyte-pod-sweeper/airbyte-app/bin/airbyte-pod-sweeper
stage:
- airbyte-pod-sweeper/airbyte-app/bin/airbyte-pod-sweeper
44 changes: 10 additions & 34 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,47 +429,23 @@ config:
# Your workload’s containers.
containers:
airbyte-api-server:
resource: airbyte-api-server
resource: airbyte-image
airbyte-bootloader:
resource: airbyte-bootloader
resource: airbyte-image
airbyte-connector-builder-server:
resource: airbyte-connector-builder-server
resource: airbyte-image
airbyte-cron:
resource: airbyte-cron
resource: airbyte-image
airbyte-pod-sweeper:
resource: airbyte-pod-sweeper
resource: airbyte-image
airbyte-server:
resource: airbyte-server
resource: airbyte-image
airbyte-workers:
resource: airbyte-workers
resource: airbyte-image

# This field populates the Resources tab on Charmhub.
resources:
airbyte-api-server:
type: oci-image
description: OCI image for Airbyte API server
upstream-source: airbyte/airbyte-api-server:0.60.0
airbyte-bootloader:
type: oci-image
description: OCI image for Airbyte Bootloader
upstream-source: airbyte/bootloader:0.60.0
airbyte-connector-builder-server:
type: oci-image
description: OCI image for Airbyte Connector Builder Server
upstream-source: airbyte/connector-builder-server:0.60.0
airbyte-cron:
airbyte-image:
type: oci-image
description: OCI image for Airbyte Cron
upstream-source: airbyte/cron:0.60.0
airbyte-pod-sweeper:
type: oci-image
description: OCI image for Airbyte Pod Sweeper
upstream-source: bitnami/kubectl:1.29.4
airbyte-server:
type: oci-image
description: OCI image for Airbyte Server
upstream-source: airbyte/server:0.60.0
airbyte-workers:
type: oci-image
description: OCI image for Airbyte Worker
upstream-source: airbyte/worker:0.60.0
description: OCI image for Airbyte

15 changes: 1 addition & 14 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""Charm the application."""

import logging
from pathlib import Path

import ops
from botocore.exceptions import ClientError
Expand Down Expand Up @@ -53,7 +52,7 @@ def get_pebble_layer(application_name, context):
"services": {
application_name: {
"summary": application_name,
"command": f"/bin/bash -c airbyte-app/bin/{application_name}",
"command": f"/bin/bash {application_name}/airbyte-app/bin/{application_name}",
"startup": "enabled",
"override": "replace",
# Including config values here so that a change in the
Expand Down Expand Up @@ -293,18 +292,6 @@ def _update(self, event):
event.defer()
return

if container_name == "airbyte-pod-sweeper":
script_path = Path(__file__).parent / "scripts/pod-sweeper.sh"

with open(script_path, "r") as file_source:
logger.info("pushing pod-sweeper script...")
container.push(
f"/airbyte-app/bin/{container_name}",
file_source,
make_dirs=True,
permissions=0o755,
)

env = create_env(self.model.name, self.app.name, container_name, self.config, self._state)
env = {k: v for k, v in env.items() if v is not None}
pebble_layer = get_pebble_layer(container_name, env)
Expand Down
3 changes: 1 addition & 2 deletions src/charm_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,12 @@ def create_env(model_name, app_name, container_name, config, state):
"RUNNING_TTL_MINUTES": config["pod-running-ttl-minutes"],
"SUCCEEDED_TTL_MINUTES": config["pod-successful-ttl-minutes"],
"UNSUCCESSFUL_TTL_MINUTES": config["pod-unsuccessful-ttl-minutes"],
"INTERNAL_API_HOST": f"{app_name}:{INTERNAL_API_PORT}",
"INTERNAL_API_HOST": f"http://{app_name}:{INTERNAL_API_PORT}",
"AIRBYTE_SERVER_HOST": f"{app_name}:{INTERNAL_API_PORT}",
"CONFIG_API_HOST": f"{app_name}:{INTERNAL_API_PORT}",
"CONNECTOR_BUILDER_SERVER_API_HOST": f"{app_name}:{CONNECTOR_BUILDER_SERVER_API_PORT}",
"CONNECTOR_BUILDER_API_HOST": f"{app_name}:{CONNECTOR_BUILDER_SERVER_API_PORT}",
"AIRBYTE_API_HOST": f"{app_name}:{AIRBYTE_API_PORT}/api/public",
"AIRBYTE_URL": config["webapp-url"],
}

# https://github.com/airbytehq/airbyte/issues/29506#issuecomment-1775148609
Expand Down
7 changes: 4 additions & 3 deletions src/literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
INTERNAL_API_PORT = 8001
AIRBYTE_API_PORT = 8006
WORKLOAD_API_PORT = 8007
AIRBYTE_VERSION = "0.63.8"
DB_NAME = "airbyte-k8s_db"


CONTAINER_HEALTH_CHECK_MAP = {
"airbyte-api-server": {
Expand All @@ -27,9 +30,7 @@
"airbyte-workers": {"port": 9000, "health_endpoint": "/"},
}

DB_NAME = "airbyte-k8s_db"
REQUIRED_S3_PARAMETERS = ["region", "endpoint", "access-key", "secret-key"]
AIRBYTE_VERSION = "0.60.0"
BUCKET_CONFIGS = [
"storage-bucket-logs",
"storage-bucket-state",
Expand Down Expand Up @@ -59,6 +60,6 @@
"CONNECTOR_BUILDER_API_URL": "/connector-builder-api",
"TEMPORAL_WORKER_PORTS": "9001,9002,9003,9004,9005,9006,9007,9008,9009,9010,9011,9012,9013,9014,9015,9016,9017,9018,9019,9020,9021,9022,9023,9024,9025,9026,9027,9028,9029,9030",
"CONTAINER_ORCHESTRATOR_ENABLED": "true",
"CONTAINER_ORCHESTRATOR_IMAGE": "airbyte/container-orchestrator:0.60.0",
"CONTAINER_ORCHESTRATOR_IMAGE": f"airbyte/container-orchestrator:{AIRBYTE_VERSION}",
"LOG4J_CONFIGURATION_FILE": "log4j2-minio.xml",
}
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-image", action="store", default="")
30 changes: 25 additions & 5 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,50 @@
"""Charm integration test config."""

import logging
from pathlib import Path

import pytest
import pytest_asyncio
from helpers import (
APP_NAME_AIRBYTE_SERVER,
APP_NAME_TEMPORAL_ADMIN,
APP_NAME_TEMPORAL_SERVER,
create_default_namespace,
get_airbyte_charm_resources,
perform_airbyte_integrations,
perform_temporal_integrations,
run_sample_workflow,
)
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-image")
assert charm_image, "--airbyte-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:
"""Fetch 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."""
await ops_test.model.set_config({"update-status-hook-interval": "1m"})

charm = await ops_test.build_charm(".")
resources = get_airbyte_charm_resources()
# resources = get_airbyte_charm_resources()
resources = {"airbyte-image": charm_image}

await ops_test.model.deploy(charm, resources=resources, application_name=APP_NAME_AIRBYTE_SERVER, trust=True)
await ops_test.model.deploy(
Expand Down
Loading
Loading