Skip to content

Commit

Permalink
fix(knox): fix broken yarn links for livy
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdibn committed Oct 27, 2023
1 parent deb2e0c commit 7efdf57
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
58 changes: 58 additions & 0 deletions roles/knox/common/templates/services/livy/0.4.3/rewrite.xml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<rules>
<!-- These should be removed at some point since Livy
doesn't have /v1 in the REST API specification -->
<rule dir="IN" name="LIVYSERVER/livy/root/v1/inbound/" pattern="*://*:*/**/livy/v1">
<rewrite template="{$serviceUrl[LIVYSERVER]}"/>
</rule>
<rule dir="IN" name="LIVYSERVER/livy/path/v1/inbound" pattern="*://*:*/**/livy/v1/{path=**}?{**}">
<rewrite template="{$serviceUrl[LIVYSERVER]}/{path=**}?{**}"/>
</rule>

<!-- Prefer these rules without v1 in the url -->
<rule dir="IN" name="LIVYSERVER/livy/root/inbound" pattern="*://*:*/**/livy">
<rewrite template="{$serviceUrl[LIVYSERVER]}"/>
</rule>
<rule dir="IN" name="LIVYSERVER/livy/path/inbound" pattern="*://*:*/**/livy/{path=**}?{**}">
<rewrite template="{$serviceUrl[LIVYSERVER]}/{path=**}?{**}"/>
</rule>

<rule dir="OUT" name="LIVYSERVER/livy/outbound/sparkurl" pattern="*://*:*/proxy/{**}">
<rewrite template="{$frontend[url]}/yarn/proxy/{**}"/>
</rule>

<rule dir="OUT" name="LIVYSERVER/livy/outbound/logs" pattern="{scheme}://{host}:{port}/node/containerlogs/{**}?{**}">
<rewrite template="{$frontend[url]}/yarn/node/containerlogs/{**}?{**}?{scheme}?host={$hostmap(host)}?{port}"/>
</rule>

<rule dir="OUT" name="LIVYSERVER/livy/outbound/logs2" pattern="{scheme}://{host}:{port}/node/containerlogs/{**}">
<rewrite template="{$frontend[url]}/yarn/node/containerlogs/{**}?{scheme}?host={$hostmap(host)}?{port}"/>
</rule>

<rule dir="OUT" name="LIVYSERVER/livy/outbound/headers/ui" pattern="{scheme}://{host}:{port}/ui/">
<rewrite template="{$frontend[url]}/livy/ui/"/>
</rule>

<filter name="LIVYSERVER/livy/outbound/headers">
<content type="application/x-http-headers">
<apply path="Location" rule="LIVYSERVER/livy/outbound/headers/ui"/>
</content>
</filter>

</rules>
35 changes: 35 additions & 0 deletions roles/knox/common/templates/services/livy/0.4.3/service.xml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<service role="LIVYSERVER" name="livy" version="0.4.3">
<metadata>
<type>API_AND_UI</type>
<context>/livy/</context>
<shortDesc>Livy Server</shortDesc>
<description>Apache Livy is a service that enables easy interaction with a Spark cluster over a REST interface.</description>
</metadata>
<routes>
<route path="/livy/**?**"/>
<route path="/livy">
<rewrite apply="LIVYSERVER/livy/outbound/headers" to="response.headers"/>
</route>
<route path="/livy/">
<rewrite apply="LIVYSERVER/livy/outbound/headers" to="response.headers"/>
</route>
</routes>
<dispatch classname="org.apache.knox.gateway.livy.LivyDispatch"/>
</service>
25 changes: 25 additions & 0 deletions roles/knox/gateway/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,31 @@
group: "{{ knox_group }}"
mode: "644"

# Livy Spark 2 service definition
- name: Create Livy Spark 2 service dir
ansible.builtin.file:
path: "{{ knox_data_dir }}/data/services/livy/0.4.3"
state: directory
owner: "{{ knox_user }}"
group: "{{ knox_group }}"
mode: "755"

- name: Template Livy Spark 2 service.xml
ansible.builtin.template:
src: services/livy/0.4.3/service.xml.j2
dest: "{{ knox_data_dir }}/data/services/livy/0.4.3/service.xml"
owner: "{{ knox_user }}"
group: "{{ knox_group }}"
mode: "644"

- name: Template Livy Spark 2 rewrite.xml
ansible.builtin.template:
src: services/livy/0.4.3/rewrite.xml.j2
dest: "{{ knox_data_dir }}/data/services/livy/0.4.3/rewrite.xml"
owner: "{{ knox_user }}"
group: "{{ knox_group }}"
mode: "644"

- name: Template Knox gateway-site.xml
ansible.builtin.template:
src: gateway-site.xml.j2
Expand Down

0 comments on commit 7efdf57

Please sign in to comment.