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

[supervisor] Add patch to prevent 'supervisorctl start' command from hanging if system time has rolled backward #1311

Merged
merged 2 commits into from
Jan 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ src/sonic-device-data/src/device/
src/sonic-device-data/src/debian/
src/supervisor/*
!src/supervisor/Makefile
!src/supervisor/patch/
src/thrift/*
!src/thrift/Makefile

Expand Down
6 changes: 5 additions & 1 deletion rules/supervisor.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# supervisor package

SUPERVISOR = python-supervisor_3.3.2-1_all.deb
SUPERVISOR_VERSION = 3.3.2

export SUPERVISOR_VERSION

SUPERVISOR = python-supervisor_$(SUPERVISOR_VERSION)-1_all.deb
$(SUPERVISOR)_SRC_PATH = $(SRC_PATH)/supervisor
SONIC_MAKE_DEBS += $(SUPERVISOR)
12 changes: 10 additions & 2 deletions src/supervisor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
SHELL = /bin/bash
.SHELLFLAGS += -e

MAIN_TARGET = python-supervisor_3.3.2-1_all.deb
MAIN_TARGET = python-supervisor_$(SUPERVISOR_VERSION)-1_all.deb

$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# Remove any stale files
Expand All @@ -11,7 +11,15 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# Clone supervisor repo
git clone https://github.com/Supervisor/supervisor.git
pushd ./supervisor
git checkout -f 3.3.2

# Reset HEAD to the commit of the proper tag
# NOTE: Using "git checkout <tag_name>" here detaches our HEAD,
# which stg doesn't like, so we use this method instead
git reset --hard $(SUPERVISOR_VERSION)

# Apply patches
stg init
stg import -s ../patch/series

# Build Python and Debian package
python setup.py --command-packages=stdeb.command bdist_deb
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 9ce7c3273d78dc412e3a1e3c95307a63846bad39 Mon Sep 17 00:00:00 2001
From: Joe LeVeque <jolevequ@microsoft.com>
Date: Tue, 16 Jan 2018 20:42:13 +0000
Subject: [PATCH] Prevent 'supervisorctl start' from hanging if system time
rolls backward

---
supervisor/process.py | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/supervisor/process.py b/supervisor/process.py
index f9ddcd9..d292421 100644
--- a/supervisor/process.py
+++ b/supervisor/process.py
@@ -588,6 +588,10 @@ class Subprocess:

logger = self.config.options.logger

+ # If system clock has moved backward, reset self.laststart to current system time
+ if now < self.laststart:
+ self.laststart = now;
Copy link
Collaborator

@lguohan lguohan Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am ok with this pariticular fix. however, I think the time travel can cause other problems in the code.

i checked the supervisord code, it looks like there are other places that save the current time to a value and use it later, like self.delay, it could also have the same problem in the back-off process.

if you are in the backoff state, and the system clock moved backward, then you need wait for a long time to catch up and the process won't restart for a long time.

another example is last_dispatch.

this does not sound like a trivial problem. I also see there are some unittest added. I think we need to fix all the problems I see above and add unit test code and add unit test code.

+
if self.config.options.mood > SupervisorStates.RESTARTING:
# dont start any processes if supervisor is shutting down
if state == ProcessStates.EXITED:
--
2.1.4

1 change: 1 addition & 0 deletions src/supervisor/patch/series
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0001-Prevent-supervisorctl-start-from-hanging-if-system-t.patch