From 8dfc8020380fc6b7dc5c7107f28d475ae26c9410 Mon Sep 17 00:00:00 2001 From: Simone Giacomel Date: Wed, 27 May 2020 08:40:08 -0400 Subject: [PATCH 1/2] Check that Placement is not null before trying to access it Signed-off-by: Simone Giacomel --- manager/orchestrator/task.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manager/orchestrator/task.go b/manager/orchestrator/task.go index f9a3feadf5..ea2501118e 100644 --- a/manager/orchestrator/task.go +++ b/manager/orchestrator/task.go @@ -119,6 +119,10 @@ func nodeMatches(s *api.Service, n *api.Node) bool { return false } + if s.Spec.Task.Placement == nil { + return false + } + constraints, _ := constraint.Parse(s.Spec.Task.Placement.Constraints) return constraint.NodeMatches(constraints, n) } From 9cb517e7ad77c64f6809e9b0a15b181c3aca354d Mon Sep 17 00:00:00 2001 From: Simone Giacomel Date: Fri, 15 Jan 2021 14:18:15 -0500 Subject: [PATCH 2/2] Update task.go Met the requirements if the constraints are empty --- manager/orchestrator/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/orchestrator/task.go b/manager/orchestrator/task.go index ea2501118e..84f496c068 100644 --- a/manager/orchestrator/task.go +++ b/manager/orchestrator/task.go @@ -120,7 +120,7 @@ func nodeMatches(s *api.Service, n *api.Node) bool { } if s.Spec.Task.Placement == nil { - return false + return true } constraints, _ := constraint.Parse(s.Spec.Task.Placement.Constraints)