Skip to content

Commit

Permalink
vdk-server: fix ingress settings
Browse files Browse the repository at this point in the history
In 5369fc6 ingress configuraiton was made more configurable but the
defaults were removed and that broke vdk-server

Now installation fails with error like

-Stderr output: Error: INSTALLATION FAILED: release vdk failed, and has
been uninstalled due to atomic being set: Ingress.extensions
"vdk-pipelines-control-service" is invalid: spec: Invalid value:
[]networking.IngressRule(nil): either `defaultBackend` or `rules` must
be specified

Testing Done: tests
  • Loading branch information
antoniivanov committed Feb 12, 2024
1 parent 7c993c9 commit c4f99c9
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 19 deletions.
16 changes: 10 additions & 6 deletions projects/vdk-plugins/vdk-server/.plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
.build-vdk-server:
variables:
PLUGIN_NAME: vdk-server
extends: .build-plugin

build-py37-vdk-server:
extends: .build-vdk-server
image: "python:3.7"
before_script:
- apk add --no-cache bash curl python3 py3-pip
- curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.21.0/kind-linux-amd64
- chmod +x ./kind
- mv ./kind /usr/local/bin/kind
- kind --version
- export DESIRED_VERSION=v3.11.3 # helm version 3.11.3
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- helm version
extends: .build-plugin-dind

build-py311-vdk-server:
extends: .build-vdk-server
image: "python:3.11"

release-vdk-server:
variables:
Expand Down
1 change: 1 addition & 0 deletions projects/vdk-plugins/vdk-server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ kubernetes
pytest
pytest-cov
vdk-core
vdk-test-utils
8 changes: 7 additions & 1 deletion projects/vdk-plugins/vdk-server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
description="Versatile Data Kit SDK plugin that facilitates the installation of a local Control Service.",
long_description=pathlib.Path("README.md").read_text(),
long_description_content_type="text/markdown",
install_requires=["vdk-core", "click-spinner", "docker", "kubernetes"],
install_requires=[
"vdk-core",
"click-spinner",
"docker",
"kubernetes",
"vdk-plugin-control-cli",
],
package_dir={"": "src"},
packages=setuptools.find_namespace_packages(where="src"),
include_package_data=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021-2024 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0

ingress:
hosts:
- name: "localhost"
paths:
- path: /data-jobs
serviceName: "{{ .Release.Name }}-svc"
servicePort: 8092
- path: /
serviceName: "{{ .Release.Name }}-ui"
servicePort: 8091
34 changes: 24 additions & 10 deletions projects/vdk-plugins/vdk-server/src/vdk/plugin/server/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,18 @@ class Installer:
git_server_admin_email = "[email protected]"
git_server_repository_name = "vdk-git-repo"

def __init__(self):
def __init__(self, server_id: str = ""):
self.git_server_image = "gogs/gogs:0.12"
self.__current_directory = self.__get_current_directory()
if server_id:
self.kind_cluster_name = f"{self.kind_cluster_name}-{server_id}"
self.docker_registry_container_name = (
f"{self.docker_registry_container_name}-{server_id}"
)
self.helm_installation_name = f"{self.helm_installation_name}-{server_id}"
self.git_server_container_name = (
f"{self.git_server_container_name}-{server_id}"
)

def install(self):
"""
Expand Down Expand Up @@ -243,7 +253,7 @@ def __create_git_server_container(self):
else:
# docker run --name=vdk-git-server -p 10022:22 -p 10080:3000 -p 10081:80 gogs/gogs:0.12
docker_client.containers.run(
"gogs/gogs:0.12",
self.git_server_image,
detach=True,
name=self.git_server_container_name,
ports={"22/tcp": "10022", "3000/tcp": "10080", "80/tcp": "10081"},
Expand Down Expand Up @@ -612,20 +622,22 @@ def __install_helm_chart(self):
if result.returncode != 0:
stderr_as_str = result.stderr.decode("utf-8")
log.error(f"Stderr output: {stderr_as_str}")
exit(result.returncode)
sys.exit(result.returncode)
result = subprocess.run(["helm", "repo", "update"], capture_output=True)
if result.returncode != 0:
stderr_as_str = result.stderr.decode("utf-8")
log.error(f"Stderr output: {stderr_as_str}")
exit(result.returncode)
sys.exit(result.returncode)
helm_command = self.__helm_install_command(git_server_ip)
log.debug(f"Running helm command: {helm_command}")
result = subprocess.run(
self.__helm_install_command(git_server_ip),
helm_command,
capture_output=True,
)
if result.returncode != 0:
stderr_as_str = result.stderr.decode("utf-8")
log.error(f"Stderr output: {stderr_as_str}")
exit(result.returncode)
sys.exit(result.returncode)
else:
log.info("Control Service installed successfully")
except Exception as ex:
Expand Down Expand Up @@ -680,9 +692,9 @@ def __helm_install_command(self, git_server_ip):
"--set",
"deploymentDockerRegistryType=generic",
"--set",
f"deploymentDockerRepository={self.docker_registry_container_name}:5000",
f"deploymentDockerRepository={self.docker_registry_container_name}:{self.__docker_registry_port}",
"--set",
"proxyRepositoryURL=localhost:5000",
f"proxyRepositoryURL=localhost:{self.__docker_registry_port}",
"--set",
f"deploymentGitUrl={git_server_ip}/{self.git_server_admin_user}/{self.git_server_repository_name}.git",
"--set",
Expand All @@ -705,6 +717,8 @@ def __helm_install_command(self, git_server_ip):
"datajobTemplate.template.spec.successfulJobsHistoryLimit=5",
"--set",
"datajobTemplate.template.spec.failedJobsHistoryLimit=5",
"-f",
self.__current_directory.joinpath("helm-values.yaml"),
]

def __uninstall_helm_chart(self):
Expand Down Expand Up @@ -786,7 +800,7 @@ def __finalize_configuration():
write_default_rest_api_url("http://localhost:8092")
except Exception as ex:
log.error(f"Failed to finalize installation. {str(ex)}")
exit(1)
sys.exit(1)
log.info("Done")

@staticmethod
Expand All @@ -796,7 +810,7 @@ def __cleanup_configuration():
reset_default_rest_api_url()
except Exception as ex:
log.error(f"Failed to clean up. {str(ex)}")
exit(1)
sys.exit(1)
log.info("Done")

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
VDK Server plugin script.
"""
import logging
import sys

Check notice on line 7 in projects/vdk-plugins/vdk-server/src/vdk/plugin/server/server_plugin.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

projects/vdk-plugins/vdk-server/src/vdk/plugin/server/server_plugin.py#L7

'sys' imported but unused (F401)

Check warning on line 7 in projects/vdk-plugins/vdk-server/src/vdk/plugin/server/server_plugin.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

projects/vdk-plugins/vdk-server/src/vdk/plugin/server/server_plugin.py#L7

Unused import sys

import click
from vdk.api.plugin.hook_markers import hookimpl
Expand Down Expand Up @@ -37,7 +38,13 @@
is_flag=True,
help="Returns whether a local Control Service is currently installed.",
)
def server(install, uninstall, status):
@click.option(
"-si",
"--server-id",
default="",
help="Server identifier. Used to create multiple instances of VDK Server on same machine.",
)
def server(install, uninstall, status, server_id):
flags = 0
if install:
flags += 1
Expand All @@ -51,7 +58,7 @@ def server(install, uninstall, status):
"Exactly one of --install, --uninstall, or --status options should be specified"
)
else:
installer = Installer()
installer = Installer(server_id)
if install:
installer.install()
elif uninstall:
Expand Down
25 changes: 25 additions & 0 deletions projects/vdk-plugins/vdk-server/tests/test_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2021-2024 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0
from click.testing import Result
from vdk.plugin.server import server_plugin
from vdk.plugin.test_utils.util_funcs import cli_assert_equal
from vdk.plugin.test_utils.util_funcs import CliEntryBasedTestRunner


def test_install():
runner = CliEntryBasedTestRunner(server_plugin)

result: Result = runner.invoke(["-v", "debug", "server", "--uninstall"])
cli_assert_equal(0, result)

result: Result = runner.invoke(["-v", "debug", "server", "--install"])

cli_assert_equal(0, result)

result: Result = runner.invoke(["-v", "debug", "server", "--status"])

cli_assert_equal(0, result)
assert (
"The Versatile Data Kit Control Service is installed and running"
in result.output
)

0 comments on commit c4f99c9

Please sign in to comment.