Bug 1482800

Summary: hostnamectl report "Could not set property: Connection timed out"
Product: Red Hat Enterprise Linux 7 Reporter: chen zhen <zhechen>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: chaitu2k6, dwojewod, jsynacek, ktordeur, rmetrich, systemd-maint-list, systemd-maint, zhechen
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-07-30 10:00:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description chen zhen 2017-08-18 06:15:55 UTC
Description of problem:


Version-Release number of selected component (if applicable):
systemd-sysv-219-30.el7_3.9.x86_64
systemd-219-30.el7_3.9.x86_64
systemd-libs-219-30.el7_3.9.x86_64

How reproducible:
70% 

Steps to Reproduce:
1.echo "hostnamectl set-hostname cloud-compute-1946.cloud.baby.cn >> /root/hostname.log 2>&1" >> /etc/rc.local
2. chmod +x /etc/rc.d/rc.local
3.reboot
4.it failed to set the hostname ,and cat /root/hostname.log:
Could not set property: Connection timed out

Actual results:
Failed to set hostname

Expected results:
Succeed in setting new hostname

Additional info:

Comment 2 Jan Synacek 2017-08-18 08:07:42 UTC
(In reply to chen zhen from comment #0)
> Steps to Reproduce:
> 1.echo "hostnamectl set-hostname cloud-compute-1946.cloud.baby.cn >>
> /root/hostname.log 2>&1" >> /etc/rc.local
> 2. chmod +x /etc/rc.d/rc.local
> 3.reboot

Why are you doing it like this? Please don't mix systemd's commands and initscripts like this. If you just do the "hostnamectl set-hostname cloud-compute-1946.cloud.baby.cn", then your hostname stays set, provided that nothing else set it elsewhere.

Comment 5 Jan Synacek 2018-07-30 10:00:10 UTC
This bugzilla complete escaped me, since it was last proposed for rhel-7.5. As I hinted in comment 2, it's a user error.

Comment 6 smanne 2018-09-19 18:43:09 UTC
Folks,

these answers are not helpful and there are multiple other bugs opened for the same issue.

Below is the fix that worked for me.

from the below output of systemctl status command, I noticed that /tmp was not mounted with proper acls.

sudo-sh[root@myhost]# hostnamectl set-hostname --static $dnsname
Could not set property: Connection timed out
sudo-sh[root@myhost]# hostnamectl set-hostname poc-rhel-cassandra-b1
Could not set property: Failed to activate service 'org.freedesktop.hostname1': timed out



sudo-sh[root@myhost]# systemctl status systemd-hostnamed
● systemd-hostnamed.service - Hostname Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-hostnamed.service; static; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-hostnamed.service(8)
           man:hostname(5)
           man:machine-info(5)
           http://www.freedesktop.org/wiki/Software/systemd/hostnamed

Sep 19 13:52:53 myhost systemd[1]: Dependency failed for Hostname Service.
Sep 19 13:52:53 myhost systemd[1]: Job systemd-hostnamed.service/start failed with result 'dependency'.
Sep 19 13:54:02 myhost systemd[1]: Dependency failed for Hostname Service.
Sep 19 13:54:02 myhost systemd[1]: Job systemd-hostnamed.service/start failed with result 'dependency'.
Sep 19 13:55:18 myhost systemd[1]: Dependency failed for Hostname Service.
Sep 19 13:55:18 myhost systemd[1]: Job systemd-hostnamed.service/start failed with result 'dependency'.

sudo-sh[root@myhost]# systemctl restart systemd-hostnamed
A dependency job for systemd-hostnamed.service failed. See 'journalctl -xe' for details.
sudo-sh[root@myhost]# journalctl -xe
-- Unit user-0.slice has finished shutting down.
Sep 19 13:56:01 myhost systemd[1]: Stopping User Slice of root.
-- Subject: Unit user-0.slice has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user-0.slice has begun shutting down.
Sep 19 13:56:03  sudo-sh[12198]: ec2-user : HOST=myhost : TTY=pts/0 ; PWD=/home/ec2-user ; USER=root ; SUDO-SH-COMMAND=systemctl
Sep 19 13:56:29  sudo-sh[12199]: ec2-user : HOST=myhost : TTY=pts/0 ; PWD=/home/ec2-user ; USER=root ; SUDO-SH-COMMAND=systemctl
Sep 19 13:56:29  polkitd[624]: Registered Authentication Agent for unix-process:12199:22680 (system bus name :1.39 [/usr/bin/pkttyagent --
Sep 19 13:56:29  systemd[1]: Mounting /var/tmp...
-- Subject: Unit var-tmp.mount has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit var-tmp.mount has begun starting up.
Sep 19 13:56:29  mount[12205]: mount:  /tmp is not a block device
Sep 19 13:56:29  systemd[1]: var-tmp.mount mount process exited, code=exited status=32
Sep 19 13:56:29  systemd[1]: Failed to mount /var/tmp.
-- Subject: Unit var-tmp.mount has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit var-tmp.mount has failed.
--
-- The result is failed.
Sep 19 13:56:29  systemd[1]: Dependency failed for Hostname Service.
-- Subject: Unit systemd-hostnamed.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-hostnamed.service has failed.
--
-- The result is dependency.
Sep 19 13:56:29  systemd[1]: Job systemd-hostnamed.service/start failed with result 'dependency'.
Sep 19 13:56:29  systemd[1]: Unit var-tmp.mount entered failed state.
Sep 19 13:56:29  polkitd[624]: Unregistered Authentication Agent for unix-process:12199:22680 (system bus name :1.39, object path /org/fre
Sep 19 13:56:36  sudo-sh[12207]: ec2-user : HOST=myhost : TTY=pts/0 ; PWD=/home/ec2-user ; USER=root ; SUDO-SH-COMMAND=journalctl



to resolve this issue, I edited /etc/fstab and changed the /tmp acls.

Before
#/tmp /var/tmp auto rw,nodev,nofail,nosuid,relatime 0 0

After
/tmp /var/tmp auto bind 0 0


make sure to make a copy of your original fstab file before editing, then restart the server.

Now hostname service started fine.

sudo-sh[root@myhost]# systemctl status systemd-hostnamed
● systemd-hostnamed.service - Hostname Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-hostnamed.service; static; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-hostnamed.service(8)
           man:hostname(5)
           man:machine-info(5)
           http://www.freedesktop.org/wiki/Software/systemd/hostnamed

Sep 19 14:16:45  systemd[1]: Starting Hostname Service...
Sep 19 14:16:45  systemd[1]: Started Hostname Service.

Also hostnamectl set-hostname command worked as expected.

sudo-sh[root@myhost]# dnsname=`ifconfig eth0|grep netmask|awk '{print $2}'|while read addr; do host $addr|awk '{print $NF}'|sed 's/.$//'; done`
sudo-sh[root@myhost]# hostnamectl set-hostname --static $dnsname
sudo-sh[root@myhost]# hostnamectl status|grep Static
   Static hostname: poc-rhel-cassandra-b1