Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-29496

Windows service: Add support of the Delayed Start option

    Details

    • Similar Issues:

      Description

      Currently the service starts in the "Automatic" mode, so there can be conflicts with other services like login service, shared directory mappers, etc. "Automatic (Delayed start)" could resolve this issue by allowing other services to start before Jenkins master/slave starts the initialization.

      The change requires https://github.com/kohsuke/winsw/releases/tag/winsw-1.17 at least (not merged into Jenkins core)

        Attachments

          Issue Links

            Activity

            oleg_nenashev Oleg Nenashev created issue -
            Hide
            teilo James Nord added a comment -

            The service should not use delayed start as this will slow down the startup of Jenkins.

            If anything the service dependencies should be set correctly - but how do you know that you need the "Workstation" service only if you are running on a shared home/workspace.
            Some installations may have disabled this for security.

            A delayed start by default (IIRC) will keep a salve offline for 2 minutes. AFAICT there is only a global setting for delayed start and changing this will affect services other than Jenkins.

            Show
            teilo James Nord added a comment - The service should not use delayed start as this will slow down the startup of Jenkins. If anything the service dependencies should be set correctly - but how do you know that you need the "Workstation" service only if you are running on a shared home/workspace. Some installations may have disabled this for security. A delayed start by default (IIRC) will keep a salve offline for 2 minutes. AFAICT there is only a global setting for delayed start and changing this will affect services other than Jenkins.
            Hide
            teilo James Nord added a comment -

            this implies that we should not be using winsw to install itself, but Jenkins should install itself ant it needs to tweak the options depending on if the slave/master has been configured with any UNC paths - or that if you use UNC etc etc that you need to update the dependencies with

            sc config nameOfJenkinsService depend= nameOfServiceAYouDependOn/nameOfServiceAYouDependOn
            Show
            teilo James Nord added a comment - this implies that we should not be using winsw to install itself, but Jenkins should install itself ant it needs to tweak the options depending on if the slave/master has been configured with any UNC paths - or that if you use UNC etc etc that you need to update the dependencies with sc config nameOfJenkinsService depend= nameOfServiceAYouDependOn/nameOfServiceAYouDependOn
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            @James
            I agree that the delayed start may cause additional delays, but...

            • There is one well-known use-case with shared directories
            • Another known use case is a Windows event system, which starts as a service. If Jenkins starts before it, we may lose events in monitoring systems
            • There is a potential risk for user jobs, because currently Jenkins may start executing them on slave machines without fully initialized services => undefined behavior even for standard Windows CLI tools

            My opinion is that the "Delayed start" should be enabled by default. If a user knows what he is doing, he can switch the mode an set dependencies on other services. Would you agree with such approach?

            > A delayed start by default (IIRC) will keep a slave offline for 2 minutes. AFAICT there is only a global setting for delayed start and changing this will affect services other than Jenkins.

            No, Windows will start "delayed" services shortly after starting other ones with automatic start. AFAIK there's no hardcoded timeout.

            > this implies that we should not be using winsw to install itself

            Service startup mode can be passed via the configuration XML file, which is being used to instal the Jenkins service

            Show
            oleg_nenashev Oleg Nenashev added a comment - @James I agree that the delayed start may cause additional delays, but... There is one well-known use-case with shared directories Another known use case is a Windows event system, which starts as a service. If Jenkins starts before it, we may lose events in monitoring systems There is a potential risk for user jobs, because currently Jenkins may start executing them on slave machines without fully initialized services => undefined behavior even for standard Windows CLI tools My opinion is that the "Delayed start" should be enabled by default. If a user knows what he is doing, he can switch the mode an set dependencies on other services. Would you agree with such approach? > A delayed start by default (IIRC) will keep a slave offline for 2 minutes. AFAICT there is only a global setting for delayed start and changing this will affect services other than Jenkins. No, Windows will start "delayed" services shortly after starting other ones with automatic start. AFAIK there's no hardcoded timeout. > this implies that we should not be using winsw to install itself Service startup mode can be passed via the configuration XML file, which is being used to instal the Jenkins service
            Hide
            teilo James Nord added a comment -

            No, Windows will start "delayed" services shortly after starting other ones with automatic start. AFAIK there's no hardcoded timeout.

            Nope - there is a system wide setting (at least in some versions of Windows) and it defaults to 120 seconds.

            HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\AutoStartDelay

            • There is one well-known use-case with shared directories
            • Another known use case is a Windows event system, which starts as a service. If Jenkins starts before it, we may lose events in monitoring systems
            • There is a potential risk for user jobs, because currently Jenkins may start executing them on slave machines without fully initialized services => undefined behavior even for standard Windows CLI tools

            Which is why I said you need to install the service with dependencies set, not delayed start. If Jenkins needs service X to be alive it should have a dependency on it to ensure it is started after that service.
            The result is the service will still start after the services it needs are started, but it will not be artificially delayed but the AutoStartDelay.

            You need shared directories - add a service dependency on Workstation, you need the event system (you shouldn't), depend on EventLog, you need to make sure antivirus is running add a dependency on WinDefend etc etc...

            Show
            teilo James Nord added a comment - No, Windows will start "delayed" services shortly after starting other ones with automatic start. AFAIK there's no hardcoded timeout. Nope - there is a system wide setting (at least in some versions of Windows) and it defaults to 120 seconds . HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\AutoStartDelay There is one well-known use-case with shared directories Another known use case is a Windows event system, which starts as a service. If Jenkins starts before it, we may lose events in monitoring systems There is a potential risk for user jobs, because currently Jenkins may start executing them on slave machines without fully initialized services => undefined behavior even for standard Windows CLI tools Which is why I said you need to install the service with dependencies set , not delayed start. If Jenkins needs service X to be alive it should have a dependency on it to ensure it is started after that service. The result is the service will still start after the services it needs are started, but it will not be artificially delayed but the AutoStartDelay. You need shared directories - add a service dependency on Workstation , you need the event system (you shouldn't), depend on EventLog , you need to make sure antivirus is running add a dependency on WinDefend etc etc...
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            I still think that a default delayed start would be preferable for users, who would like to get a working infrastructure out-of-the-box. All service configuration steps may require much time from users, who have no appropriate qualification.

            My proposals:

            • Enable "Delayed start" by default
            • Add a Wiki page describing Windows service configuration for "Advanced" users
            Show
            oleg_nenashev Oleg Nenashev added a comment - I still think that a default delayed start would be preferable for users, who would like to get a working infrastructure out-of-the-box. All service configuration steps may require much time from users, who have no appropriate qualification. My proposals: Enable "Delayed start" by default Add a Wiki page describing Windows service configuration for "Advanced" users
            Hide
            teilo James Nord added a comment -

            Most people probably don't use UNC paths for storage[1] - and then you are impacting the majority of users with a slow startup to fix the minority of users.

            If you want to fix 80% of the minority without impacting the majority you could just depend on the "workstation" service.

            Anyone that wants anything more complex can suck it themselves.

            [1] based on nothing other than gut feeling and finger in the air - and that we still have huge amount of users that run builds on master!

            Show
            teilo James Nord added a comment - Most people probably don't use UNC paths for storage [1] - and then you are impacting the majority of users with a slow startup to fix the minority of users. If you want to fix 80% of the minority without impacting the majority you could just depend on the "workstation" service. Anyone that wants anything more complex can suck it themselves. [1] based on nothing other than gut feeling and finger in the air - and that we still have huge amount of users that run builds on master!
            teilo James Nord made changes -
            Field Original Value New Value
            Description Currently the service starts in the default mode, so there can be conflicts with other services like login service, shared directory mappers, etc. "Delayed start" could resolve this issue by allowing other services to start before Jenkins master/slave starts the initialization.

            The change requires https://github.com/kohsuke/winsw/releases/tag/winsw-1.17 at least (not merged into Jenkins core)
            Currently the service starts in the "Automatic" mode, so there can be conflicts with other services like login service, shared directory mappers, etc. "Automatic (Delayed start)" could resolve this issue by allowing other services to start before Jenkins master/slave starts the initialization.

            The change requires https://github.com/kohsuke/winsw/releases/tag/winsw-1.17 at least (not merged into Jenkins core)
            teilo James Nord made changes -
            Summary Windows service: use "Delayed start" as a default start mode for Jenkins master and slaves Windows service: service can start before required windows services are available.
            oleg_nenashev Oleg Nenashev made changes -
            Issue Type Improvement [ 4 ] Bug [ 1 ]
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            We agreed to move the discussion to Jenkins CI Dev list

            Show
            oleg_nenashev Oleg Nenashev added a comment - We agreed to move the discussion to Jenkins CI Dev list
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 164373 ] JNJira + In-Review [ 181601 ]
            oleg_nenashev Oleg Nenashev made changes -
            Link This issue is duplicated by JENKINS-43575 [ JENKINS-43575 ]
            oleg_nenashev Oleg Nenashev made changes -
            Issue Type Bug [ 1 ] Improvement [ 4 ]
            oleg_nenashev Oleg Nenashev made changes -
            Summary Windows service: service can start before required windows services are available. Windows service: Add support of the Delayed Start option
            oleg_nenashev Oleg Nenashev made changes -
            Component/s windows-slave-installer-module [ 21834 ]
            Hide
            oleg_nenashev Oleg Nenashev added a comment - - edited

            James Nord After some reconsideration I have decided not to enable it by default, but to provide a proper feature in WinSW: https://github.com/kohsuke/winsw/pull/205 . So anyone will be able to enable it if he wants.

            Would it work for you?

            Show
            oleg_nenashev Oleg Nenashev added a comment - - edited James Nord After some reconsideration I have decided not to enable it by default, but to provide a proper feature in WinSW: https://github.com/kohsuke/winsw/pull/205 . So anyone will be able to enable it if he wants. Would it work for you?
            oleg_nenashev Oleg Nenashev made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            oleg_nenashev Oleg Nenashev made changes -
            Epic Link JENKINS-38833 [ 175240 ]
            oleg_nenashev Oleg Nenashev made changes -
            Status In Progress [ 3 ] In Review [ 10005 ]
            Hide
            oleg_nenashev Oleg Nenashev added a comment -

            Closing as Resolved. The option is there since 2.60, but it is an opt-in behavior

            Show
            oleg_nenashev Oleg Nenashev added a comment - Closing as Resolved. The option is there since 2.60, but it is an opt-in behavior
            oleg_nenashev Oleg Nenashev made changes -
            Status In Review [ 10005 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]

              People

              • Assignee:
                oleg_nenashev Oleg Nenashev
                Reporter:
                oleg_nenashev Oleg Nenashev
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: