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

Updated kfam & profile-controller version #126

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions kfam/rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
name: kfam
summary: Kubeflow Access Management API
description: Kubeflow Access Management API provides fine-grain user-namespace level access control.
version: "v1.7.0_1"
version: "v1.8.0"
license: Apache-2.0
base: ubuntu:22.04
base: ubuntu@22.04

platforms:
amd64:
Expand All @@ -27,7 +27,7 @@ parts:
source: https://github.com/kubeflow/kubeflow.git
source-subdir: components/access-management
source-type: git
source-tag: v1.7.0
source-tag: v1.8.0
build-environment:
- CGO_ENABLED: 0
- GOOS: linux
Expand Down
69 changes: 69 additions & 0 deletions kfam/tests/test_rock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
#
#

from pathlib import Path

import os
import logging
import random
import pytest
import string
import subprocess
import yaml

from charmed_kubeflow_chisme.rock import CheckRock


@pytest.fixture()
def rock_test_env(tmpdir):
"""Yields a temporary directory and random docker container name, then cleans them up after."""
container_name = "".join(
[str(i) for i in random.choices(string.ascii_lowercase, k=8)]
)
yield tmpdir, container_name

try:
subprocess.run(["docker", "rm", container_name])
except Exception:
pass
# tmpdir fixture we use here should clean up the other files for us


@pytest.mark.abort_on_fail
def test_rock(rock_test_env):
"""Test rock."""
temp_dir, container_name = rock_test_env
check_rock = CheckRock("rockcraft.yaml")
rock_image = check_rock.get_name()
rock_version = check_rock.get_version()
LOCAL_ROCK_IMAGE = f"{rock_image}:{rock_version}"

subprocess.run(
[
"docker",
"run",
"--rm",
LOCAL_ROCK_IMAGE,
"exec",
"ls",
"-la",
"/access-management",
],
check=True,
)

subprocess.run(
[
"docker",
"run",
"--rm",
LOCAL_ROCK_IMAGE,
"exec",
"ls",
"-la",
"/third_party/library/hashicorp",
],
check=True,
)
51 changes: 51 additions & 0 deletions kfam/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
[tox]
skipsdist = True
skip_missing_interpreters = True
envlist = pack, export-to-docker, sanity, integration

[testenv]
setenv =
PYTHONPATH={toxinidir}
PYTHONBREAKPOINT=ipdb.set_trace

[testenv:pack]
passenv = *
allowlist_externals =
rockcraft
commands =
rockcraft pack

[testenv:export-to-docker]
passenv = *
allowlist_externals =
bash
skopeo
yq
commands =
# export rock to docker
bash -c 'NAME=$(yq eval .name rockcraft.yaml) && \
VERSION=$(yq eval .version rockcraft.yaml) && \
ARCH=$(yq eval ".platforms | keys | .[0]" rockcraft.yaml) && \
ROCK="$\{NAME\}_$\{VERSION\}_$\{ARCH\}.rock" && \
DOCKER_IMAGE=$NAME:$VERSION && \
echo "Exporting $ROCK to docker as $DOCKER_IMAGE" && \
skopeo --insecure-policy copy oci-archive:$ROCK docker-daemon:$DOCKER_IMAGE'

[testenv:sanity]
passenv = *
deps =
pytest
charmed-kubeflow-chisme
commands =
# run rock tests
pytest -s -v --tb native --show-capture=all --log-cli-level=INFO {posargs} {toxinidir}/tests

[testenv:integration]
passenv = *
allowlist_externals =
echo
commands =
# TODO: Implement integration tests here
echo "WARNING: This is a placeholder test - no test is implemented here."
16 changes: 7 additions & 9 deletions profile-controller/rockcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Constructed from https://github.com/kubeflow/kubeflow/blob/v1.7-branch/components/profile-controller/Dockerfile
# Constructed from https://github.com/kubeflow/kubeflow/blob/v1.8.0/components/profile-controller/Dockerfile

name: profile-controller
summary: Controller for Kubeflow Profile objects
description: Controller for Kubeflow Profile objects
version: v1.7.0_22.04_1 # version format: <KF-upstream-version>_<Charmed-KF-version>
version: "v1.8.0"

# TODO: use base: bare
base: ubuntu:22.04
build-base: ubuntu:22.04
base: ubuntu@22.04
build-base: ubuntu@22.04

license: Apache-2.0

Expand All @@ -27,10 +27,8 @@ parts:
plugin: go
source-type: git
source: https://github.com/kubeflow/kubeflow.git
source-tag: v1.7-branch
# TODO: Refactor to use source-subdir once
# [this fix](https://github.com/canonical/craft-parts/pull/442) lands
# source-subdir: components/profile-controller
source-tag: v1.8.0
source-subdir: components/profile-controller
build-environment:
- CGO_ENABLED: 0
- GOOS: linux
Expand All @@ -40,7 +38,7 @@ parts:
# Build the go code and output to $CRAFT_PART_INSTALL
# Copy the hashcorp libs used during build for later staging
override-build: |
cd components/profile-controller
cd $CRAFT_PART_SRC_WORK
go mod download
go build -a -o $CRAFT_PART_INSTALL/manager main.go

Expand Down
69 changes: 69 additions & 0 deletions profile-controller/tests/test_rock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
#
#

from pathlib import Path

import os
import logging
import random
import pytest
import string
import subprocess
import yaml

from charmed_kubeflow_chisme.rock import CheckRock


@pytest.fixture()
def rock_test_env(tmpdir):
"""Yields a temporary directory and random docker container name, then cleans them up after."""
container_name = "".join(
[str(i) for i in random.choices(string.ascii_lowercase, k=8)]
)
yield tmpdir, container_name

try:
subprocess.run(["docker", "rm", container_name])
except Exception:
pass
# tmpdir fixture we use here should clean up the other files for us


@pytest.mark.abort_on_fail
def test_rock(rock_test_env):
"""Test rock."""
temp_dir, container_name = rock_test_env
check_rock = CheckRock("rockcraft.yaml")
rock_image = check_rock.get_name()
rock_version = check_rock.get_version()
LOCAL_ROCK_IMAGE = f"{rock_image}:{rock_version}"

subprocess.run(
[
"docker",
"run",
"--rm",
LOCAL_ROCK_IMAGE,
"exec",
"ls",
"-la",
"/manager",
],
check=True,
)

subprocess.run(
[
"docker",
"run",
"--rm",
LOCAL_ROCK_IMAGE,
"exec",
"ls",
"-la",
"/third_party/library/hashicorp",
],
check=True,
)
51 changes: 51 additions & 0 deletions profile-controller/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
[tox]
skipsdist = True
skip_missing_interpreters = True
envlist = pack, export-to-docker, sanity, integration

[testenv]
setenv =
PYTHONPATH={toxinidir}
PYTHONBREAKPOINT=ipdb.set_trace

[testenv:pack]
passenv = *
allowlist_externals =
rockcraft
commands =
rockcraft pack

[testenv:export-to-docker]
passenv = *
allowlist_externals =
bash
skopeo
yq
commands =
# export rock to docker
bash -c 'NAME=$(yq eval .name rockcraft.yaml) && \
VERSION=$(yq eval .version rockcraft.yaml) && \
ARCH=$(yq eval ".platforms | keys | .[0]" rockcraft.yaml) && \
ROCK="$\{NAME\}_$\{VERSION\}_$\{ARCH\}.rock" && \
DOCKER_IMAGE=$NAME:$VERSION && \
echo "Exporting $ROCK to docker as $DOCKER_IMAGE" && \
skopeo --insecure-policy copy oci-archive:$ROCK docker-daemon:$DOCKER_IMAGE'

[testenv:sanity]
passenv = *
deps =
pytest
charmed-kubeflow-chisme
commands =
# run rock tests
pytest -s -v --tb native --show-capture=all --log-cli-level=INFO {posargs} {toxinidir}/tests

[testenv:integration]
passenv = *
allowlist_externals =
echo
commands =
# TODO: Implement integration tests here
echo "WARNING: This is a placeholder test - no test is implemented here."
Loading