Libelektra: AsciiNema improvements

Created on 2 Jun 2019  ·  27Comments  ·  Source: ElektraInitiative/libelektra

  • [ ] should work as-is also in docker (sudo?)
  • [ ] kdb editor also for hosts
  • [ ] also show from other language, e.g. python
  • [ ] show YAML
  • [ ] show spec-mount

All 27 comments

I can rerecord everything as it is now to show the error message since it minorly belongs under "my domain" but I do not want to completely instruct a whole yaml, python, specmount example as this is a lot of work to sensefully show a user what elektra can do.

We agreed that only error message related issues belong to me...

I agree that python is not something you worked with. YAML is just an example, not really important. The other things are perfectly in scope.

Ok, but what about "should work as-is also in docker"
I do not understand this point.

Ok, but what about "should work as-is also in docker"
I do not understand this point.

That the tutorial is done inside of docker. So you start the tutorial by pulling a docker image (maybe you can push an alpine Docker image to docker.com which has Elektra 0.9.1 installed so that you do not need to install during the tutorial).

Why would I need to do that in a docker container? I have asciinema local on my system and record it there. All that asciinema emits is a .json file

Why would I need to do that in a docker container? I have asciinema local on my system and record it there.

As first command during the tutorial you pull and enter the docker container. This has the advantage that what is recorded also works for people who want to try out themselves without the need to go through installation.

maybe you can push an alpine Docker image to docker.com which has Elektra 0.9.1 installed so that you do not need to install during the tutorial

Don't we have a docker registry already were jenkins pulls all the containers? If I would push such a docker image to dockerhub then I probably need your account for that so the docker image stays online for the lifetime of elektra.

This should be no problem but can you create a Docker image?

@mpranj did you plan to do such an image for releases?

did you plan to do such an image for releases?

No immediate plans, but sounds like nice to have. I like the idea very much that we publish such an image officially with each release. Elektra is quite a pain to compile and set up for novices.

Ok, can you create an alpine docker image and upload it to a (newly created public?) repo? It would make most sense that you as build master do that :)

can you create an alpine docker image

I can create it but probably not today.

No immediate plans

probably not today.

Ok, so I created it today.

docker run -it elektra/elektra and you are dropped into a shell with kdb available.

Amazing job! Do not forget to advertise it in the next release notes. We should also add this information to the important places for newcomers (@d3nwp).

@mpranj Which plugins did you include in the image? json for example does not exist. If I should include yaml you probably should install one of that.

Btw is sudo not installed in the image but required to mount (actually very weird).

Furthermore: this image is whopping 700 mb big, did you take an alpine version?

Btw is sudo not installed in the image but required to mount (actually very weird).

The image is constructed in a way that you do not need sudo. So simply type as first command (after docker run):

alias sudo= # in this image we do not need to be root

Then "sudo" will not happen in the image but if users try it out on their machine, they will have all the commands that need sudo with sudo.

@Piankero you can inspect the image in #3300 and add suggestions.
Unfortunately:

677.1M  /usr
360.8M  /usr/local/lib/elektra
73.4M   /usr/libexec/gcc
63.1M   /usr/local/bin/kdb

I think actually the image is not constructed such that sudo is not needed, I need to improve that. Or did you try it out?

The image is constructed in a way that you do not need sudo.

docker run -it elektra/elektra           
~ $ kdb mount hello.js /hello ini
 Sorry, 3 warnings were issued ;(
    Sorry, module resolver_fm_hpu_b issued the warning C01100:
    Resource: Could not create configuration file '/etc/kdb/elektra.ecf'. Reason: No such file or directory
    Mountpoint: system/elektra
    Configfile: /etc/kdb/elektra.ecf.8:1575114514.708002.tmp
    At: /opt/elektra/src/plugins/resolver/resolver.c:709
    Sorry, module dump issued the warning C01100:
    Resource: Could not open file /etc/kdb/elektra.ecf.8:1575114514.708002.tmp for writing. Reason: No such file or directory
    Mountpoint: system/elektra
    Configfile: /etc/kdb/elektra.ecf.8:1575114514.708002.tmp
    At: /opt/elektra/src/plugins/dump/dump.cpp:287
    Sorry, module resolver_fm_hpu_b issued the warning C01100:
    Resource: Could not unlink the file '/etc/kdb/elektra.ecf.8:1575114514.708002.tmp'. Reason: No such file or directory
    Mountpoint: system/elektra
    Configfile: /etc/kdb/elektra.ecf.8:1575114514.708002.tmp
    At: /opt/elektra/src/plugins/resolver/resolver.c:1154
Sorry, module resolver_fm_hpu_b issued the error C01100:
Resource: Could not create directory '/etc/kdb'. Reason: Permission denied. Identity: uid: 1000, euid: 1000, gid: 1000, egid: 1000
Mountpoint: system/elektra
Configfile: /etc/kdb/elektra.ecf.8:1575114514.708002.tmp
At: /opt/elektra/src/plugins/resolver/resolver.c:785


IMPORTANT: Sorry, I am unable to write your requested mountpoint to system/elektra/mountpoints.
           You can get the problematic file name by reading the elektra system file (kdb file system/elektra/mountpoints).
           Usually you need to be root for this operation (try `sudo !!`).

@Piankero yes, it is configured incorrectly. Sorry, I'll try to fix it soon!

I tried to simply configure elektra to not write anything outside the user directory, but the tutorial includes things like editing the hosts file as root.

Maybe it makes sense that the image is run as root so these things can be done easily?
Otherwise sudo needs to be set up in the image properly, I don't know if that makes sense.

EDIT: ping also does not work in alpine / busybox without root.

EDIT: another thing that is not available in alpine to my knowledge is xerces, so there is no xmltool :(

EDIT: elektrify-getenv does not work because alpine does not use glibc.

I pushed elektra/elektra:0.9.1-3 which configures kdb to write only in the user homedir.

Since not everything from the AsciiNema tutorial will work on alpine, I'm open for other suggestions.

I tried to simply configure elektra to not write anything outside the user directory, but the tutorial includes things like editing the hosts file as root.

Yes.

Maybe it makes sense that the image is run as root so these things can be done easily?
Otherwise sudo needs to be set up in the image properly, I don't know if that makes sense.

Maybe sudo is better, as all our tutorials use sudo.

e.g. scripts/docker/cirrus/arch/Dockerfile has sudo

EDIT: ping also does not work in alpine / busybox without root.

Not a big deal to not have it (as we also do not have getenv)

EDIT: another thing that is not available in alpine to my knowledge is xerces, so there is no xmltool :(

Not a big deal: then we do not show the xerces plugin. xmltool is deprecated anyway.

EDIT: elektrify-getenv does not work because alpine does not use glibc.

This part we can remove.

Thank you! I will add sudo then!

I pushed elektra/elektra:0.9.1-5 which adds sudo and reduces image size by factor ~100.

@markus2330 Before I record the new tutorial I want you to approve the whole playbook.

Here is the new version:

docker run -it elektra/elektra                                      > NEW LINE

sudo kdb mount hello.js /hello json
kdb set user/hello/hello/world "Hello World"
kdb get user/hello/hello/world  
kdb file user/hello/hello/world
vi /home/elektra/.config/hello.js
# Edit file to say "Hello World from File!"
kdb get user/hello/hello/world
kdb editor user/hello ini
# Edit file to say "Hello World from INI!"
kdb get user/hello/hello/world
kdb export user/hello 
kdb export user/hello tcl
kdb export user/hello yaml                                      > NEW LINE
kdb rm user/hello/hello/world
cat /home/markus/.config/hello.ini     
sudo kdb umount /hello
echo "Now let us change something.. With validation"
vi specification.ini                                       > NEW START
# content:
# []
# mountpoint = specification.ini
# [hostip]
# check/ipaddr =
# [timeout]
# check/range = 0-100
sudo kdb mount /home/elektra/specification.ini spec/validation ni
sudo kdb spec-mount /validation
kdb set /validation/hostip 123.123.123.1233
kdb set /validation/timeout 500
kdb editor spec/validation ni
#edit range to 1000
kdb set /validation/timeout 500
sudo kdb umount spec/validation                                      
kdb rm -r /validation                                           > NEW END
echo "What to do next???"
kdb
kdb --help
kdb --find-tools

Wow, you even scripted it :+1: . I am already looking forward to the result.

Can you put the script into a PR so that we can discuss line-by-line?

At first glance I notice:

  • many more echo would be helpful (it gives the reader more time to realize what is happening)
  • the specification is better to be built up step by step, not everything at once
  • did you see the demo in https://archive.fosdem.org/2018/schedule/event/elektra/
  • hosts plugin is missing (so that implicit validation without a specification is shown)

Btw. I just read that https://github.com/dhobsd/castty supports audio :wink:

Can you put the script into a PR so that we can discuss line-by-line?

https://github.com/ElektraInitiative/libelektra/pull/3320

I mark this issue stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping the issue by writing a message here or create a new issue with the remainder of this issue.
Thank you for your contributions :sparkling_heart:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mpranj picture mpranj  ·  4Comments

markus2330 picture markus2330  ·  4Comments

sanssecours picture sanssecours  ·  3Comments

sanssecours picture sanssecours  ·  4Comments

mpranj picture mpranj  ·  3Comments