xtreme-d / docker-slurm-cluster

Simple Slurm cluster in docker.
MIT License
9 stars 6 forks source link

[SOLVED] What happens on init_slurm_db #8

Closed m0rfeo closed 2 years ago

m0rfeo commented 2 years ago

Hello, in docker-entrypoint.sh to init slurm db the script exec this line:

IS_DATABASE_EXIST="`mysql -h $MARIADB_HOST -u root -p"$MARIADB_ROOT_PASSWORD" -qfsBe "select count(*) as c from information_schema.schemata where schema_name='$MARIADB_DATABASE'" -H | sed -E 's/c|<[^>]+>//g>

What are happening on this part?

select count(*) as c from information_schema.schemata where schema_name='$MARIADB_DATABASE'" -H | sed -E 's/c|<[^>]+>//g>

hackprime commented 2 years ago

@m0rfeo At the first run of the project, the slurmdbd must create a new database on the MariaDB server. and we cannot start slurmdbd it the database isn't ready yet. The part of the script you mentioned ensures that the database already exists. If it doesn't, then the script goes to sleep for five seconds and repeats the existence check.

It may look weird a bit but it's simple.

I am open to suggestions about how to make this part more elegant :)

m0rfeo commented 2 years ago

@hackprime I undestand why you need to do that and i think that is a correct solution don't affect to the integrity and don't create security holes.

But i still dont undestand what you wan't to get with this part sed -E 's/c|<[^>]+>//g>.

Thanks for support and congratulations for your proyect.

hackprime commented 2 years ago

@m0rfeo sed -E 's/c|<[^>]+>//g' removes unnecessary text from the output of the mysql command using the regular expression as a pattern. In other words, having the following output

<TABLE BORDER=1><TR><TH>c</TH></TR><TR><TD>0</TD></TR></TABLE>

it removes all HTML tags (the <[^>]+> part of the regular expression) and the c character (the c part) from the passed string. So, the output of the sed will be:

0
m0rfeo commented 2 years ago

@hackprime Thanks for the explanation!