hitrov/oci-arm-host-capacity

Multiple availability domains?

mehapps opened this issue · 5 comments

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." }

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

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

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."
}

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

Also that constructor seems the same, getting the error still