The drone swarm that performs missions in an autonomous and intelligent overall collaborative manner is an important operational factor in the complex flight space. However, the complex and changing battlefield environment greatly affects the mission execution and survivability of drone swarm. In this paper, we formulated the problem of formation reconfiguration to avoid collision with obstacles with minimum cost in a complex flight space as a two-stage stochastic programming with considering uncertain moving obstacles, where we first calculate the optimal formation parameters of the drone swarm that can avoid certain fixed obstacles with minimum reconfiguration cost in the first-stage. For the uncertain moving obstacles, we calculate the extra cost for avoiding in the second-stage after the distribution of moving obstacles is known, and add this part of the cost to the first-stage to ensure the overall reconfiguration cost is minimized. Moreover, the sample average approximation (SAA) method is exploited to solve this stochastic programming problem. Extensive experimental results from the OMNeT ++ simulation environment indicate both the feasibility and effectiveness of our proposed two-stage stochastic programming approach and the better performs, compared with the existing approach.