Skip to content

Commit

Permalink
Merge pull request #533 from GrahamDumpleton/various-fixes
Browse files Browse the repository at this point in the history
Lookup service fixes.
  • Loading branch information
GrahamDumpleton authored Aug 9, 2024
2 parents 718d903 + 802b02c commit 7726f98
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
#@ ingress_secret = "{}-tls".format(data.values.clusterIngress.domain)
#@ end

#@ ingress_ca_secret = data.values.clusterIngress.caCertificateRef.name

#@ workshop_base_image = image_reference("base-environment")
#@ workshop_base_image_pull_policy = image_pull_policy(workshop_base_image)

#@ def lookup_service_values():
tld: #@ "{}.{}".format(data.values.lookupService.ingressPrefix, data.values.clusterIngress.domain)
certName: #@ ingress_secret
caName: #@ ingress_ca_secret
image: #@ image
imagePullPolicy: #@ image_pull_policy(image)
workshopBaseImage: #@ workshop_base_image
workshopBaseImagePullPolicy: #@ workshop_base_image_pull_policy
#@ end

#@ if data.values.lookupService.enabled:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:data", "data")

#@overlay/match by=overlay.subset({"kind":"Deployment"})
---
spec:
template:
spec:
#@ if data.values.caName != None and data.values.caName != "":
#@overlay/match missing_ok=True
initContainers:
- name: ca-trust-store-initialization
image: #@ data.values.workshopBaseImage
imagePullPolicy: #@ data.values.workshopBaseImagePullPolicy
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: false
runAsUser: 0
command:
- /opt/eduk8s/sbin/setup-certificates
volumeMounts:
- name: workshop-ca
mountPath: /etc/pki/ca-trust/source/anchors/Cluster_Ingress_CA.pem
subPath: ca.crt
- name: workshop-ca-trust
mountPath: /mnt
containers:
#@overlay/match by="name"
- name: lookup-service
volumeMounts:
- name: workshop-ca-trust
mountPath: /etc/pki/ca-trust
readOnly: true
volumes:
- name: workshop-ca
secret:
secretName: #@ data.values.caName
- name: workshop-ca-trust
emptyDir: {}
#@ end
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#! Ingress
tld: ""
certName: ""
#! Custom CA
caName: ""
#! Images
image: ""
imagePullPolicy: ""
workshopBaseImage: ""
workshopBaseImagePullPolicy: ""
2 changes: 1 addition & 1 deletion carvel-packages/installer/config/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ spec:
- kapp:
rawOptions:
- "--app-changes-max-to-keep=0"
- "--diff-changes=true"
#! - "--diff-changes=true"
8 changes: 6 additions & 2 deletions lookup-service/service/caches/portals.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ async def reacquire_workshop_session(
self.portal.cluster.name,
user_id,
)
logger.error("Failed response status: %s", response.status)
logger.error("Failed response text: %s", await response.text())

return

Expand Down Expand Up @@ -309,7 +311,7 @@ async def request_workshop_session(
self,
environment_name: str,
user_id: str,
parameters: Dict[Tuple[str, str], str],
parameters: List[Dict[str, str]],
index_url: str,
) -> Dict[str, str] | None:
"""Request a workshop session for a user."""
Expand All @@ -325,9 +327,9 @@ async def request_workshop_session(
headers=headers,
params={
"user": user_id,
"parameters": parameters,
"index_url": index_url,
},
json={"parameters": parameters},
) as response:
if response.status != 200:
logger.error(
Expand All @@ -336,6 +338,8 @@ async def request_workshop_session(
self.portal.cluster.name,
user_id,
)
logger.error("Failed response status: %s", response.status)
logger.error("Failed response text: %s", await response.text())

return

Expand Down
4 changes: 2 additions & 2 deletions lookup-service/service/handlers/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ def clusterconfigs_update(


@kopf.on.delete("clusterconfigs.lookup.educates.dev")
def clusterconfigs_delete(name: str, memo: ServiceState, **_):
def clusterconfigs_delete(name: str, meta: kopf.Meta, memo: ServiceState, **_):
"""Remove the cluster configuration from the cluster database."""

generation = memo.get("generation")
generation = meta.get("generation")

cluster_database = memo.cluster_database

Expand Down
2 changes: 0 additions & 2 deletions session-manager/handlers/workshopsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -3161,8 +3161,6 @@ def _apply_environment_patch(patch):

phase = "Running"

logger.info("STATUS %s", status)

changes = {
"message": None,
"url": url,
Expand Down

0 comments on commit 7726f98

Please sign in to comment.