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

seems like logs.py in agent is missing #113

Closed
chenull opened this issue Jul 3, 2021 · 12 comments
Closed

seems like logs.py in agent is missing #113

chenull opened this issue Jul 3, 2021 · 12 comments
Assignees
Labels
bug Something isn't working prio:medium

Comments

@chenull
Copy link

chenull commented Jul 3, 2021

hi.. tried to install manually kraken agent in rocky linux. there are 2 issues:

  1. rocky linux is not supported yet in upstream distro python package
  2. logs.py is missing
ayik@rokiroki ~ $ kkagent
Traceback (most recent call last):
  File "/home/ayik/.local/bin/kkagent", line 11, in <module>
    load_entry_point('kraken-agent==0.567', 'console_scripts', 'kkagent')()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/ayik/.local/lib/python3.8/site-packages/kraken_agent-0.567-py3.8.egg/kraken/agent/main.py", line 23, in <module>
    from . import logs
ImportError: cannot import name 'logs' from 'kraken.agent' (/home/ayik/.local/lib/python3.8/site-packages/kraken_agent-0.567-py3.8.egg/kraken/agent/__init__.py)
ayik@rokiroki ~ $
@chenull
Copy link
Author

chenull commented Jul 3, 2021

oops.. rocky linux is supported indeed from upstream distro:

ayik@rokiroki ~ $ ipython
Python 3.8.6 (default, Jun 29 2021, 21:14:45)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.25.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import distro

In [2]: dstr = distro.id()

In [3]: dstr
Out[3]: 'rocky'

so i think this line should be:

elif dstr in ['fedora', 'centos', 'rocky']:

godfryd added a commit that referenced this issue Jul 4, 2021
@godfryd
Copy link
Contributor

godfryd commented Jul 4, 2021

I have added rocky. And will do a release shortly.

How did you try to install the Kraken agent? Did you follow the instruction from https://kraken.ci/docs/?

@chenull
Copy link
Author

chenull commented Jul 4, 2021

How did you try to install the Kraken agent? Did you follow the instruction from https://kraken.ci/docs/?

i tried to install using the instruction from the docs and got:

    raise Exception('distro %s is not supported yet' % dstr)  # pylint: disable=raise-missing-from
Exception: distro rocky is not supported yet
ayik@rokiroki ~ $

that's why i tried to install manually using python setup.py install from the git repo in agent/ folder

@godfryd
Copy link
Contributor

godfryd commented Jul 4, 2021

I just made a release: https://github.com/Kraken-CI/kraken/releases/tag/v0.645.
Please try it. If you encounter any other problems then let me know. I will try to resolve them.

that's why i tried to install manually using python setup.py install from the git repo in agent/ folder

this will not work as some source files are copied from other folders while setup.py does not know that

@godfryd godfryd added bug Something isn't working prio:medium labels Jul 4, 2021
@godfryd godfryd self-assigned this Jul 4, 2021
@chenull
Copy link
Author

chenull commented Jul 4, 2021

upgraded to 0.645 and here some issues:

  • running as regular user, got some error installing complaining path / permission in /opt/kraken/. fixed with adding sudo in this line
  • the env file /opt/kraken/kraken.env is not populated with KRAKEN_CLICKHOUSE_ADDR and KRAKEN_MINIO_ADDR althoug i have them set up in the admin page. edited manually and now the agent can be discovered

@godfryd
Copy link
Contributor

godfryd commented Jul 4, 2021

running as regular user, got some error installing complaining path / permission in /opt/kraken/. fixed with adding sudo in this line

sudo shouldn't be required on this level, kkagent uses sudo internally but there might be some missing places. Do you have logs with this error?

the env file /opt/kraken/kraken.env is not populated with KRAKEN_CLICKHOUSE_ADDR and KRAKEN_MINIO_ADDR

it seems that I do not pass them correctly, I will fix that in a moment

@chenull
Copy link
Author

chenull commented Jul 4, 2021

sudo shouldn't be required on this level, kkagent uses sudo internally but there might be some missing places. Do you have logs with this error?

ayik@rokiroki ~/srv $ ./kraken-agent-install.sh
+ KRAKEN_URL=http://192.168.1.83:8080/
+ sudo -n true
+ '[' 0 -ne 0 ']'
+ python3 --version
Python 3.8.6
+ '[' 0 -ne 0 ']'
+ DL_TOOL=
+ which curl
/usr/bin/curl
+ '[' 0 -ne 0 ']'
+ DL_TOOL=curl
+ set -e
+ '[' curl == wget ']'
+ curl -o /tmp/kkagent http://192.168.1.83:8080/install/agent
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1341k  100 1341k    0     0  93.5M      0 --:--:-- --:--:-- --:--:-- 93.5M
+ chmod a+x /tmp/kkagent
+ /tmp/kkagent install -s http://192.168.1.83:8080/
2021-07-04 17:46:29,543 INFO p:30687     logs:211   setup logging on agent to clickhouse: localhost:9001
2021-07-04 17:46:29,544 INFO p:30687     main:40    Starting Kraken Agent, version 0.645
ln: failed to create symbolic link '/opt/kraken/kkagent': Permission denied
Traceback (most recent call last):
  File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/kkagent/__main__.py", line 3, in <module>
  File "/tmp/kkagent/_bootstrap/__init__.py", line 244, in bootstrap
  File "/tmp/kkagent/_bootstrap/__init__.py", line 39, in run
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/kraken/agent/main.py", line 69, in install
    inst.install()
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/kraken/agent/install.py", line 149, in install
    install_linux()
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/kraken/agent/install.py", line 131, in install_linux
    update.make_links_to_new_binaries(dest_dir)
  File "/home/ayik/.shiv/kkagent_2f8df2cb94cc4e623461f432f75f2eb59f694dc042e5a3364d457a0e0e698d59/site-packages/kraken/agent/update.py", line 67, in make_links_to_new_binaries
    subprocess.run(cmd, shell=True, check=True)
  File "/usr/lib64/python3.8/subprocess.py", line 512, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'ln -s /opt/kraken/0.645/kkagent /opt/kraken/kkagent' returned non-zero exit status 1

with sudo:

ayik@rokiroki ~/srv $ vi kraken-agent-install.sh
ayik@rokiroki ~/srv $ sudo /tmp/kkagent install -s http://192.168.1.83:8080/
2021-07-04 17:49:33,729 INFO p:30857     logs:211   setup logging on agent to clickhouse: localhost:9001
2021-07-04 17:49:33,730 INFO p:30857     main:40    Starting Kraken Agent, version 0.645
Created symlink /etc/systemd/system/multi-user.target.wants/kraken-agent.service → /usr/lib/systemd/system/kraken-agent.service.
● kraken-agent.service - Kraken Agent
   Loaded: loaded (/usr/lib/systemd/system/kraken-agent.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2021-07-04 17:49:34 WIB; 69ms ago
 Main PID: 30931 (python3)
    Tasks: 1 (limit: 23484)
   Memory: 3.9M
   CGroup: /system.slice/kraken-agent.service
           └─30931 python3 /opt/kraken/kkagent run

Jul 04 17:49:34 rokiroki.local systemd[1]: Started Kraken Agent.

i think it's because ln -s should be ln -fs

godfryd added a commit that referenced this issue Jul 4, 2021
- fixed passing minio and clickhouse addresses
- fixed permissions issues
@godfryd
Copy link
Contributor

godfryd commented Jul 4, 2021

Ok, I have fixed both issues and made a release: 0.647. Could you check it?

@chenull
Copy link
Author

chenull commented Jul 7, 2021

since the user who install the script is different from user kraken, os.unlink failed:

  File "/home/ayik/.shiv/kkagent_cc8cf5fc62456cb4e5c44e4739a7df09c81b43b140dd0ba4c8cec16ead29ac25/site-packages/kraken/agent/update.py", line 65, in make_links_to_new_binaries
    os.unlink('/opt/kraken/kkagent')
PermissionError: [Errno 13] Permission denied: '/opt/kraken/kkagent'
ayik@rokiroki ~/srv $ whoami
ayik
ayik@rokiroki ~/srv $ ls -al /opt/kraken/kkagent
lrwxrwxrwx 1 kraken kraken 25 Jul  4 17:49 /opt/kraken/kkagent -> /opt/kraken/0.645/kkagent
ayik@rokiroki ~/srv $

using sudo to change uid to kraken, everything is worked fine.

i think all file operation should be done using sudo, or the documentation should tell to use kraken to install the agent

@godfryd
Copy link
Contributor

godfryd commented Jul 8, 2021

Ok, I fixed this problem too and made a release: 0.664. Could you check it?

@chenull
Copy link
Author

chenull commented Jul 8, 2021

ok. it fixed. thank for your good work.

ayik@rokiroki ~/srv $ ./kraken-agent-install.sh
+ KRAKEN_URL=http://192.168.1.83:8080/
+ sudo -n true
+ '[' 0 -ne 0 ']'
+ python3 --version
Python 3.8.6
+ '[' 0 -ne 0 ']'
+ DL_TOOL=
+ which curl
/usr/bin/curl
+ '[' 0 -ne 0 ']'
+ DL_TOOL=curl
+ set -e
+ '[' curl == wget ']'
+ curl -o /tmp/kkagent http://192.168.1.83:8080/install/agent
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1341k  100 1341k    0     0  81.8M      0 --:--:-- --:--:-- --:--:-- 81.8M
+ chmod a+x /tmp/kkagent
+ export KRAKEN_MINIO_ADDR=192.168.1.83:9999
+ KRAKEN_MINIO_ADDR=192.168.1.83:9999
+ export KRAKEN_CLICKHOUSE_ADDR=192.168.1.83:8123
+ KRAKEN_CLICKHOUSE_ADDR=192.168.1.83:8123
+ /tmp/kkagent install -s http://192.168.1.83:8080/
2021-07-08 21:39:10,038 INFO p:106633     logs:211   setup logging on agent to clickhouse: 192.168.1.83:8123
2021-07-08 21:39:10,039 INFO p:106633     main:40    Starting Kraken Agent, version 0.664
● kraken-agent.service - Kraken Agent
   Loaded: loaded (/usr/lib/systemd/system/kraken-agent.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2021-07-08 21:39:11 WIB; 63ms ago
 Main PID: 106719 (python3)
    Tasks: 1 (limit: 23484)
   Memory: 3.9M
   CGroup: /system.slice/kraken-agent.service
           └─106719 python3 /opt/kraken/kkagent run

Jul 08 21:39:11 rokiroki.local systemd[1]: Started Kraken Agent.
+ rm -f /tmp/kkagent
+ echo 'Kraken Agent installed'
Kraken Agent installed

@godfryd
Copy link
Contributor

godfryd commented Jul 8, 2021

Great! Thanks for testing.
So I'm closing the issue.

If you any further concerns we could continue the discussion on Google Groups: https://groups.google.com/g/kraken-ci

@godfryd godfryd closed this as completed Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prio:medium
Projects
None yet
Development

No branches or pull requests

2 participants