Re: [Fuego] Jenkins service restart failure after UID:GID change

Dhinakar Kalyanasundaram <[email protected]> Tue, 04 Jan 2022 11:52:18 +0530
Newsgroups dev.linux.lists.fuego
Message-ID <20220104062218epcms5p6efcc8e39ee3fc8506bc478e47aac3536@epcms5p6>
Hi Tim,




Thanks a lot for your prompt response as usual.


Your suggestion to 'check for stray files with ownership issue' worked like a charm.


I just pasted below the sequence of commands inside docker container so that it will be useful to others fuego users.




Objective: To change UID:GID of Jenkins user from '1001' to '1000' inside docker container.




root@team-server:/ # sudo usermod -u 1000 Jenkins (should change jenkins user UID in /etc/passwd)
root@team-server:/ # sudo groupmod -g 1000 Jenkins (should change jenkins user GID in /etc/group)


root@team-server:/ # cd /var/lib/
root@team-server:/var/lib # chown jenkins:jenkins -R jenkins/ (this is to ensure the ownership of any stray files under /var/lib/jenkins user also gets changed)




root@team-server :~# find / -xdev -user 1001 | xargs chown jenkins:jenkins (just to make sure any other files/folders with '1001' ownership gets changed as well)


root@team-server:/var/lib # service jenkins restart
[ ok ] Restarting Jenkins Continuous Integration Server: jenkins.



Jenkins service should get restarted successfully after UID:GID changes.




Regards,


Dhinakar




--------- Original Message ---------


Sender : [email protected] <[email protected]>


Date : 2022-01-04 01:42 (GMT+5:30)


Title : RE: Jenkins service restart failure after UID:GID change


To : Dhinakar Kalyanasundaram<[email protected]>, [email protected]


> -----Original Message-----
> From: Dhinakar Kalyanasundaram <[email protected]>
> 
> Dear Fuego users, Tim,
> 
> Nice to get in touch & post message in this forum after quite sometime.

Good to hear from you. It has been a while. :-)

> 
> I am facing an issue related to file/folder ownership outside and inside docker.
> 
> The ownership of 'fuego-core', 'fuego-ro' & 'fuego-rw' folders and files inside is in my name 'dhinakar' with UID:GID -> 1000:1000 on my
> Linux (Ubuntu 20.04.3 LTS) host.
> 
> Inside docker the ownership of 'fuego-core', 'fuego-ro' & 'fuego-rw' folders and files gets changed to and user whose UID:GID maps to
> 1000:1000, ideally 'jenkins'.
> 
> But unfortunately inside docker my 'jenkins' user has UID:GID -> 1001:1001 so I face permission issues when I access 'fuego-core', 'fuego-
> ro' & 'fuego-rw' folders as 'jenkins' user from the Fuego Dashboard.
> 
> I tried to fix it by changing UID:GID of 'jenkins' user inside docker to 1000:1000 using following commands,
> 
> # usermod -u 1000 jenkins
> # groupmod -g 1000 Jenkins
> 
> and also by directly modifying /etc/passwd file (jenkins:x:1001:1001::/var/lib/jenkins:/bin/bash ->
> jenkins:x:1000:1000::/var/lib/jenkins:/bin/bash)

It possible to miss a few places doing this manually.

I don't see /etc/group mentioned. That needs to be changed (or verified) as well.

Although usermod and groupmod are supposed to change files in a user's home directory, 
they won't catch files outside the home directory. These need to be changed manually.

I would use 'find' to make sure that the there are no stray files or directories owned by user 1001,
throughout the entire file system.

Try this (inside the docker container) to see what stray files with wrong ownership might exist:
$ find / -xdev -user 1001

And use this to change their ownership:
$ find / -xdev -user 1001 | xargs chown jenkins.jenkins

If there are no stray mis-owned files, and you still get an error restarting the Jenkins
service, try looking in the log at /var/log/jenkins/Jenkins.log, to see what the problem
report is.

> 
> And restarted Jenkins service after making the above changes.
> 
> But I got the below error.
> 
> # service jenkins restart
> [FAIL] Restarting Jenkins Continuous Integration Server: jenkins failed!
> 
> Anyone faced similar issues? If so please share your approach to solve this issue.
> 
> 
> 
> Note: I do not want to reinstall fuego or create a new instance as I have lot of data inside current docker instance.
> 
> Also, I do not want to change UID:GID of my ubuntu host 'dhinakar' as it is used across projects and on network.

Understood. Note that some of the data may be re-creatable in a new docker container, using data from your
existing fuego-rw/log directory, by using the 'deorphan-runs.py' script, but let's see if we can get the UID change
implemented before trying something more complicated.

Regards
-- Tim

> 
> 
> 
> Regards,
> 
> Dhinakar
> 
> 
> 
> 
> 
> 
> 
> 
> <http://ext.samsung.net/mail/ext/v1/external/status/update?userid=dhinakar.k&do=bWFpbElEPTIwMjIwMTAzMTkzOTI1ZXBjbXM1cDRkMT
> dhMjViNmJlNTU3Y2VlODZmODUyZTQ5MmVlYjlmYiZyZWNpcGllbnRBZGRyZXNzPVRpbS5CaXJkQHNvbnkuY29t>
(unnamed) (image/gif, 13.1 KB) - not displayed