Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #304 from helxplatform/develop
Browse files Browse the repository at this point in the history
Merge Develop
  • Loading branch information
waTeim authored Oct 24, 2023
2 parents 705cdc6 + 9e3ee18 commit 39819e4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,19 @@ Using the command lines above without the `-s` flag for server will work on GKE.
client_factory = TychoClientFactory ()
client = client_factory.get_client ()
```

### "proxy_rewrite" Feature Overview:

The "proxy_rewrite" feature ensures system-wide consistency in handling service
locations, especially when interacting with higher-level reverse proxies. By def
ining annotations in `service.yaml`, Ambassador's behavior is tailored, allowing
the underlying service to perceive an altered path while maintaining a consistent
location view at the system level.

- **context.py**: Processes external specifications, capturing "proxy_rewrite"
directives, and transforms them into an internal representation.
- **model.py**: Forms the structural foundation of the system, accurately reflecting
the "proxy_rewrite" configurations and their implications.
- **service.yaml**: Serves as a template for Kubernetes service definitions. When
interpreted, it influences Ambassador's behavior using "proxy_rewrite" annotations,
ensuring path and location consistency across the system.
2 changes: 1 addition & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_system_model(request):
"principal": {"username": "renci"},
"service_account": "default",
"conn_string": "",
"proxy_rewrite_rule": False,
"proxy_rewrite": { 'enabled': False },
"containers": [
{
"name": "nginx-container",
Expand Down
2 changes: 1 addition & 1 deletion tycho/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "1.16.1"
VERSION = "1.17.1"
4 changes: 3 additions & 1 deletion tycho/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ def start (self, principal, app_id, resource_request, host):
spec["services"][app_id]["conn_string"] = conn_string
""" Add a proxy rewrite rule """
proxy_rewrite_rule = self.apps.get(app_id).get("proxy-rewrite-rule", False)
spec["services"][app_id]["proxy_rewrite_rule"] = proxy_rewrite_rule
proxy_rewrite = self.apps.get(app_id).get("proxy-rewrite", { "enabled":False, "target":None })
spec["services"][app_id]["proxy_rewrite"] = proxy_rewrite
if proxy_rewrite_rule: spec["services"][app_id]["proxy_rewrite"]["enabled"] = True
""" Add gitea integration rule """
gitea_integration = self.apps.get(app_id).get("gitea-integration", False)
spec["services"][app_id]["gitea_integration"] = gitea_integration
Expand Down
6 changes: 3 additions & 3 deletions tycho/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def __repr__(self):

class System:
""" Distributed system of interacting containerized software. """
def __init__(self, config, name, principal, service_account, conn_string, proxy_rewrite_rule, containers, identifier,
def __init__(self, config, name, principal, service_account, conn_string, proxy_rewrite, containers, identifier,
gitea_integration, services={}, security_context={}, init_security_context={}):
""" Construct a new abstract model of a system given a name and set of containers.
Expand Down Expand Up @@ -242,7 +242,7 @@ def __init__(self, config, name, principal, service_account, conn_string, proxy_
self.init_memory = os.environ.get("TYCHO_APP_INIT_MEMORY", "250Mi")
self.gpu_resource_name = os.environ.get("TYCHO_APP_GPU_RESOURCE_NAME", "nvidia.com/gpu")
"""Proxy rewrite rule for ambassador service annotations"""
self.proxy_rewrite_rule = proxy_rewrite_rule
self.proxy_rewrite = proxy_rewrite
# """Flag for checking if an IRODS connection is enabled"""
if os.environ.get("IROD_HOST") != None:
logger.info("Irods host enabled")
Expand Down Expand Up @@ -452,7 +452,7 @@ def parse (config, name, principal, system, service_account, env={}, services={}
"principal": principal,
"service_account": service_account,
"conn_string": spec.get("conn_string", ""),
"proxy_rewrite_rule": spec.get("proxy_rewrite_rule", False),
"proxy_rewrite": spec.get("proxy_rewrite", { 'target':None, 'enabled':False }),
"containers": containers,
"identifier": identifier,
"gitea_integration": spec.get("gitea_integration", False),
Expand Down
8 changes: 7 additions & 1 deletion tycho/template/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ metadata:
headers:
REMOTE_USER: {{system.username}}
{% endif %}
{% if system.proxy_rewrite_rule == True %}
{% if system.proxy_rewrite.enabled == True %}
{% if system.proxy_rewrite.target == None %}
rewrite: /private/{{system.system_name}}/{{system.username}}/{{system.identifier}}/{{system.conn_string}}
{% else %}
rewrite: {{ system.proxy_rewrite.target }}
add_response_headers:
X-Original-Path: /private/{{system.system_name}}/{{system.username}}/{{system.identifier}}/{{system.conn_string}}
{% endif %}
{% endif %}
retry_policy:
retry_on: gateway-error
Expand Down

0 comments on commit 39819e4

Please sign in to comment.