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

Fix restore of RETENTION_DAYS variable #20

Merged
merged 4 commits into from
May 31, 2024
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
3 changes: 2 additions & 1 deletion imageroot/actions/clone-module/50configure-module
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ configure_retval = agent.tasks.run(agent_id=os.environ['AGENT_ID'], action='conf
"lets_encrypt": os.environ["TRAEFIK_LETS_ENCRYPT"] == 'True',
"host": os.environ["TRAEFIK_HOST"],
"http2https": os.environ["TRAEFIK_HTTP2HTTPS"] == 'True',
"restore": True,
"restore": True, # restore the configuration to the relay rule and the alwaysBccAddress
"retention_days": int(os.environ["RETENTION_DAYS"]),
})
agent.assert_exp(configure_retval['exit_code'] == 0, "The configure-module subtask failed!")
19 changes: 2 additions & 17 deletions imageroot/actions/configure-module/90add-relay-rule
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ ip_address = rdb.hget(f'node/{node_id}/vpn', 'ip_address')

if providers:
mail_id = providers[0]["module_id"]
if not os.environ.get("MAIL_SERVER"):
# we configure the first time and if we are in a clone or restore action
if not os.environ.get("MAIL_SERVER") or data.get("restore", False):
# first configuration, we add the relay rule
response = agent.tasks.run(f"module/{mail_id}", action='add-relay-rule', data={
"rule_type": "always-bcc",
Expand All @@ -44,21 +45,5 @@ if providers:
"bcc": "archive@"+os.environ['MODULE_ID']
})
agent.assert_exp(response['exit_code'] == 0)
else:
response = agent.tasks.run(f"module/{mail_id}", action='alter-relay-rule', data={
"rule_type": "always-bcc",
"rule_subject": "archive@"+os.environ['MODULE_ID'],
"host": ip_address,
"port": int(os.environ['TCP_PORT_ARCHIVE']),
"mandatory_tls": False,
"username": "",
"password": "",
"enabled": True})
agent.assert_exp(response['exit_code'] == 0)
# we need to set bcc address for the mail server
response = agent.tasks.run(f"module/{mail_id}", action='set-always-bcc', data={
"bcc": "archive@"+os.environ['MODULE_ID']
})
agent.assert_exp(response['exit_code'] == 0)

agent.set_env("MAIL_SERVER", data["mail_server"])
1 change: 1 addition & 0 deletions imageroot/actions/restore-module/06copyenv
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ for evar in [
"TRAEFIK_HTTP2HTTPS",
"TRAEFIK_LETS_ENCRYPT",
"MAIL_SERVER",
"RETENTION_DAYS",
]:
agent.set_env(evar, original_environment[evar])

Expand Down
3 changes: 2 additions & 1 deletion imageroot/actions/restore-module/50configure-module
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ configure_retval = agent.tasks.run(agent_id=os.environ['AGENT_ID'], action='conf
"lets_encrypt": renv["TRAEFIK_LETS_ENCRYPT"] == 'True',
"host": renv["TRAEFIK_HOST"],
"http2https": renv["TRAEFIK_HTTP2HTTPS"] == 'True',
"restore": True,
"restore": True, # restore the configuration to the relay rule and the alwaysBccAddress
'retention_days': int(renv['RETENTION_DAYS']),
})
agent.assert_exp(configure_retval['exit_code'] == 0, "The configure-module subtask failed!")
Loading