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

[Bug]: why does netclient.service wait for 17 seconds? #3019

Open
1 task done
mfide opened this issue Jul 25, 2024 · 1 comment
Open
1 task done

[Bug]: why does netclient.service wait for 17 seconds? #3019

mfide opened this issue Jul 25, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mfide
Copy link

mfide commented Jul 25, 2024

I have netclient v0.24.2 runs on Ubuntu 24.04 server.

When I run systemd-analyze blame to see the slowest services in my system, I get following list:

17.069s netclient.service
 7.630s systemd-networkd-wait-online.service
 2.251s fwupd-refresh.service
 2.109s fwupd.service
 1.101s lvm2-monitor.service
  854ms docker.service
  775ms snapd.seeded.service
  695ms snapd.service
..
..

netclient.service is the top1 in this list.
Then I check the content of /etc/systemd/system/netclient.service file:

[Unit]
Description=Netclient Daemon
Documentation=https://docs.netmaker.org https://k8s.netmaker.org
After=network-online.target
Wants=network-online.target

[Service]
User=root
Type=simple
ExecStartPre=/bin/sleep 17
ExecStart=/sbin/netclient daemon
Restart=on-failure
RestartSec=15s

[Install]
WantedBy=multi-user.target

There is a PreStart script which waits for 17 seconds as hard coded for nothing in the netclient.service file.
According to the blame list above, my system becomes online in 7 seconds (systemd-networkd-wait-online service).

Why does netclient service has this 17 second sleep time?

Thank you.

Version

v0.24.2

What OS are you using?

Linux

Relevant log output

No response

Contributing guidelines

  • Yes, I did.
@mfide mfide added the bug Something isn't working label Jul 25, 2024
@mfide mfide changed the title [Bug]: why does netclient.service waits for 17 seconds? [Bug]: why does netclient.service wait for 17 seconds? Jul 25, 2024
@Cirr0e
Copy link

Cirr0e commented Nov 28, 2024

Hi there! I can help explain why this delay exists and what we can do about it.

Looking at your service file, that 17-second sleep delay is actually a legacy workaround from earlier versions of netclient. It was originally implemented to ensure network services were fully initialized before starting netclient, but this approach has been largely superseded by better handling in newer versions.

Since you're running v0.24.2 and your system shows network-online is achieved in ~7.6 seconds, this delay is unnecessarily long. The service file already has the proper dependencies:

After=network-online.target
Wants=network-online.target

You can safely modify this by:

  1. Creating an override file:
sudo systemctl edit netclient.service
  1. Add these lines to reduce or remove the delay:
[Service]
ExecStartPre=
ExecStartPre=/bin/sleep 5

This will override the original 17-second sleep with a more reasonable 5-second delay. I'm suggesting 5 seconds rather than removing it entirely just to provide a small buffer after network-online.target is reached.

References:

Important considerations:

  • If you experience any network connectivity issues after reducing the delay, you can adjust the sleep time accordingly
  • Make sure to test the changes during a maintenance window
  • Use systemctl restart netclient to apply the changes

Let me know if you need any clarification or run into any issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants