Merge ~aym-frikha/charm-mongodb:branch_1946810 into charm-mongodb:master

Proposed by Aymen Frikha
Status: Merged
Approved by: James Troup
Approved revision: 139336d55a5524f8072594c37db460e613e67b29
Merged at revision: f35fe0bb10a95b9fcbf5429a7f10c882bb58fce2
Proposed branch: ~aym-frikha/charm-mongodb:branch_1946810
Merge into: charm-mongodb:master
Diff against target: 151 lines (+15/-33)
5 files modified
dev/null (+0/-8)
hooks/hooks.py (+14/-18)
metadata.yaml (+0/-1)
tests/functional/requirements.txt (+1/-1)
tests/functional/tests/tests.yaml (+0/-5)
Reviewer Review Type Date Requested Status
🤖 prod-jenkaas-bootstack (community) continuous-integration Approve
Xav Paice (community) Approve
BootStack Reviewers Pending
Review via email: mp+412639@code.launchpad.net

Commit message

resolve bug: #1946810 that prevent the MongoDB replication.
resolve bug: #1952908 That make the CI failing

To post a comment you must log in.
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Xav Paice (xavpaice) wrote :

I note that not every reference to default_mongodb_* is prefixed with a conditional for is_percona_source(). Is that deliberate because it's not needed in some cases, or is it maybe easier to have is_percona_source used in some initial variable setup outside of the remaining functions, so that we have the `# Global variables ` section set up with generic names for paths that are adjusted according to the package source?

Regards the CI failures, I'm running a test to see if it's due to Xenial and various Python package changes that have recently meant for some other charms that we've had to remove Xenial support.

review: Needs Information
Revision history for this message
Xav Paice (xavpaice) wrote :

Functests passed for me after the following patch, I'd support removing Xenial from this release.

diff --git a/metadata.yaml b/metadata.yaml
index 4604c93..a4218ea 100644
--- a/metadata.yaml
+++ b/metadata.yaml
@@ -20,7 +20,6 @@ tags:
 series:
     - focal
     - bionic
- - xenial
 provides:
   nrpe-external-master:
     interface: nrpe-external-master
diff --git a/tests/functional/tests/bundles/xenial.yaml b/tests/functional/tests/bundles/xenial.yaml
deleted file mode 100644
index 56c5081..0000000
--- a/tests/functional/tests/bundles/xenial.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-series: xenial
-description: "mongodb-charm test bundle"
-applications:
- mongodb:
- num_units: 3
- constraints: root-disk=10G
- options:
- replicaset: testset
- backup_directory: /var/backups
diff --git a/tests/functional/tests/tests.yaml b/tests/functional/tests/tests.yaml
index 72347b4..cb8611c 100644
--- a/tests/functional/tests/tests.yaml
+++ b/tests/functional/tests/tests.yaml
@@ -1,9 +1,5 @@
 charm_name: mongodb
 tests:
- - model_alias_xenial:
- - tests.tests_mongodb.BasicMongodbCharmTest
- - tests.tests_mongodb.ReplicatedMongodbCharmTest
- - tests.tests_mongodb.XenialMongodbCharmTest
   - model_alias_bionic:
       - tests.tests_mongodb.BasicMongodbCharmTest
       - tests.tests_mongodb.CharmOperationTest
@@ -22,7 +18,6 @@ tests:
       - tests.tests_mongodb.ShardedMongodbCharmTest
       - tests.tests_mongodb.CharmOperationTest
 gate_bundles:
- - model_alias_xenial: xenial
   - model_alias_bionic: bionic
   - model_alias_bionic_replicated: bionic-replicated
   - model_alias_focal: focal

Revision history for this message
Aymen Frikha (aym-frikha) wrote :

> I note that not every reference to default_mongodb_* is prefixed with a
> conditional for is_percona_source(). Is that deliberate because it's not
> needed in some cases, or is it maybe easier to have is_percona_source used in
> some initial variable setup outside of the remaining functions, so that we
> have the `# Global variables ` section set up with generic names for paths
> that are adjusted according to the package source?

For default_mongodb_config and default_mongodb_pid_file, every reference is prefixed with a conditional for is_percona_source() to be adjusted based on the package source, only the default_mongodb_init_config variable is not prefixed since it's not necessary in this situation.
In my opinion, the charm code needs a big redesign (split into classes and scripts) to have simpler review process and understandable code.

> Regards the CI failures, I'm running a test to see if it's due to Xenial and
> various Python package changes that have recently meant for some other charms
> that we've had to remove Xenial support.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Xav Paice (xavpaice) wrote :

Change LGTM, Unit and Lint pass in CI, functests not but they're OK locally for me.

I'll review the functest issues in CI separately, it could be a tester machine issue (unit tests failed on my local Bionic test runner, but functests pass).

2021-12-07 22:12:03 [INFO] Events:
  Deploy Bundle:
    Start: 1638914731.8535476
    Finish: 1638914737.2969482
    Elapsed Time: 5.443400621414185
    PCT Of Run Time: 2
  Prepare Environment:
    Start: 1638914729.4626167
    Finish: 1638914731.8533437
    Elapsed Time: 2.3907270431518555
    PCT Of Run Time: 1
  Test tests.tests_mongodb.BasicMongodbCharmTest:
    Start: 1638915099.0387628
    Finish: 1638915101.6677506
    Elapsed Time: 2.6289877891540527
    PCT Of Run Time: 1
  Test tests.tests_mongodb.CharmOperationTest:
    Start: 1638915102.7218187
    Finish: 1638915105.89774
    Elapsed Time: 3.1759212017059326
    PCT Of Run Time: 1
  Test tests.tests_mongodb.ReplicatedMongodbCharmTest:
    Start: 1638915101.6679058
    Finish: 1638915102.72168
    Elapsed Time: 1.053774118423462
    PCT Of Run Time: 1
  Wait for Deployment:
    Start: 1638914737.2969673
    Finish: 1638915098.8577418
    Elapsed Time: 361.56077456474304
    PCT Of Run Time: 97
Metadata: {}

____________________________________________________________________________________________________ summary _____________________________________________________________________________________________________
  func: commands succeeded
  congratulations :)

review: Approve
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision f35fe0bb10a95b9fcbf5429a7f10c882bb58fce2

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/hooks.py b/hooks/hooks.py
2index 42af6e3..9d07683 100755
3--- a/hooks/hooks.py
4+++ b/hooks/hooks.py
5@@ -143,11 +143,9 @@ was_i_primary = False
6
7
8 def is_percona_source():
9- """This function will check the source repository of mongodb package
10- and return true if it comes from percona repo because it will change the whole charm
11- process like the config file structure.
12- An example of the percona mongodb repository is:
13- http://repo.percona.com/psmdb-44/apt main
14+ """Return true if MongoDB package comes from Percona repo.
15+
16+ It change the charm process if we are managing Percona MongoDB.
17 """
18 if "repo.percona.com" in config("source") or config("percona-mode"):
19 return True
20@@ -719,8 +717,6 @@ def leave_replset(master_node=None, host=None):
21
22
23 def enable_replset(replicaset_name=None):
24- if is_percona_source():
25- default_mongodb_config = percona_mongodb_config
26 retval = False
27 if replicaset_name is None:
28 juju_log("enable_replset: replicaset_name is None, exiting", level=DEBUG)
29@@ -744,7 +740,10 @@ def enable_replset(replicaset_name=None):
30 mongodb_config = mongodb_conf(config_data)
31 else:
32 mongodb_config = mongodb_conf_yaml(config_data)
33- retval = update_file(default_mongodb_config, mongodb_config)
34+ if is_percona_source():
35+ retval = update_file(percona_mongodb_config, mongodb_config)
36+ else:
37+ retval = update_file(default_mongodb_config, mongodb_config)
38
39 juju_log("enable_replset will return: %s" % str(retval), level=DEBUG)
40
41@@ -987,10 +986,6 @@ def enable_mongos(
42 wait_for=default_wait_for,
43 max_tries=default_max_tries,
44 ):
45- if is_percona_source():
46- mongodb_pid_file = percona_mongodb_pid_file
47- else:
48- mongodb_pid_file = default_mongodb_pid_file
49 juju_log("enable_mongos")
50 if config_data is None or config_servers is None:
51 juju_log("enable_mongos: config_data and config_servers are mandatory")
52@@ -1142,11 +1137,12 @@ def config_changed(): # noqa: C901
53 config_data = config()
54 juju_log("config_data: {}".format(config_data), level=DEBUG)
55 if is_percona_source():
56- default_mongodb_config = "/etc/mongod.conf"
57- with open(default_mongodb_config) as file:
58+ mongodb_config_path = percona_mongodb_config
59+ with open(mongodb_config_path) as file:
60 mongodb_config = yaml.safe_load(file)
61 else:
62- mongodb_config = open(default_mongodb_config).read()
63+ mongodb_config_path = default_mongodb_config
64+ mongodb_config = open(mongodb_config_path).read()
65
66 if (
67 config_data.changed("volume-ephemeral-storage")
68@@ -1155,7 +1151,7 @@ def config_changed(): # noqa: C901
69 ):
70 config_changed_volume()
71
72- mongodb_config_hash = file_hash(default_mongodb_config)
73+ mongodb_config_hash = file_hash(mongodb_config_path)
74 # current ports
75 if is_percona_source():
76 current_mongodb_port = mongodb_config["net"]["port"]
77@@ -1178,7 +1174,7 @@ def config_changed(): # noqa: C901
78 mongodb_config = mongodb_conf(config_data)
79 else:
80 mongodb_config = mongodb_conf_yaml(config_data)
81- update_file(default_mongodb_config, mongodb_config)
82+ update_file(mongodb_config_path, mongodb_config)
83
84 if config_data["backups_enabled"]:
85 backup_cronjob()
86@@ -1203,7 +1199,7 @@ def config_changed(): # noqa: C901
87 write_logrotate_config(config_data)
88
89 # restart mongodb if the configuration file has changed.
90- if file_hash(default_mongodb_config) != mongodb_config_hash:
91+ if file_hash(mongodb_config_path) != mongodb_config_hash:
92 status_set("maintenance", "Restarting mongod")
93 restart_mongod()
94
95diff --git a/metadata.yaml b/metadata.yaml
96index 4604c93..a4218ea 100644
97--- a/metadata.yaml
98+++ b/metadata.yaml
99@@ -20,7 +20,6 @@ tags:
100 series:
101 - focal
102 - bionic
103- - xenial
104 provides:
105 nrpe-external-master:
106 interface: nrpe-external-master
107diff --git a/tests/functional/requirements.txt b/tests/functional/requirements.txt
108index 65ba4d7..97fc106 100644
109--- a/tests/functional/requirements.txt
110+++ b/tests/functional/requirements.txt
111@@ -1,3 +1,3 @@
112 git+https://github.com/openstack-charmers/zaza.git#egg=zaza
113-pymongo
114+pymongo==3.12.1
115 python-openstackclient
116diff --git a/tests/functional/tests/bundles/xenial.yaml b/tests/functional/tests/bundles/xenial.yaml
117deleted file mode 100644
118index a17f8b7..0000000
119--- a/tests/functional/tests/bundles/xenial.yaml
120+++ /dev/null
121@@ -1,8 +0,0 @@
122-series: xenial
123-description: "mongodb-charm test bundle"
124-applications:
125- mongodb:
126- num_units: 3
127- options:
128- replicaset: testset
129- backup_directory: /var/backups
130diff --git a/tests/functional/tests/tests.yaml b/tests/functional/tests/tests.yaml
131index 72347b4..cb8611c 100644
132--- a/tests/functional/tests/tests.yaml
133+++ b/tests/functional/tests/tests.yaml
134@@ -1,9 +1,5 @@
135 charm_name: mongodb
136 tests:
137- - model_alias_xenial:
138- - tests.tests_mongodb.BasicMongodbCharmTest
139- - tests.tests_mongodb.ReplicatedMongodbCharmTest
140- - tests.tests_mongodb.XenialMongodbCharmTest
141 - model_alias_bionic:
142 - tests.tests_mongodb.BasicMongodbCharmTest
143 - tests.tests_mongodb.CharmOperationTest
144@@ -22,7 +18,6 @@ tests:
145 - tests.tests_mongodb.ShardedMongodbCharmTest
146 - tests.tests_mongodb.CharmOperationTest
147 gate_bundles:
148- - model_alias_xenial: xenial
149 - model_alias_bionic: bionic
150 - model_alias_bionic_replicated: bionic-replicated
151 - model_alias_focal: focal

Subscribers

People subscribed via source and target branches

to all changes: