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

[ENHANCEMENT] bastille list.sh should change the JID column to be a numeric value #193

Closed
X86BSD opened this issue Apr 12, 2020 · 12 comments
Labels
enhancement New feature or request

Comments

@X86BSD
Copy link
Contributor

X86BSD commented Apr 12, 2020

Doing a 'bastille list' has a column for JID, which currently uses the jails name as it was set during creation.

The problem is that the JID column and the hostname column appear to use the same value.

This seems awkward and the JID imo should be a numeric value. The reason being, when you have really long hostname's doing a 'bastille console reallyreallyreallylonghostname' is horrible and painful. It would be much easier, make more sense, and be more productive to the user to be able to see the numeric value of the JID column for the jail and simply do 'bastile console 4' for instance. Instead of typing in a really long hostname I think most would rather type in a much smaller number to get into the console.

Upon looking into this it seems you just need to drop "-N" from list.sh when jls is called.
I'm not sure why you want to print the "Hostname" twice on output.
What's the reasoning here?

@X86BSD X86BSD added the enhancement New feature or request label Apr 12, 2020
@mariusvw
Copy link
Contributor

To me the reason looks that the jail name is most common to remain static.
The hostname might be the same but it can differ from the jail name.
The JID is dynamic so you shouldn't rely too much on that if searching for a specific jail.

@X86BSD
Copy link
Contributor Author

X86BSD commented Apr 16, 2020

Having the same hostname twice, again is redundant.

Also as I mentioned I don’t want to be typing in entire jail names, in either case, which may be very very long to console into a jail.

Having a numeric value saves a lot of typing to get into a jail via console.

‘Bastille console 4’ beats ‘bastille console verylongjailnamethatidontwantohavetotypeineverysingletimeiwanttogetintotheconsoleofit’.

Seriously this is a usability issue.

@mariusvw
Copy link
Contributor

I understand your point.
Already working on a change.

One thing I do wonder about, is it really needed to use bastille instead of jls in this case?

@hackacad
Copy link
Contributor

Please talk to @cedwards before changing a main functionality.
This was already addressed in #140
We should discuss which functionalities should be changed in what ways (bastille list vs bastille list jails|containers)
(there's some ways, like grepping jails.conf, using jls with different options, ...)

@mariusvw
Copy link
Contributor

@hackacad good that you mentioned that.

Personally I think showing the jail names is a good thing, this matches the default config structure for jails. Other hand, I know when working on running jails using the id's is faster.
As I mentioned before, we should be aware that a jail name is not the hostname. The hostname gets set from the jail name if no hostname is specified.

Since bastille is a wrapper around the jail tools it would be nice to match the commands as close as possible.

My idea for bastile list is to show the jails with id and name and show only the jails owned by bastile. I happen to have 2 seperate jails on an old machine (migrating to bastile) which causes confusion.
This needs to be done carefully not to break the create process where bastile checks if a jail with the requested name already exists.

@X86BSD
Copy link
Contributor Author

X86BSD commented Apr 20, 2020

Marius, that is what I was saying. I think you need both a "jailname" and a numeric "jail id". The former for easily seeing what the jails purpose is i.e "PostgreSQL12.1" the latter for making it much faster to get to the console of said jail. I'm sorry if I didn't make that clear.

@Johanhen
Copy link

Johanhen commented May 22, 2020

If we do a bastille list we get this:

root@test01-head:/usr/local/share/bastille # bastille list
 JID             IP Address      Hostname                      Path
 saltmaster      10.10.89.20     saltmaster                    /usr/local/bastille/jails/saltmaster/root
 haproxy         10.10.89.50     haproxy                       /usr/local/bastille/jails/haproxy/root

This is the same output as jls -N

doing a jls you get

root@test01-head:/usr/local/share/bastille # bastille list
   JID  IP Address      Hostname                      Path
     1  10.10.89.20     saltmaster                    /usr/local/bastille/jails/saltmaster/root
     2  10.10.89.50     haproxy                       /usr/local/bastille/jails/haproxy/root

So you get and the JID and the hostname.

So change jls -N to jls on line 40 in list.sh should give you what you want.

To make sure you can use a numeric in the bastille console command i changed console.sh with the following patch.

--- /usr/local/share/bastille/console.sh        2020-04-15 06:58:11.160706000 +0200
+++ console.sh  2020-05-22 17:17:14.000633000 +0200
@@ -53,8 +53,16 @@
 if [ "${TARGET}" = 'ALL' ]; then
     JAILS=$(jls name)
 fi
+
+if [ -z "${TARGET##*[!0-9]*}" ];
+    then
+        JLS_PARAMETER="name"
+    else
+        JLS_PARAMETER="jid"
+fi
+
 if [ "${TARGET}" != 'ALL' ]; then
-    JAILS=$(jls name | awk "/^${TARGET}$/")
+    JAILS=$(jls ${JLS_PARAMETER} | awk "/^${TARGET}$/")
 fi

 validate_user() {

@X86BSD
Copy link
Contributor Author

X86BSD commented Oct 11, 2020

Jonanhen,

The patch is great! I originally wanted to see about using any part of the hostname like iocage supports. If the hostname was 'PostgreSQL12' one could do P, Po, Pos, etc to console in.

But the jid # is much shorter, and is unique. The way iocage does it is great if you just have a few jails. But if you have 50 instances of 'PostgreSQL12' that kind of ruins using the hostname.

So using the jail ID # is unique and far shorter to get access to the jail. 'bastille console 2048' for instance.

I think that patch works beautifully. Thank you, very much, for that.

Now we just need to change 'jls -N' to 'jls' as the default for 'bastille list'.

@Johanhen
Copy link

Johanhen commented Oct 11, 2020 via email

@bmac2
Copy link
Collaborator

bmac2 commented Oct 19, 2023

fix merged to main branch of bastille. no reason for this patch going forward.

@bmac2 bmac2 closed this as completed Oct 19, 2023
@tobiastom
Copy link
Contributor

@bmac2 Out of curiosity, what has been changed? bastille list still displays the name and for example bastille console $jid does not work.

@tobiastom
Copy link
Contributor

Sorry, I found #612 myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants