Merge ~addyess/charm-thruk-agent:lp1849578-enable_https_without_http into charm-thruk-agent:master

Proposed by Adam Dyess
Status: Merged
Approved by: Chris Sanders
Approved revision: 41c08728d2009de83f6a7a78d3cda937606f7e8e
Merged at revision: dfd6f46435ce80db9a342ed1eeb2a0cd572747ad
Proposed branch: ~addyess/charm-thruk-agent:lp1849578-enable_https_without_http
Merge into: charm-thruk-agent:master
Diff against target: 38 lines (+20/-0)
1 file modified
hooks/actions.py (+20/-0)
Reviewer Review Type Date Requested Status
Chris Sanders (community) Approve
Xav Paice Pending
Andrea Ieri Pending
Review via email: mp+387091@code.launchpad.net

Commit message

symlink the thruk cookie to /etc/apache2/vhost.d/ so it can be included by nagios vhost config

To post a comment you must log in.
Revision history for this message
Adam Dyess (addyess) wrote :

Couldn't lint the project --> Updated to support linting, fixed lint errors
Updated charmhelpers to support python 3.8.
Non-Standard Unit testing --> Updated to support pytest
Non-Standard Functional testing --> Updated to remove amulet tests
   Added two more tests to functional testing
   Extended to test xenial and bionic (not focal -- it doesn't work)

And FINALLY --
create a directory /etc/apache2/vhost.d/
so that subordinate charms can add *.include files in it -- then ssl vhost config can use those

Revision history for this message
Adam Dyess (addyess) wrote :
Revision history for this message
Adam Dyess (addyess) wrote :
Revision history for this message
Chris Sanders (chris.sanders) wrote :

The change looks good, looking at that unit test. Is that a coverage report of the built in site-packages? Those should be excluded, but more importantly are there any local unit tests at all?

I don't think adding a completely missing unit test framework is in-scope for fixing this bug but wanted to be sure we were both in alignment that there doesn't appear to be any actual tests in that test output.

review: Needs Information
Revision history for this message
Adam Dyess (addyess) wrote :

Yes, you are correct that thruk-agent has an embarrassingly pitiful amount of unit test coverage.

There is one test, but it is not being correctly run under this environment. You can see that I fixed that in another MR (https://code.launchpad.net/~addyess/charm-thruk-agent/+git/charm-thruk-agent/+merge/387134) which has already been approved

Revision history for this message
Chris Sanders (chris.sanders) wrote :

Alright then, glad there's already another fix for the one existing test.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/actions.py b/hooks/actions.py
2index 440fa5b..00f8eb5 100644
3--- a/hooks/actions.py
4+++ b/hooks/actions.py
5@@ -91,6 +91,25 @@ def notify_thrukmaster_relation(service_name):
6 hookenv.relation_set(relation_id=rel_id, relation_settings=thruk_data)
7
8
9+def install_cookie_into_apache2():
10+ """Activate cookie in existing default virtual hosts."""
11+ thruk_cookie = "/etc/apache2/vhost.d/thruk_cookie_auth.include"
12+ try:
13+ os.makedirs('/etc/apache2/vhost.d/')
14+ except OSError:
15+ pass
16+
17+ try:
18+ os.remove(thruk_cookie)
19+ except OSError:
20+ pass
21+
22+ os.symlink(
23+ "/usr/share/thruk/thruk_cookie_auth.include",
24+ thruk_cookie
25+ )
26+
27+
28 def update_ppa(service_name):
29 config = hookenv.config()
30 prev_source = config.previous('source')
31@@ -106,6 +125,7 @@ def update_ppa(service_name):
32 pkgs_to_install = filter_installed_packages(PACKAGE_LIST)
33 if pkgs_to_install:
34 apt_install(packages=pkgs_to_install, fatal=True)
35+ install_cookie_into_apache2()
36
37
38 def update_status(service_name):

Subscribers

People subscribed via source and target branches

to all changes: