HarrisKirk / blue-green-dreams

2 stars 1 forks source link

Switch set target cluster functionality #106

Closed chrissound closed 10 months ago

chrissound commented 1 year ago

This is a WIP, please do not merge yet. It partially includes the commits from #105.

chrissound commented 1 year ago

This should now be completed and ready to be merged/tested. I've tested it successfully:

...
2023-10-19 at 18:15:10 DEBUG     execute_sh                    () chmod 600 /tmp/bgd_decoded.txt 
2023-10-19 at 18:15:10 DEBUG     execute_sh                    ()  
2023-10-19 at 18:15:10 DEBUG     execute_sh                    () scp -o StrictHostKeyChecking=no -o BatchMode=yes -i /tmp/bgd_decoded.txt nginx-lb/nginx.conf.replaced root@172.104.13.27:/etc/nginx/sites-available/default 
2023-10-19 at 18:15:12 DEBUG     execute_sh                    ()  
2023-10-19 at 18:15:12 DEBUG     execute_sh                    () ssh -o StrictHostKeyChecking=no -o BatchMode=yes -i /tmp/bgd_decoded.txt root@172.104.13.27 nginx -t && service nginx reload 
2023-10-19 at 18:15:13 DEBUG     execute_sh                    ()  
2023-10-19 at 18:15:13 INFO      switch_set_ip_target_to_cluster() nginx switch (env: green) succesfully set to target (blue)
HarrisKirk commented 11 months ago

I am not clear on what the cli command looks like. Can you provide an example? In particular how we will identify the cluster that is the target.

chrissound commented 11 months ago

Added a better example in the README.md but essentially:

bgdctl switch-set-ip-target-to-cluster our-switch-env our-cluster-target-env

So if we wanted to set the dev switch to point to the green cluster: bgdctl switch-set-ip-target-to-cluster dev green

Regarding your question

In particular how we will identify the cluster that is the target.

I'm not sure what you mean? The python script automatically figures out which cluster in linode is the target, based on the env specified.

HarrisKirk commented 10 months ago

I think in general we are seeing this PR with the same intent, which is good. I have these questions for our Thursday call. I don't have answers but merely topics. 1 - I think the "env" tag for a switch may need to be revisited since I envision being able to delete all linode artifacts that match an "env" tag. And since a switch can (by definition) point to different clusters, I am not sure it makes sense to assign an "env" tag on a switch the same way we do the cluster artifacts. Perhaps we simply don't assign a "env" tag to a switch and when we want to delete it, we delete it by linode-id. Perhaps the "switch view" command can also be modified to show the cluster currently pointed to? 2 - I think the command needs to be the "switch" command followed by the "sub-command" that is something shorter than your example. Perhaps you already had that in mind. The verbs "redirect", "set-target" or something else come to mind. I am open to other ideas. The typer help messages for these arguments will need to be thought through carefully. 3 - I am starting to assemble use cases for the entire flow of creating and testing a new cluster (which can have an arbitrary name) which will include deleting the clusters after the switch has happened. Probably a manual not automated step.

@chrissound We are on the home stretch of the work I wanted your help with so this is getting exciting.