Commit a925228a authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Contempla servicios completados en check deploy

Los servicios que no tengan en ejecución todas sus réplicas pero, por el
contrario, todas sus réplicas hayan completado su última tarea con
éxito, serán considerados correctos.
parent 1f6af085
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -29,6 +29,28 @@ do
				stackServices=\$(docker service ls -f name=${serviceToCheck} --format '{{.Replicas}}') ; \
				serviceCount=\$(echo \"\${stackServices}\" | \${grepBin} -cE '.+') ; \
				runningServiceCount=\$(echo \"\${stackServices}\" | \${grepBin} -cE '([0-9]+)\/\1') ; \
				for j in \$(seq 1 ${runningServiceCount}) ; \
				do \
					runningServiceName=\$(docker service ls -f name=${serviceToCheck} --format '{{.Name}}') | \
						head -\${j} | tail -1 ; \
					runningServiceDesiredReplicas=\$(docker service ls -f name=\${runningServiceName} \
						--format '{{.Replicas}}' | cut -d '/' -f 2) ; \
					completedTaskCount=0 ; \
					for k in \$(seq 1 ${runningServiceDesiredReplicas}) ; \
					do \
						runningServiceStoppedTaskState=\$(docker service ps --format '{{.CurrentState}}' \
							-f 'desired-state=shutdown' -f \"name=\${runningServiceName}.\${k}\" \
							\${runningServiceName} | head -1 ; \
						if echo \"\${runningServiceStoppedTaskState}\" | grep 'Complete' ; \
						then \
							completedTaskCount=\$((\${completedTaskCount} + 1)) ; \
						fi ; \
					done ; \
				if [ \${completedTaskCount} -eq \${runningServiceDesiredReplicas} ] ; \
				then \
					runningServiceCount=\$((\${runningServiceCount} + 1)) ; \
				fi ; \
				done ; \
				statusCheckCmd=\"[ \"\${serviceCount}\" -ne \"0\" -a \
					\"\${serviceCount:-_}\" = \"\${runningServiceCount:--}\" ]\" ; \
			else \