ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.84k stars 901 forks source link

Prometheus plugin - unknown parameter: spent #4380

Closed zefir01 closed 3 years ago

zefir01 commented 3 years ago

Issue and Steps to Reproduce

Version

c-lightning v0.9.2 allow-deprecated-apis=false

Dockerfile

FROM debian:stable-slim AS builder_btc WORKDIR /opt RUN apt update RUN apt install -y git build-essential libtool \ autotools-dev automake pkg-config bsdmainutils python3 libevent-dev \ libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev \ libzmq3-dev libdb++-dev && apt-get clean all RUN git clone https://github.com/bitcoin/bitcoin.git && cd bitcoin WORKDIR /opt/bitcoin RUN git checkout 0.21 RUN mkdir build && ./autogen.sh && ./autogen.sh && ./configure --with-incompatible-bdb \ && make -j $(nproc) && make install DESTDIR=/opt/bitcoin/build

FROM debian:stable-slim AS builder WORKDIR /opt RUN apt-get update && apt-get install -y lsb-release wget \ autoconf automake build-essential git libtool libgmp-dev libsqlite3-dev python3 python3-mako \ net-tools zlib1g-dev libsodium-dev gettext libpq-dev socat inotify-tools python3 python3-dev python3-pip \ libffi-dev libleveldb-dev python2 python-pip python-dev build-essential && apt-get clean all

RUN git clone https://github.com/ElementsProject/lightning.git && cd lightning WORKDIR /opt/lightning RUN git checkout v0.9.2 RUN mkdir build && ./configure && make -j 8 && make install DESTDIR=/opt/lightning/build \ && cp devtools/bolt11-cli /opt/lightning/build/usr/local/bin/ RUN git clone https://github.com/talaia-labs/python-teos.git && cd python-teos && git checkout v0.1.1 COPY requirements.txt ./python-teos/watchtower-plugin/ RUN mkdir plugins2 && cd plugins2 && git clone https://github.com/lightningd/plugins.git

FROM python:3-buster as prod RUN apt update && apt install -y libsqlite3-0 libpq5 libsodium23 libleveldb-dev libboost-system1.67.0 libboost-filesystem1.67.0 libboost-test1.67.0 \ libboost-thread1.67.0 libevent-2.1-6 libdb5.3++ libevent-pthreads-2.1-6 libzmq5 gettext-base socat inotify-tools && apt-get clean all WORKDIR /opt COPY --from=builder_btc /opt/bitcoin/build/ /usr/ COPY --from=builder /opt/lightning/build/ /usr/ COPY --from=builder /opt/lightning/python-teos/watchtower-plugin /watchtower-plugin COPY --from=builder /opt/lightning/plugins2/plugins/prometheus /prometheus RUN cd /watchtower-plugin/ && pip3 install -r requirements.txt RUN cd /prometheus && pip3 install -r requirements.txt COPY entrypoint.sh / RUN chmod +x /entrypoint.sh

COPY config.prod /config

EXPOSE 9735 9835 5000 9750

ENV LIGHTNINGD_DATA /root/.lightning ENV EXPOSE_TCP true ENV LIGHTNINGD_NETWORK testnet ENV LIGHTNINGD_RPC_PORT 9835 COPY ./tini /tini RUN chmod +x /tini ENTRYPOINT ["/tini", "--"] CMD ["/entrypoint.sh", "--conf=/config.run", "--plugin", "/watchtower-plugin/watchtower.py", "--plugin", "/prometheus/prometheus.py", "--autocleaninvoice-cycle", "600", "--autocleaninvoice-expired-by", "3600"]

StackTrace

2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: ---------------------------------------- 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: Exception occurred during processing of request from ('10.0.6.4', 33674) 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: Traceback (most recent call last): 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/socketserver.py\", line 650, in process_request_thread 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: self.finish_request(request, client_address) 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/socketserver.py\", line 360, in finish_request 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: self.RequestHandlerClass(request, client_address, self) 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/socketserver.py\", line 720, in init 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: self.handle() 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/http/server.py\", line 427, in handle 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: self.handle_one_request() 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/http/server.py\", line 415, in handle_one_request 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: method() 2021-02-08T14:59:05.745Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/site-packages/prometheus_client/exposition.py\", line 151, in do_GET 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: output = encoder(registry) 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/site-packages/prometheus_client/openmetrics/exposition.py\", line 14, in generate_latest 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: for metric in registry.collect(): 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/site-packages/prometheus_client/registry.py\", line 75, in collect 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: for metric in collector.collect(): 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: File \"/prometheus/prometheus.py\", line 45, in collect 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: funds = self.rpc.listfunds() 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/site-packages/pyln/client/lightning.py\", line 924, in listfunds 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: return self.call(\"listfunds\", payload) 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: File \"/usr/local/lib/python3.9/site-packages/pyln/client/lightning.py\", line 387, in call 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: raise RpcError(method, payload, resp['error']) 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: pyln.client.lightning.RpcError: RPC call failed: method: listfunds, payload: {'spent': False}, error: {'code': -32602, 'message': 'unknown parameter: spent'} 2021-02-08T14:59:05.746Z UNUSUAL plugin-prometheus.py: ----------------------------------------

When

The error appears during a request for metrics by Prometheus.

getinfo output

{ "id": ------------------------------------------", "alias": "-----------------------------------------------

", "color": "03dfdc", "num_peers": 0, "num_pending_channels": 0, "num_active_channels": 0, "num_inactive_channels": 0, "address": [ { "type": "torv3", "address": "-------------------------------------------------------------", "port": 9735 } ], "binding": [ { "type": "ipv4", "address": "0.0.0.0", "port": 9735 } ], "version": "v0.9.2", "blockheight": 669717, "network": "bitcoin", "msatoshi_fees_collected": 0, "fees_collected_msat": "0msat", "lightning-dir": "/root/.lightning/bitcoin" }

zefir01 commented 3 years ago
pip3 download pyln-client==0.9.3
unzip pyln_client-0.9.3-py3-none-any.whl
user@ws1:~/tmp$ grep spent pyln/client/lightning.py
    def listfunds(self, spent=False):
        or both unspent and spent funds if {spent} is True.
            "spent": spent
git clone https://github.com/ElementsProject/lightning.git
cd lightning/
git checkout v0.9.2
Note: switching to 'v0.9.2'.
user@ws1:~/tmp/lightning$ grep spent contrib/pyln-client/pyln/client/lightning.py 
user@ws1:~/tmp/lightning$ 
user@ws1:~/tmp$ unzip pyln_client-0.9.2-py3-none-any.whl 
Archive:  pyln_client-0.9.2-py3-none-any.whl
replace pyln/client/__init__.py? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
  inflating: pyln/client/__init__.py  
replace pyln/client/lightning.py? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
  inflating: pyln/client/lightning.py  
  inflating: pyln/client/nodes.py    
  inflating: pyln/client/plugin.py   
  inflating: pyln_client-0.9.2.dist-info/METADATA  
  inflating: pyln_client-0.9.2.dist-info/WHEEL  
  inflating: pyln_client-0.9.2.dist-info/top_level.txt  
  inflating: pyln_client-0.9.2.dist-info/zip-safe  
  inflating: pyln_client-0.9.2.dist-info/RECORD  
user@ws1:~/tmp$ grep spent pyln/client/lightning.py
user@ws1:~/tmp$ 
zefir01 commented 3 years ago

I got it. excuse me.

cdecker commented 3 years ago

That'd mean that the prometheus dependencies should be updated to pyln-client==0.9.3 too, thanks for pointing this out :+1: