Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Generic option while setting up root domain and custom tls #2060

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
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
5 changes: 4 additions & 1 deletion press/api/marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
get_total_installs_by_app,
)
from press.utils import get_app_tag, get_current_team, get_last_doc, unique
from press.utils.billing import get_frappe_io_connection
from press.utils.billing import get_frappe_io_connection, disabled_frappeio_auth


@frappe.whitelist()
Expand Down Expand Up @@ -1099,6 +1099,9 @@ def get_discount_percent(plan, discount=0.0):
"Bronze": 30.0,
}

if disabled_frappeio_auth():
return discount

if team.erpnext_partner and frappe.get_value(
"Marketplace App Plan", plan, "partner_discount"
):
Expand Down
15 changes: 14 additions & 1 deletion press/api/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,20 @@ def update_partnership_date(team, partnership_date):

@frappe.whitelist()
def get_partner_details(partner_email):
from press.utils.billing import get_frappe_io_connection
from press.utils.billing import get_frappe_io_connection, disabled_frappeio_auth

if disabled_frappeio_auth():
return frappe._dict(
{
"email": "",
"partner_type": "",
"company_name": "",
"custom_ongoing_period_fc_invoice_contribution": "",
"custom_ongoing_period_enterprise_invoice_contribution": "",
"partner_name": "",
"custom_number_of_certified_members": "",
}
)

client = get_frappe_io_connection()
data = client.get_doc(
Expand Down
7 changes: 7 additions & 0 deletions press/playbooks/roles/agent/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@
content: '{{ certificate_intermediate_chain }}'
dest: /home/frappe/agent/tls/chain.pem

- name: Setup TLS Mapper
become: yes
become_user: frappe
copy:
content: '{{ certificate_file_mapper }}'
dest: /home/frappe/agent/tls/tls_file_mapper.json

- name: Setup Agent NGINX
become: yes
become_user: frappe
Expand Down
10 changes: 5 additions & 5 deletions press/playbooks/roles/mariadb/templates/mariadb.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ max-connect-errors = 1000000
innodb = FORCE

# DATA STORAGE #
datadir = /var/lib/mysql/
datadir = {{ data_dir }}/

# BINARY LOGGING #
log-bin = /var/lib/mysql/mysql-bin
log_bin_index = /var/lib/mysql/mysql-bin.index
log-bin = {{ data_dir }}/mysql-bin
log_bin_index = {{ data_dir }}/mysql-bin.index
expire-logs-days = 14
sync-binlog = 1

Expand Down Expand Up @@ -53,10 +53,10 @@ character-set-client-handshake = FALSE
max_allowed_packet = 512M

# LOGGING #
log-error = /var/lib/mysql/mysql-error.log
log-error = {{ data_dir }}/mysql-error.log
log-queries-not-using-indexes = 0
slow-query-log = 1
slow-query-log-file = /var/lib/mysql/mysql-slow.log
slow-query-log-file = {{ data_dir }}/mysql-slow.log

# Networking
bind-address = {{ private_ip }}
Expand Down
12 changes: 6 additions & 6 deletions press/playbooks/self_hosted_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
- role: essentials
- role: user
- role: mariadb
- role: nginx
- role: agent
- role: node_exporter
- role: mysqld_exporter
- role: deadlock_logger
- role: filebeat
# - role: nginx
# - role: agent
# # - role: node_exporter
# - role: mysqld_exporter
# - role: deadlock_logger
# - role: filebeat
8 changes: 4 additions & 4 deletions press/press/doctype/analytics_server/analytics_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ def validate_plausible_password(self):

def _setup_server(self):
agent_repository_url = self.get_agent_repository_url()
certificate_name = frappe.db.get_value(
"TLS Certificate", {"wildcard": True, "domain": self.domain}, "name"
)
certificate = frappe.get_doc("TLS Certificate", certificate_name)
certificate = self.get_certificate()

log_server = frappe.db.get_single_value("Press Settings", "log_server")
if log_server:
Expand All @@ -76,6 +73,8 @@ def _setup_server(self):
ansible = Ansible(
playbook="analytics.yml",
server=self,
user=self._ssh_user(),
port=self._ssh_port(),
variables={
"server": self.name,
"workers": 1,
Expand All @@ -97,6 +96,7 @@ def _setup_server(self):
"certificate_private_key": certificate.private_key,
"certificate_full_chain": certificate.full_chain,
"certificate_intermediate_chain": certificate.intermediate_chain,
"certificate_file_mapper": certificate.tls_file_mapper,
},
)
play = ansible.run()
Expand Down
18 changes: 17 additions & 1 deletion press/press/doctype/app_release/app_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,28 @@ def check_python_syntax(dirpath: str) -> str:
- -o: optimize level, 0 is no optimization
"""

command = f"python3 -m compileall -q -o 0 {dirpath}"
def _get_python_version():
proc = subprocess.run(
shlex.split("python3 --version"),
text=True,
capture_output=True,
)
return proc.stdout

python_version = _get_python_version()

if "Python 3.8" in python_version:
# In python3.8 compileall does not supports -o flag
command = f"python3 -m compileall -q {dirpath}"
else:
command = f"python3 -m compileall -q -o 0 {dirpath}"

proc = subprocess.run(
shlex.split(command),
text=True,
capture_output=True,
)

if proc.returncode == 0:
return ""

Expand Down
31 changes: 31 additions & 0 deletions press/press/doctype/database_server/database_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,37 @@ frappe.ui.form.on('Database Server', {
},
__('Dangerous Actions'),
);
frm.add_custom_button(
__('Change Mariadb Data Directory'),
() => {
const dialog = new frappe.ui.Dialog({
title: __('Update Memory Allocator'),
fields: [
{
fieldtype: 'Data',
label: __('Data Directory'),
fieldname: 'data_dir',
reqd: 1,
},
],
});

dialog.set_primary_action(__('Update'), (args) => {
frm.call({
method: 'change_data_directory',
doc: frm.doc,
args: args,
freeze: true,
callback: () => {
dialog.hide();
frm.refresh();
},
});
});
dialog.show();
},
__('Dangerous Actions'),
);
}
},

Expand Down
16 changes: 15 additions & 1 deletion press/press/doctype/database_server/database_server.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"mariadb_section",
"self_hosted_mariadb_server",
"mariadb_root_password",
"data_dir",
"_old_data_directory",
"server_id",
"is_primary",
"column_break_12",
Expand Down Expand Up @@ -517,11 +519,23 @@
"fieldtype": "Int",
"label": "Auto Add Storage Max",
"non_negative": 1
},
{
"fieldname": "data_dir",
"fieldtype": "Data",
"label": "Data Directory",
"read_only": 1
},
{
"fieldname": "_old_data_directory",
"fieldtype": "Data",
"label": "_Old Data Directory",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-08-13 11:02:07.399141",
"modified": "2024-08-29 14:35:57.852153",
"modified_by": "Administrator",
"module": "Press",
"name": "Database Server",
Expand Down
Loading
Loading