hitrov / oci-arm-host-capacity

This script allows to bypass Oracle Cloud Infrastructure 'Out of host capacity' error immediately when additional OCI capacity will appear in your Home Region / Availability domain.
MIT License
898 stars 449 forks source link

Multiple availability domains? #137

Open mehapps opened 1 month ago

mehapps commented 1 month ago

How can I have it check multiple? I had OCI_AVAILABILITY_DOMAIN=['PoxX:US-ASHBURN-AD-1','PoxX:US-ASHBURN-AD-2','PoxX:US-ASHBURN-AD-3'] And I'm getting this error { "code": "CannotParseRequest", "message": "Incorrectly formatted request. Please refer to our documentation for help." }

ethanseverson commented 1 month ago

I got mine to work by setting OCI_AVAILABILITY_DOMAIN with this array format in the .env OCI_AVAILABILITY_DOMAIN='["IiXX:US-CHICAGO-1-AD-1", "IiXX:US-CHICAGO-1-AD-2", "IiXX:US-CHICAGO-1-AD-3"]'

then i modified this in index.php

//add this above the constructor
$ociAvailabilityDomain = getenv('OCI_AVAILABILITY_DOMAIN') ? json_decode(getenv('OCI_AVAILABILITY_DOMAIN'), true) : null;

$config = new OciConfig(
    getenv('OCI_REGION'),
    getenv('OCI_USER_ID'),
    getenv('OCI_TENANCY_ID'),
    getenv('OCI_KEY_FINGERPRINT'),
    getenv('OCI_PRIVATE_KEY_FILENAME'),
    $ociAvailabilityDomain, // change this line
    getenv('OCI_SUBNET_ID'),
    getenv('OCI_IMAGE_ID'),
    (int) getenv('OCI_OCPUS'),
    (int) getenv('OCI_MEMORY_IN_GBS')
);

After these changes, the script will check each availability domain

mehapps commented 1 month ago

Do you get PHP Warning: Undefined variable $ociAvailabilityDomains in /Users/mehapps/Downloads/oci-arm-host-capacity/index.php on line 31 with this? I've been getting it for ashburn

ethanseverson commented 1 month ago

I did and it works fine, but i added this above the constructor and now it is working as expected with no warning

//add this above the constructor
$ociAvailabilityDomain = getenv('OCI_AVAILABILITY_DOMAIN') ? json_decode(getenv('OCI_AVAILABILITY_DOMAIN'), true) : null;

Output:

=== Thu May 23 22:14:01 CDT 2024 ===
{
    "code": "InternalError",
    "message": "Out of host capacity."
}
{
    "code": "InternalError",
    "message": "Out of host capacity."
}
{
    "code": "InternalError",
    "message": "Out of host capacity."
}
mehapps commented 1 month ago

I think my script is setup weird - it tries each domain once and then sends me back to terminal

mehapps commented 1 month ago

Also that constructor seems the same, getting the error still