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

Update rock to v1.1.0 #20

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
16 changes: 10 additions & 6 deletions airbyte_rock/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: airbyte
summary: Airbyte rock
description: Airbyte OCI image for the Airbyte charm
version: "1.0"
version: "1.0.0"
base: [email protected]
license: Apache-2.0
platforms:
Expand Down Expand Up @@ -49,7 +49,7 @@ parts:
plugin: dump
source: https://github.com/airbytehq/airbyte-platform.git # yamllint disable-line
source-type: git
source-tag: v0.63.8
source-tag: v1.3.0
override-build: |
cp -r . ${CRAFT_PART_INSTALL}/airbyte-platform
stage:
Expand All @@ -72,33 +72,37 @@ parts:
- openjdk-21-jdk-headless
override-build: |
cd ${CRAFT_STAGE}/airbyte-platform
./gradlew assemble -x dockerBuildImage --continue --max-workers 1
# ./gradlew assemble -x dockerBuildImage --continue --max-workers 1
./gradlew build --continue
./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
mkdir ${CRAFT_PART_INSTALL}/airbyte-workload-api-server
mkdir ${CRAFT_PART_INSTALL}/airbyte-workload-launcher

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
tar -xvf ${CRAFT_STAGE}/airbyte-platform/airbyte-workload-api-server/build/distributions/airbyte-app.tar -C ${CRAFT_PART_INSTALL}/airbyte-workload-api-server
tar -xvf ${CRAFT_STAGE}/airbyte-platform/airbyte-workload-launcher/build/distributions/airbyte-app.tar -C ${CRAFT_PART_INSTALL}/airbyte-workload-launcher
stage:
- airbyte-server
- airbyte-api-server
- airbyte-workers
- airbyte-bootloader
- airbyte-cron
- airbyte-connector-builder-server
- airbyte-workload-api-server
- airbyte-workload-launcher

local-files:
after: [organize-tars]
Expand Down
5 changes: 3 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,9 @@ config:

# Your workload’s containers.
containers:
airbyte-api-server:
airbyte-workload-api-server:
resource: airbyte-image
airbyte-workload-launcher:
resource: airbyte-image
airbyte-bootloader:
resource: airbyte-image
Expand All @@ -448,4 +450,3 @@ resources:
airbyte-image:
type: oci-image
description: OCI image for Airbyte

19 changes: 17 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
INTERNAL_API_PORT,
LOGS_BUCKET_CONFIG,
REQUIRED_S3_PARAMETERS,
WORKLOAD_API_PORT,
WORKLOAD_LAUNCHER_PORT,
)
from log import log_event_handler
from relations.airbyte_ui import AirbyteServerProvider
Expand Down Expand Up @@ -62,6 +64,13 @@ def get_pebble_layer(application_name, context):
},
}

if application_name == "airbyte-bootloader":
pebble_layer["services"][application_name].update(
{
"on-success": "ignore",
}
)

application_info = CONTAINER_HEALTH_CHECK_MAP[application_name]
if application_info is not None:
pebble_layer["services"][application_name].update(
Expand Down Expand Up @@ -172,7 +181,7 @@ def _on_update_status(self, event):
check = container.get_check("up")
if check.status != CheckStatus.UP:
logger.error(f"check failed for {container_name}")
self.unit.status = MaintenanceStatus("Status check: DOWN")
self.unit.status = MaintenanceStatus(f"Status check: {container_name!r} DOWN")
return

if not all_valid_plans:
Expand Down Expand Up @@ -284,7 +293,13 @@ def _update(self, event):
self.unit.status = BlockedStatus(f"failed to create buckets: {str(e)}")
return

self.model.unit.set_ports(AIRBYTE_API_PORT, INTERNAL_API_PORT, CONNECTOR_BUILDER_SERVER_API_PORT)
self.model.unit.set_ports(
AIRBYTE_API_PORT,
INTERNAL_API_PORT,
CONNECTOR_BUILDER_SERVER_API_PORT,
WORKLOAD_API_PORT,
WORKLOAD_LAUNCHER_PORT,
)

for container_name in CONTAINER_HEALTH_CHECK_MAP:
container = self.unit.get_container(container_name)
Expand Down
14 changes: 11 additions & 3 deletions src/charm_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
BASE_ENV,
CONNECTOR_BUILDER_SERVER_API_PORT,
INTERNAL_API_PORT,
WORKLOAD_API_PORT,
)
from structured_config import StorageType

Expand Down Expand Up @@ -39,7 +40,7 @@ def create_env(model_name, app_name, container_name, config, state):
secret_persistence = config["secret-persistence"].value

# Some defaults are extracted from Helm chart:
# https://github.com/airbytehq/airbyte-platform/tree/v0.60.0/charts/airbyte
# https://github.com/airbytehq/airbyte-platform/tree/v1.3.0/charts/airbyte
env = {
**BASE_ENV,
# Airbye services config
Expand Down Expand Up @@ -137,11 +138,18 @@ def create_env(model_name, app_name, container_name, config, state):
"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",
"WORKLOAD_API_HOST": f"{app_name}:{WORKLOAD_API_PORT}",
"WORKLOAD_API_BEARER_TOKEN": ".Values.workload-api.bearerToken",
}

# https://github.com/airbytehq/airbyte/issues/29506#issuecomment-1775148609
if container_name == "airbyte-api-server":
env.update({"INTERNAL_API_HOST": f"http://{app_name}:{INTERNAL_API_PORT}"})
if container_name in ["airbyte-workload-launcher", "airbyte-workers"]:
env.update(
{
"INTERNAL_API_HOST": f"http://{app_name}:{INTERNAL_API_PORT}",
"WORKLOAD_API_HOST": f"http://{app_name}:{WORKLOAD_API_PORT}",
}
)

if config["storage-type"].value == StorageType.minio and state.minio:
minio_endpoint = construct_svc_endpoint(
Expand Down
17 changes: 14 additions & 3 deletions src/literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@
INTERNAL_API_PORT = 8001
AIRBYTE_API_PORT = 8006
WORKLOAD_API_PORT = 8007
AIRBYTE_VERSION = "0.63.8"
WORKLOAD_LAUNCHER_PORT = 8016
AIRBYTE_VERSION = "1.3.0"
DB_NAME = "airbyte-k8s_db"


CONTAINER_HEALTH_CHECK_MAP = {
"airbyte-api-server": {
"port": AIRBYTE_API_PORT,
"airbyte-workload-api-server": {
"port": WORKLOAD_API_PORT,
"health_endpoint": "/health",
},
"airbyte-workload-launcher": {
"port": WORKLOAD_LAUNCHER_PORT,
"health_endpoint": "/health",
},
"airbyte-bootloader": None,
Expand Down Expand Up @@ -62,4 +67,10 @@
"CONTAINER_ORCHESTRATOR_ENABLED": "true",
"CONTAINER_ORCHESTRATOR_IMAGE": f"airbyte/container-orchestrator:{AIRBYTE_VERSION}",
"LOG4J_CONFIGURATION_FILE": "log4j2-minio.xml",
"ENTERPRISE_SOURCE_STUBS_URL": "https://connectors.airbyte.com/files/resources/connector_stubs/v0/connector_stubs.json",
"PUB_SUB_ENABLED": "false",
"PUB_SUB_TOPIC_NAME": "",
"DATA_PLANE_ID": "local",
"LOCAL_ROOT": "/tmp/airbyte_local", # nosec
"RUN_DATABASE_MIGRATION_ON_STARTUP": "true",
}
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def deploy(ops_test: OpsTest, charm: str, charm_image: str):
config={"num-history-shards": 4},
)
await ops_test.model.deploy(APP_NAME_TEMPORAL_ADMIN, channel="edge")
await ops_test.model.deploy("postgresql-k8s", channel="14/stable", trust=True)
await ops_test.model.deploy("postgresql-k8s", channel="14/stable", trust=True, revision=381)
await ops_test.model.deploy("minio", channel="edge")

async with ops_test.fast_forward():
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async def perform_airbyte_integrations(ops_test: OpsTest):
raise_on_blocked=False,
wait_for_active=True,
idle_period=60,
timeout=600,
timeout=300,
)

assert ops_test.model.applications[APP_NAME_AIRBYTE_SERVER].units[0].workload_status == "active"
Expand Down Expand Up @@ -236,7 +236,7 @@ def create_airbyte_connection(api_url, source_id, destination_id):
}

logger.info("creating Airbyte connection")
response = requests.post(url, json=payload, headers=POST_HEADERS, timeout=300)
response = requests.post(url, json=payload, headers=POST_HEADERS, timeout=900)
logger.info(response.json())

assert response.status_code == 200
Expand Down
16 changes: 12 additions & 4 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def test_update_status_down(self):
container.get_check.return_value.status = CheckStatus.DOWN

harness.charm.on.update_status.emit()
self.assertEqual(harness.model.unit.status, MaintenanceStatus("Status check: DOWN"))
self.assertEqual(
harness.model.unit.status, MaintenanceStatus("Status check: 'airbyte-workload-api-server' DOWN")
)

def test_incomplete_pebble_plan(self):
"""The charm re-applies the pebble plan if incomplete."""
Expand Down Expand Up @@ -408,14 +410,20 @@ def create_plan(container_name, storage_type):
"WEBAPP_URL": "http://airbyte-ui-k8s:8080",
"WORKER_LOGS_STORAGE_TYPE": storage_type,
"WORKER_STATE_STORAGE_TYPE": storage_type,
"WORKLOAD_API_HOST": "localhost",
"WORKLOAD_API_HOST": "airbyte-k8s:8007",
"WORKLOAD_API_BEARER_TOKEN": ".Values.workload-api.bearerToken",
},
},
},
}

if container_name == "airbyte-api-server":
want_plan["services"][container_name]["environment"].update({"INTERNAL_API_HOST": "http://airbyte-k8s:8001"})
if container_name == "airbyte-bootloader":
want_plan["services"][container_name].update({"on-success": "ignore"})

if container_name in ["airbyte-workload-launcher", "airbyte-workers"]:
want_plan["services"][container_name]["environment"].update(
{"INTERNAL_API_HOST": "http://airbyte-k8s:8001", "WORKLOAD_API_HOST": "http://airbyte-k8s:8007"}
)

if storage_type == StorageType.minio:
want_plan["services"][container_name]["environment"].update(
Expand Down
Loading