HarrisKirk / blue-green-dreams

2 stars 1 forks source link

Modify switch-xxx commands to operate on the nginx linode switch #77

Closed HarrisKirk closed 1 year ago

HarrisKirk commented 1 year ago

Per Chris, a switch will be a linode instance with nginx. This ticket simply creates, views and deletes the switch. It can be shell commands or python whatever is easier for now. I really don't want to use Make since I want all infrastructure to be managed by the cli.

This ticket will not actually set backend IPs.

DONE = commands to create, view and delete the linode with nginx installed. The linode should have PROJECT tag. like other artifacts

HarrisKirk commented 1 year ago

I have the following testing results: The sunny day testing worked very well. I can create, view and delete the switch.

However, the 'create' command results in a non-zero return code and resulting error msg

I tried removing the view function since it first failed there. But then it also failed on the create.

I also don't see a PROJECT tag on the linode.

================================================================================== ERROR MSG

237 │   execute_sh(cmd)                                                    │
│   238 │                                                                      │
│   239 │   logging.info(f"Created linode with nginx load balancer configured  │
│   240 #    switch_view()                                                     │
│                                                                              │
│ ╭─────────────────────── locals ────────────────────────╮                    │
│ │ cmd = ['bash', '-c', '/gwa_deploy/nginx-lb/setup.sh'] │                    │
│ ╰───────────────────────────────────────────────────────╯                    │
│                                                                              │
│ /gwa_deploy/common.py:39 in execute_sh                                       │
│                                                                              │
│   36 │   if completed_process.returncode != 0:                               │
│   37 │   │   logging.debug(stdout)                                           │
│   38 │   │   logging.debug(completed_process.stderr.decode())                │
│ ❱ 39 │   │   raise Exception()                                               │
│   40 │   return stdout                                                       │
│   41                                                                         │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │               cmd = ['bash', '-c', '/gwa_deploy/nginx-lb/setup.sh']      │ │
│ │ completed_process = CompletedProcess(args=['bash', '-c',                 │ │
│ │                     '/gwa_deploy/nginx-lb/setup.sh'], returncode=1,      │ │
│ │                     stdout=b'', stderr=b'+ set -o pipefail\n+ set -e\n+  │ │
│ │                     cd /gwa_deploy\n++ linode-cli linodes create         │ │
│ │                     --region us-east --image linode/debian11 --label     │ │
│ │                     linode-blue-green-lb --type g6-standard-1            │ │
│ │                     --authorized_keys \'ssh-ed25519                      │ │
│ │                     AAAAC3NzaC1lZDI1NTE5AAAAIFrJ+FhsIIrBFXBq7RhK+AG7I99… │ │
│ │                     harris@harris-Oryx-Pro\' --root_pass                 │ │
│ │                     \'foobarException8812!\' --json\n+ json=\'[{"id":    │ │
│ │                     49430423, "label": "linode-blue-green-lb", "group":  │ │
│ │                     "", "status": "provisioning", "created":             │ │
│ │                     "2023-09-07T00:56:39", "updated":                    │ │
│ │                     "2023-09-07T00:56:39", "type": "g6-standard-1",      │ │
│ │                     "ipv4": ["50.116.49.91"], "ipv6":                    │ │
│ │                     "2600:3c03::f03c:93ff:feef:1bc2/128", "image":       │ │
│ │                     "linode/debian11", "region": "us-east", "specs":     │ │
│ │                     {"disk": 51200, "memory": 2048, "vcpus": 1, "gpus":  │ │
│ │                     0, "transfer": 2000}, "alerts": {"cpu": 90,          │ │
│ │                     "network_in": 10, "network_out": 10,                 │ │
│ │                     "transfer_quota": 80, "io": 10000}, "backups":       │ │
│ │                     {"enabled": false, "available": false, "schedule":   │ │
│ │                     {"day": null, "window": null}, "last_successful":    │ │
│ │                     null}, "hypervisor": "kvm", "watchdog_enabled":      │ │
│ │                     true, "tags": [], "host_uuid":                       │ │
│ │                     "19888ff79296a52354d780c3a9280c0d61b3c192",          │ │
│ │                     "has_user_data": false}]\'\n++ echo \'[{"id":        │ │
│ │                     49430423, "label": "linode-blue-green-lb", "group":  │ │
│ │                     "", "status": "provisioning", "created":             │ │
│ │                     "2023-09-07T00:56:39", "updated":                    │ │
│ │                     "2023-09-07T00:56:39", "type": "g6-standard-1",      │ │
│ │                     "ipv4": ["50.116.49.91"], "ipv6":                    │ │
│ │                     "2600:3c03::f03c:93ff:feef:1bc2/128", "image":       │ │
│ │                     "linode/debian11", "region": "us-east", "specs":     │ │
│ │                     {"disk": 51200, "memory": 2048, "vcpus": 1, "gpus":  │ │
│ │                     0, "transfer": 2000}, "alerts": {"cpu": 90,          │ │
│ │                     "network_in": 10, "network_out": 10,                 │ │
│ │                     "transfer_quota": 80, "io": 10000}, "backups":       │ │
│ │                     {"enabled": false, "available": false, "schedule":   │ │
│ │                     {"day": null, "window": null}, "last_successful":    │ │
│ │                     null}, "hypervisor": "kvm", "watchdog_enabled":      │ │
│ │                     true, "tags": [], "host_uuid":                       │ │
│ │                     "19888ff79296a52354d780c3a9280c0d61b3c192",          │ │
│ │                     "has_user_data": false}]\'\n++ jq -r \'.[0].id\'\n+  │ │
│ │                     vmId=49430423\n++ echo \'[{"id": 49430423, "label":  │ │
│ │                     "linode-blue-green-lb", "group": "", "status":       │ │
│ │                     "provisioning", "created": "2023-09-07T00:56:39",    │ │
│ │                     "updated": "2023-09-07T00:56:39", "type":            │ │
│ │                     "g6-standard-1", "ipv4": ["50.116.49.91"], "ipv6":   │ │
│ │                     "2600:3c03::f03c:93ff:feef:1bc2/128", "image":       │ │
│ │                     "linode/debian11", "region": "us-east", "specs":     │ │
│ │                     {"disk": 51200, "memory": 2048, "vcpus": 1, "gpus":  │ │
│ │                     0, "transfer": 2000}, "alerts": {"cpu": 90,          │ │
│ │                     "network_in": 10, "network_out": 10,                 │ │
│ │                     "transfer_quota": 80, "io": 10000}, "backups":       │ │
│ │                     {"enabled": false, "available": false, "schedule":   │ │
│ │                     {"day": null, "window": null}, "last_successful":    │ │
│ │                     null}, "hypervisor": "kvm", "watchdog_enabled":      │ │
│ │                     true, "tags": [], "host_uuid":                       │ │
│ │                     "19888ff79296a52354d780c3a9280c0d61b3c192",          │ │
│ │                     "has_user_data": false}]\'\n++ jq -r \'.[0].ipv4 |   │ │
│ │                     .[0]\'\n+ vmNetIp=50.116.49.91\n+ mkdir -p temp\n+   │ │
│ │                     echo                                                 │ │
│ │                     LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjN… │ │
│ │                     base64 -d\nbase64: invalid input\n')                 │ │
│ │            stdout = ''                                                   │ │
│ │                wd = '.'                                                  │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
Exception