Hi Jason,

I hope I'm not misunderstanding you.

I have not personally implemented blue-green deployments with GoCD, although I wonder if this behaviour below is really what you want.

If you make your blue environment active and then straight away you deploy to the green one, are you not losing your ability to revert if something goes wrong? With blue-green deployments, switching environments is the way to revert.

The way I'd imagine it is that you simply always deploy into the inactive environment and then once you're sufficiently happy with the inactive deployment (could be automated or manual), you switch the active environment over. This way you don't even need to have "blue" or "green" pipelines/stages. You just work with the inactive one. You could read that info from your load-balancer for CM tool.

Regards,

Kolos

On Fri, 21 Oct 2016, Jason Whittington wrote:

I would like to implement blue/green in GoCD something like this. I would
like to hear how anyone else is solving the problem today. The behavior I
want is something like this:



  1. New material is checked in which triggers some kind of "Approval"
  pipeline.
  2. Two pipelines (Blue and Green) each *Wait *somehow for their "color"
  to become available
  3. The pipelines deploy to their color when the their color goes inactive

<https://lh3.googleusercontent.com/-U6yXds2_ntQ/WApnHTwnC8I/AAAAAAAAAHM/3rYtC8SuuX8xFA8HnHp9ZL22snvcnnkeACKgB/s1600/bluegreen1.PNG>


The "hard part" for me is the *Wait* stages.  I need the pipeline
scheduling to be automatic to make sure we deploy the right versions of
materials.  Automatic scheduling will trigger an agent to run somewhere.
The question is, how best to "wait" for something that might take hours or
days? If I were using Windows Workflow Foundation I could exit on a
resumable bookmark that I could trigger later.  Alas, bookmarks aren't
available in GoCD and I don't see any way in GoCD for an agent to say "put
me to sleep until some future event happens".

Options I see on the table:



  -
*Poll some endpoint and hang until the change happens ("Busy wait") *I
  could have an agent start up and repeatedly poll some outside service
  asking "can I  run now? now? how about now?" This feels like a crummy
  solution to me.  The agent will look like a "hung agent" and likely be
  terminated for running too long.  Busy wait is chatty and consumes cycles.
   It Completely fails if there is a reboot somewhere in there.

  - *Set a timer to "try again later"*
  Only slightly less grody - I could have the agent set a timer that will
  call a script at some point in the future that will check for availability
  and then trigger the pipeline to run again. This would be a manual
  invocation though, so I would need the future invocation to pass in the all
  the right versions of things when it triggers.  This feels likely to be
  fragile if the materials change over time.  Something like this:

     at now +15 minutes -f curl '
  http://myserver/go/api/pipelines/DeployToGreen/schedule'
  <http://ci.example.com/go/api/pipelines/pipeline1/schedule'> -u
  'username:password'  --header 'Confirm: true' -X POST


<https://lh3.googleusercontent.com/--n1EnLPvMLo/WApyHj9y0II/AAAAAAAAAHg/tlvaw3YjTjAUurSaKzoyzekmWpWsvX0OwCLcB/s1600/gocd_retry_timer.PNG>

I thought maybe I could do a "dummy first stage and manually invoked second
stage" trick and have the timer callback repeatedly invoke the failing
stage but I don't see a way to do that with the REST API*.*  Is it there
and I just don't see it?

  - *Play material games*
  Material can be used to trigger pipelines, right? I thought maybe I
  could have some kind of dummy material that I would check in when the
  environment changes (Like a text file that says "blue" or "green").  The
  DeployToBlue and DeployToGreen pipelines would have a material dependency
  on that item so that they would notice and trigger any time that material
  changes. This also feels super-dodgy and I'm not inclined to pursue it.

  - *Rely on human intervention*
  I really want to avoid having to make a human go into the UI and
  manually trigger DeployToBlue or DeployToGreen.


And...I'm about out of ideas.  I'm a little surprised how hard this is.
I'm hoping there's a way for me to re-trigger a failed stage via REST,
then I think I have a decent solution.  Failing that I don't see a great
way to implement blue-green with GoCD.

Appreciate your ideas!
Jason

--
You received this message because you are subscribed to the Google Groups 
"go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to