Preventing parallel processes from causing DoS
Recursively executing parallel builds is the potentially equivalent of a fork bomb for your Packer build. On the one hand, there are a lot more cores available in today’s machines. On the other hand, the cloud provides virtually unlimited threads and cores to an image builder. Each Packer template may itself contain many build sources. Parallelism and recursion together can quickly leave resources overwhelmed and unresponsive. It becomes necessary to limit the number of processes active at any given time.
We will adapt the build script from the previous chapter to use parallelism for each infrastructure grouping. Before we can automate builds in the next chapter, we also need to prepare for another potential problem — overlapping build pipelines, which must not be allowed. If a fix or change is made to code during an active build, then that build must be stopped before we can re-attempt a new build. Luckily, the GNU parallel...