facebookarchive / CommunityCellularManager

Tool for deploying, managing and controlling your Community Cellular Networks
Other
88 stars 36 forks source link

While depackaging endaga packages, getting the following error #19

Closed brajabasi closed 7 years ago

brajabasi commented 7 years ago

Target: Integrate Openbts client with Cloud App in same machine Pre-Condition: 1) I have 2 shell command terminals in ubuntu 2) In terminal 1 vagrant up services for cloud - This is working fine 3) In terminal 2 vagrant up services for client I have followed the above steps as it mentioned. But failed while installing packages inside openbts vm of client.

vagrant@endaga-client-openbts:~/endaga-packages$ sudo dpkg -i *.deb

Installing new version of config file /etc/openvpn/etage-bundle.crt ... 0fced22e-3e46-4096-ba04-f59946e7fb17 ERROR: database "endaga" already exists ERROR: role "endaga" already exists NOTICE: relation "subscribers" already exists, skipping CREATE TABLE Restarted supervisord Setting up python-openbts (0.1.15) ... Errors were encountered while processing: endaga-openbts_0.7.11_all.deb freeswitch-conf-endaga_0.3.4_all.deb vagrant@endaga-client-openbts:~/endaga-packages$

9muir commented 7 years ago

Installing all the packages from the local directory is tricky, and just using dpkg -i *.deb doesn't generally work, because dpkg doesn't do anything to ensure dependencies are satisfied. If you don't need to incorporate local changes into the binary packages then you can probably just install the top-level package from our Debian repository and let apt resolve all the dependencies, e.g., apt-get install endaga-openbts.

If you do need to install local packages It's usually easiest to just run gdebi endaga-openbts_0.7.11_all.deb (or whatever version of the top-level package is appropriate, and you might need to install gdebi first), and just let dependencies be pulled from the package repo. You can also do a clean install from the repo first, and then just upgrade the packages you changed, in which case dpkg works just fine.

As an aside, in most cases when packaging up local source you don't need to package up the Python dependencies, so you add the argument package_requirements=no to the Fabric command, i.e., fab dev package:package_requirements=no.

brajabasi commented 7 years ago

I am folllowing the Testing section of Client.

facebook@facebook-ThinkPad-T450s:~/fbcode/CommunityCellularManager/client$ sudo pip install -r requirements.txt

Collecting psycopg2==2.6 (from -r requirements.txt (line 20)) Downloading psycopg2-2.6.tar.gz (367kB) 100% |████████████████████████████████| 368kB 82kB/s Complete output from command python setup.py egg_info: running egg_info creating pip-egg-info/psycopg2.egg-info writing pip-egg-info/psycopg2.egg-info/PKG-INFO writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt' Error: pg_config executable not found.

Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:

    python setup.py build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cLK0lc/psycopg2/

I'm not getting pg_config. How to make sure client running?

9muir commented 7 years ago

That looks like Postgres is not installed. Can you verify that it is? It should have been installed as part of the Vagrant first-boot provisioning, but if there was an error during that task the VM will be left in a partially provisioned state, and subsequent vagrant up or vagrant resume commands will not reprovision the VM. It's generally safe to explicitly do so though: vagrant provision openbts.

brajabasi commented 7 years ago

1) I just checked Postgres with following detals

vagrant@endaga-client-openbts:~$ sudo -u postgres psql psql (9.3.15) Type "help" for help.

postgres=# \l postgres=# postgres=# \c endaga You are now connected to database "endaga" as user "postgres". endaga=# \d List of relations Schema | Name | Type | Owner
--------+----------------------+----------+-------- public | endaga_config | table | endaga public | endaga_config_id_seq | sequence | endaga public | subscribers | table | endaga public | subscribers_id_seq | sequence | endaga (4 rows)

endaga=# select count(*) from endaga_config; count

52

(1 row)

endaga=#

2) I just checked registry endpoint, which treturns correct value. This assumption registry end points are stored inside DB vagrant@endaga-client-openbts:~$ endaga_db_get registry http://192.168.40.10:8000/api/v1

3) I have some queries related to BTS registration . My questions are inline

BTS Registration

VPN set up with CCM: <> Is there any VPN setup required between client and cloud. From intial discussion it should be https

4) Cloud Logs while BTS is trying to register continously:

[22/Dec/2016 05:47:56] "POST /dashboard/towers HTTP/1.1" 200 32 [22/Dec/2016 05:47:57] "GET /dashboard/towers HTTP/1.1" 200 21388 [22/Dec/2016 05:47:57] "GET /static/css/dashboard.css HTTP/1.1" 404 1668 [22/Dec/2016 05:48:54] "GET /dashboard/towers/0fced22e-3e46-4096-ba04-f59946e7fb17 HTTP/1.1" 200 6498 [22/Dec/2016 05:48:54] "GET /static/css/dashboard.css HTTP/1.1" 404 1668 [22/Dec/2016 05:52:01] "GET /api/v1/bts/sslconf?bts_uuid=0fced22e-3e46-4096-ba04-f59946e7fb17 HTTP/1.1" 200 585 Internal Server Error: /api/v1/bts/register Traceback (most recent call last): File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner response = get_response(request) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response response = self._get_response(request) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, *kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, args, kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/rest_framework/views.py", line 466, in dispatch response = self.handle_exception(exc) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/rest_framework/views.py", line 463, in dispatch response = handler(request, *args, kwargs) File "/home/vagrant/cloud/endagaweb/views/api.py", line 767, in post data={'ident': bts_uuid, 'csr': csr}) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/api.py", line 88, in post return request('post', url, data=data, kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/api.py", line 44, in request return session.request(method=method, url=url, kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/sessions.py", line 357, in request resp = self.send(prep, send_kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/sessions.py", line 460, in send r = adapter.send(request, **kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/adapters.py", line 354, in send raise ConnectionError(e) ConnectionError: HTTPConnectionPool(host='192.168.40.40', port=80): Max retries exceeded with url: /csr (Caused by <class 'socket.error'>: [Errno 111] Connection refused) [22/Dec/2016 05:52:01] "POST /api/v1/bts/register HTTP/1.1" 500 129203

9muir commented 7 years ago

You don't have to run any of the services on the the 192.168.40.0/24 subnet, that's just the default set in the Ansible scripts. From the client perspective the only thing that you'd have to change would be the registry endpoint.

The cloud logs that you attached show that the cloud/web front-end cannot contact the certifier at 192.168.40.40, is that the address that you have it running on?

9muir commented 7 years ago

Determining whether Postgres is installed can be done with dpkg or rpm (and probably apt or yum too). On Debian/Ubuntu, I use dpkg -l | grep -i postgres.

brajabasi commented 7 years ago

Certifier is running at 192.168.40.40 Please find the following log. But how to make sure it is working or not? facebook@facebook-ThinkPad-T450s:~/fbcode/CommunityCellularManager/cloud$ vagrant ssh cert Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-105-generic x86_64)

kheimerl commented 7 years ago

You should be able to run "sudo supervisorctl certifier" from the CLI. If it says running, certifier is running.

kheimerl commented 7 years ago

Given these issues, it seems there was an issues during the provisioning of the VMs. Have you tried simply destroying and remaking them?

brajabasi commented 7 years ago

I did install both cloud and client but still getting the same error. But which CLI to check "sudo supervisorctl certifier" ? I checked inside cert box.

1) To verify certifier is running or not Last login: Mon Jan 2 06:59:18 2017 from 10.0.2.2 vagrant@endaga-cert:~$ sudo supervisorctl certifier sudo: supervisorctl: command not found vagrant@endaga-cert:~$

2) Registeration request received from client [02/Jan/2017 08:59:28] "GET /api/v1/bts/sslconf?bts_uuid=1cf28e9f-d710-42cf-9b67-1e6e65bc0fc5 HTTP/1.1" 200 585 Internal Server Error: /api/v1/bts/register Traceback (most recent call last): File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner response = get_response(request) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response response = self._get_response(request) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, callback_kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view return view_func(*args, *kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view return self.dispatch(request, args, kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/rest_framework/views.py", line 466, in dispatch response = self.handle_exception(exc) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/rest_framework/views.py", line 463, in dispatch response = handler(request, *args, kwargs) File "/home/vagrant/cloud/endagaweb/views/api.py", line 767, in post data={'ident': bts_uuid, 'csr': csr}) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/api.py", line 88, in post return request('post', url, data=data, kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/api.py", line 44, in request return session.request(method=method, url=url, kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/sessions.py", line 357, in request resp = self.send(prep, send_kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/sessions.py", line 460, in send r = adapter.send(request, **kwargs) File "/home/vagrant/.virtualenvs/endaga/local/lib/python2.7/site-packages/requests/adapters.py", line 354, in send raise ConnectionError(e) ConnectionError: HTTPConnectionPool(host='192.168.40.40', port=80): Max retries exceeded with url: /csr (Caused by <class 'socket.error'>: [Errno 111] Connection refused) [02/Jan/2017 08:59:28] "POST /api/v1/bts/register HTTP/1.1" 500 129201

kheimerl commented 7 years ago

Yeah your certifier wasn't provisioned correctly. Destroy it from your dev CLI ('vagrant destroy cert') and remake it ('vagrant up cert'). That might help.

brajabasi commented 7 years ago

@kheimerl I have tried the same in my previous message I did reinstall both cloud and client , but issue persists. Please let me know the following points 1) How to verify certifier is running or not ?( Ping is working fine with cert vm box, looks like url: /csr is missing) 2) Please let me know manual installation of cert if possible

kheimerl commented 7 years ago

If supervisor is not installed on the cert VM your issue is with the provisioning.

9muir commented 7 years ago

@brajabasi: please can you try to re-provision just the certifier VM (vagrant provision certin the cloud directory). Post the Vagrant/Ansible output here.

brajabasi commented 7 years ago

facebook@facebook-ThinkPad-T450s:~/fbcode/CommunityCellularManager/cloud$ vagrant provision cert ==> cert: Running provisioner: ansible... cert: Running ansible-playbook... PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit='cert' --inventory-file=/home/facebook/fbcode/CommunityCellularManager/cloud/.vagrant/provisioners/ansible/inventory -v ansible/certifier.dev.yml Using /home/facebook/fbcode/CommunityCellularManager/cloud/ansible.cfg as config file

PLAY [cert] ****

TASK [setup] *** ok: [cert]

TASK [system_packages : Install system packages] *** failed: [cert] (item=[u'ruby', u'ruby-dev']) => {"cache_update_time": 1483338804, "cache_updated": false, "failed": true, "item": ["ruby", "ruby-dev"], "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'ruby-dev'' failed: E: There are problems and -y was used without --force-yes\n", "stderr": "E: There are problems and -y was used without --force-yes\n", "stdout": "Reading package lists...\nBuilding dependency tree...\nReading state information...\nThe following extra packages will be installed:\n ruby1.9.1-dev\nThe following NEW packages will be installed:\n ruby-dev ruby1.9.1-dev\n0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.\nNeed to get 876 kB of archives.\nAfter this operation, 4228 kB of additional disk space will be used.\nWARNING: The following packages cannot be authenticated!\n ruby1.9.1-dev\n", "stdout_lines": ["Reading package lists...", "Building dependency tree...", "Reading state information...", "The following extra packages will be installed:", " ruby1.9.1-dev", "The following NEW packages will be installed:", " ruby-dev ruby1.9.1-dev", "0 upgraded, 2 newly installed, 0 to remove and 7 not upgraded.", "Need to get 876 kB of archives.", "After this operation, 4228 kB of additional disk space will be used.", "WARNING: The following packages cannot be authenticated!", " ruby1.9.1-dev"]} to retry, use: --limit @/home/facebook/fbcode/CommunityCellularManager/cloud/ansible/certifier.dev.retry

PLAY RECAP ***** cert : ok=1 changed=0 unreachable=0 failed=1

Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

9muir commented 7 years ago

The certifier build error is a known bug (see #21) and has been fixed, although it shouldn't affect you if you are just using Vagrant in the standard way. Please update your copy of the GH repo to get that fix and see if that resolves the problem.

brajabasi commented 7 years ago

Thanks Steve Looks like the OpenBTS getting registered successfuly. Could you please check the following log -

[06/Jan/2017 04:55:21] "GET /dashboard/towers HTTP/1.1" 200 21295 [06/Jan/2017 04:55:21] "GET /static/css/dashboard.css HTTP/1.1" 200 8651 [06/Jan/2017 04:58:41] "POST /api/v1/bts/register HTTP/1.1" 200 7758 [06/Jan/2017 04:58:42] "GET /api/v1/bts/sslconf?bts_uuid=1cf28e9f-d710-42cf-9b67-1e6e65bc0fc5 HTTP/1.1" 200 585 [06/Jan/2017 04:58:42] "POST /api/v1/bts/register HTTP/1.1" 200 7758 [06/Jan/2017 04:58:44] "GET /api/v1/bts/sslconf?bts_uuid=1cf28e9f-d710-42cf-9b67-1e6e65bc0fc5 HTTP/1.1" 200 585 [06/Jan/2017 04:58:44] "POST /api/v1/bts/register HTTP/1.1" 200 7758 [06/Jan/2017 04:58:46] "GET /api/v1/bts/sslconf?bts_uuid=1cf28e9f-d710-42cf-9b67-1e6e65bc0fc5 HTTP/1.1" 200 585 [06/Jan/2017 04:58:47] "POST /api/v1/bts/register HTTP/1.1" 200 7758 [06/Jan/2017 04:58:50] "GET /api/v1/bts/sslconf?bts_uuid=1cf28e9f-d710-42cf-9b67-1e6e65bc0fc5 HTTP/1.1" 200 585 [06/Jan/2017 04:58:50] "POST /api/v1/bts/register HTTP/1.1" 200 7758 [06/Jan/2017 04:59:04] "GET /dashboard/towers HTTP/1.1" 200 21295 [06/Jan/2017 04:59:04] "GET /static/css/dashboard.css HTTP/1.1" 304 0 [06/Jan/2017 04:59:15] "GET /dashboard/towers/1cf28e9f-d710-42cf-9b67-1e6e65bc0fc5 HTTP/1.1" 200 6494

9muir commented 7 years ago

That looks like the correct initial set of cloud API calls from the client. After the BTS has completed initialisation processes you should see a sequence of calls like this, repeating every minute (the POST /sason/... calls can be ignored):

[14/Dec/2016 22:17:21] "GET /api/v1/bts/register?bts_uuid=15495b63-[...]ec2d&vpn_ip=10.64.0.6&federer_port=80&vpn_status=up HTTP/1.1" 200 111
[14/Dec/2016 22:17:22] "POST /sason/acquire/ HTTP/1.1" 409 16
[14/Dec/2016 22:17:22] "POST /sason/request/ HTTP/1.1" 200 417
[14/Dec/2016 22:17:22] "POST /sason/acquire/ HTTP/1.1" 200 9
[14/Dec/2016 22:17:22] "POST /api/v1/checkin HTTP/1.1" 200 281
9muir commented 7 years ago

I've updated the client README as of 73e7c3e to strongly suggest that the initial installation of CCM packages is done using apt-get to pull them and their dependencies from our repo. Hopefully this will eliminate these kinds of bootstrapping problems.