openboxes / openboxes-devops

Infrastracture as Code artifacts for OpenBoxes.
3 stars 0 forks source link

Deploy to Azure deployment failed #61

Open jmiranda opened 1 year ago

jmiranda commented 1 year ago

A user encountered the following issue when using the Deploy to Azure feature.

image

See the discussion on Discourse for more details. https://community.openboxes.com/t/deploy-openboxes-to-azure-problem/793

jmiranda commented 1 year ago

The discourse post documents the initial problems encountered and their solutions. I'll bring those back here once I've resolved the remaining issues.

So I ran through the deployment again and encountered another issue. So I decided to download the ob-vm-setup.sh on the server and run it directly.

azureuser@OB-VM:~$ wget https://raw.githubusercontent.com/openboxes/openboxes-devops/master/arm-template/scripts/ob-vm-setup.sh
--2023-07-21 18:51:05--  https://raw.githubusercontent.com/openboxes/openboxes-devops/master/arm-template/scripts/ob-vm-setup.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2843 (2.8K) [text/plain]
Saving to: ‘ob-vm-setup.sh.1’

ob-vm-setup.sh                                    100%[================================================================================================================>]   2.78K  --.-KB/s    in 0s      

2023-07-21 18:51:05 (38.0 MB/s) - ‘ob-vm-setup.sh’ saved [2843/2843]

azureuser@OB-VM:~$ chmod +x ob-vm-setup.sh
azureuser@OB-VM:~$ ./ob-vm-setup.sh 
+ set -e
+ [[ ! -z '' ]]
+ sudo curl -s https://repos.azul.com/azul-repo.key
+ sudo gpg --dearmor -o /usr/share/keyrings/azul.gpg
gpg: WARNING: unsafe ownership on homedir '/home/azureuser/.gnupg'
File '/usr/share/keyrings/azul.gpg' exists. Overwrite? (y/N) 

Ignoring the substance of the error message, the real problem is that we are trying to automate this setup process so being prompted to answer a question like this is counter-productive.

jmiranda commented 1 year ago

Made some progress with the attached version of ob-vm-setup.sh but encountered an error during a Liquibase migration. This is probably a legitimate bug.

Jul 21 19:44:29 OB-VM java[30566]: 2023-07-21 19:44:29,410 ERROR [main      ] liquibase.changelog.ChangeSet           : Change Set views/changelog.xml::1580848680306-7::jmiranda failed.  Error: Unknown column 'order.order_type_id' in 'where clause' [Failed SQL: (1054) CREATE OR REPLACE VIEW on_order_order_item_summary AS
Jul 21 19:44:29 OB-VM java[30566]: (
Jul 21 19:44:29 OB-VM java[30566]: SELECT a.product_id,
Jul 21 19:44:29 OB-VM java[30566]:        a.destination_id,
Jul 21 19:44:29 OB-VM java[30566]:        ifnull(sum(case
Jul 21 19:44:29 OB-VM java[30566]:                     when a.quantity_ordered - a.quantity_shipped > 0
Jul 21 19:44:29 OB-VM java[30566]:                         then a.quantity_ordered - a.quantity_shipped
Jul 21 19:44:29 OB-VM java[30566]:                     else 0 end), 0) as quantity_ordered_not_shipped,
Jul 21 19:44:29 OB-VM java[30566]:        null                                                         as quantity_shipped_not_received
Jul 21 19:44:29 OB-VM java[30566]: FROM (
Jul 21 19:44:29 OB-VM java[30566]:          SELECT product.id                   as product_id,
Jul 21 19:44:29 OB-VM java[30566]:                 order_item.id,
Jul 21 19:44:29 OB-VM java[30566]:                 `order`.destination_id,
Jul 21 19:44:29 OB-VM java[30566]:                 sum(distinct case
Jul 21 19:44:29 OB-VM java[30566]:                                  when `order`.status != 'PENDING'
Jul 21 19:44:29 OB-VM java[30566]:                                      then order_item.quantity * order_item.quantity_per_uom
Jul 21 19:44:29 OB-VM java[30566]:                                  else 0 end) as quantity_ordered,
Jul 21 19:44:29 OB-VM java[30566]:                 sum(case
Jul 21 19:44:29 OB-VM java[30566]:                         when shipment_item.quantity and shipment.current_status in ('SHIPPED', 'PARTIALLY_RECEIVED', 'RECEIVED') then shipment_item.quantity
Jul 21 19:44:29 OB-VM java[30566]:                         else 0 end)          as quantity_shipped,
Jul 21 19:44:29 OB-VM java[30566]:                 null                         as quantity_shipped_not_received
Jul 21 19:44:29 OB-VM java[30566]:          FROM order_item
Jul 21 19:44:29 OB-VM java[30566]:                   JOIN
Jul 21 19:44:29 OB-VM java[30566]:               product ON order_item.product_id = product.id
Jul 21 19:44:29 OB-VM java[30566]:                   JOIN
Jul 21 19:44:29 OB-VM java[30566]:               `order` ON order_item.order_id = `order`.id
Jul 21 19:44:29 OB-VM java[30566]:                   LEFT OUTER JOIN
Jul 21 19:44:29 OB-VM java[30566]:               order_shipment ON order_shipment.order_item_id = order_item.id
Jul 21 19:44:29 OB-VM java[30566]:                   LEFT OUTER JOIN
Jul 21 19:44:29 OB-VM java[30566]:               shipment_item ON order_shipment.shipment_item_id = shipment_item.id
Jul 21 19:44:29 OB-VM java[30566]:                   LEFT OUTER JOIN
Jul 21 19:44:29 OB-VM java[30566]:               shipment ON shipment_item.shipment_id = shipment.id
Jul 21 19:44:29 OB-VM java[30566]:          WHERE `order`.order_type_id = 'PURCHASE_ORDER'
Jul 21 19:44:29 OB-VM java[30566]:            AND order_item.order_item_status_code != 'CANCELED'
Jul 21 19:44:29 OB-VM java[30566]:          GROUP BY product.product_code, order_item.id, product.name, `order`.destination_id) a
Jul 21 19:44:29 OB-VM java[30566]: GROUP BY product_id, destination_id
Jul 21 19:44:29 OB-VM java[30566]:     )]

ob-vm-setup-sh ob-vm-setup.sh.txt

/var/log/syslog azure-var-log-syslog.txt

jmiranda commented 1 year ago

I pushed the changes to ob-vm-setup.sh and my next Azure deployment was "successful".

image

However, the database migration issue is still there so we'll need to address that within the OBGM project.