Skip to content
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
20 changes: 16 additions & 4 deletions app/controllers/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,11 @@ def get(self, app_id):
app_list["pod_statuses"] = self.get_pod_statuses(
kube_client, project.alias, app_list['alias'])

conditions = getattr(app_status_object.status,
"conditions", None) or []
app_list["deployment_messages"] = [
condition.message for condition in app_status_object.status.conditions
if condition.type == "Available"
condition.message for condition in conditions
if getattr(condition, "type", None) == "Available"
]

app_list["app_running_status"] = self.get_app_running_status(
Expand All @@ -649,7 +651,12 @@ def extract_app_details(app_status_object):
"image": container.image,
"port": container.ports[0].container_port if container.ports else None,
"replicas": app_status_object.spec.replicas,
"revision": app_status_object.metadata.annotations.get('deployment.kubernetes.io/revision'),
"revision": (
app_status_object.metadata.annotations.get(
'deployment.kubernetes.io/revision')
if (app_status_object.metadata and getattr(app_status_object.metadata, 'annotations', None))
else None
),
"command": ' '.join(container.command) if container.command else None,
"working_dir": container.working_dir,
"env_vars": {env.name: env.value for env in container.env} if container.env else None,
Expand Down Expand Up @@ -714,8 +721,13 @@ def get_app_running_status(app, app_status_object, kube_client, namespace):
if app.disabled:
return "disabled"

conditions = getattr(app_status_object.status,
"conditions", None) or []
app_deployment_status = next(
(condition.status for condition in app_status_object.status.conditions if condition.type == "Available"), None)
(c.status for c in conditions if getattr(
c, "type", None) == "Available"),
None
)

try:
app_db_status_object = kube_client.appsv1_api.read_namespaced_deployment_status(
Expand Down
23 changes: 13 additions & 10 deletions app/helpers/kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def deploy_user_app(kube_client, project: Project, user: User, app: App = None,

mount_path = '/data'

selector_data = {'app': app_alias,
'app.kubernetes.io/instance': app_alias}

# create app deployment's pvc meta and spec
is_ai = app_data.get('is_ai', False)
if is_ai:
Expand Down Expand Up @@ -214,12 +217,11 @@ def deploy_user_app(kube_client, project: Project, user: User, app: App = None,

# spec
template = client.V1PodTemplateSpec(
metadata=client.V1ObjectMeta(labels={
'app': app_alias
}),
metadata=client.V1ObjectMeta(labels=selector_data),
spec=client.V1PodSpec(
containers=[container],
image_pull_secrets=[image_pull_secret],
image_pull_secrets=[
image_pull_secret] if image_pull_secret else None,
volumes=volumes if is_ai else None
)
)
Expand All @@ -228,7 +230,7 @@ def deploy_user_app(kube_client, project: Project, user: User, app: App = None,
spec = client.V1DeploymentSpec(
replicas=replicas,
template=template,
selector={'matchLabels': {'app': app_alias}}
selector={'matchLabels': selector_data}
)

# Instantiate the deployment
Expand All @@ -255,15 +257,14 @@ def deploy_user_app(kube_client, project: Project, user: User, app: App = None,

service_meta = client.V1ObjectMeta(
name=service_name,
labels={'app': app_alias, 'app.kubernetes.io/instance': app_alias}
labels=selector_data
)

service_spec = client.V1ServiceSpec(
type='ClusterIP',
ports=[client.V1ServicePort(
port=int(current_app.config['KUBE_SERVICE_PORT']), target_port=app_port)],
selector={'app': app_alias,
'app.kubernetes.io/instance': app_alias}
selector=selector_data
)

service = client.V1Service(
Expand Down Expand Up @@ -311,8 +312,10 @@ def deploy_user_app(kube_client, project: Project, user: User, app: App = None,
host=sub_domain,
http=client.V1HTTPIngressRuleValue(
paths=[client.V1HTTPIngressPath(
path="",
path_type="ImplementationSpecific",
path="/",
path_type="Prefix",
# path="",
# path_type="ImplementationSpecific",
backend=new_ingress_backend
)]
)
Expand Down
Loading