Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

fix: extending the validation rules for plans #63

Closed

Conversation

antoninrykalsky
Copy link

When I list all the plans, there is a problem with inserting data into the objects, due to validation rules.

In one case, the 100Gbps value is missing in the enum.
In the other, it returns 100mb instead of 100MB.

Maybe it's not specifically like this, I lost the cases in the history. I can execute it again if needed.

@t0mk
Copy link
Contributor

t0mk commented Dec 18, 2023

@antoninrykalsky Hi, thanks for the patch, it's really good that you've noticed that.

We can't directly edit the python code becauese it's generated from the API specs docs (the yaml file in the root of the repo). We also can't edit the YAML file because it's generated from API-spec sub-files.

We do these fixes via python script https://github.com/equinix-labs/metal-python/blob/main/scripts/patch_metal_spec.py
You need to find out where in the spec are the speeds specified, and then add '100 Gbps' to that list.

As for the '100Mb' vs '100MB', I don't think we can force upper() call via the spec, or here in Metal python. If the spec is incosistent here, we most likely need to fix it in the ansible collection. We can talk about it on Thurdsay.

@antoninrykalsky
Copy link
Author

So about that upper, there is no problem about 100MB, but NVME vs NVMe (lowercase e)

It in in that plan. Just one occurence

{
      "id": "edd8a672-9e5c-46ea-b110-ca0ae9711e9c",
      "slug": "f3.large.x86",
      "name": "f3.large.x86",
      "description": "Our f3.large.x86 configuration is a zippy general use server, with a Intel Xeon SP processor and gobs of RAM",
      "line": "baremetal",
      "deployment_types": [],
      "categories": [
        "compute",
        "current_gen"
      ],
      "type": "standard",
      "class": "f3.large.x86",
      "legacy": false,
      "specs": {
        "cpus": [
          {
            "count": 1,
            "type": "Intel(R) Xeon(R) Gold 5218 CPU @ 2.30GHz"
          }
        ],
        "memory": {
          "total": "384GB"
        },
        "drives": [
          {
            "count": 2,
            "size": "480GB",
            "type": "SSD",
            "category": "boot"
          },
          {
            "count": 2,
            "size": "1.6TB",
            "type": "NVMe",
            "category": "storage"
          }
        ],
        "nics": [
          {
            "count": 2,
            "type": "25Gbps"
          }
        ],
        "features": {}
      },
      "pricing": {
        "hour": 4.0
      },
      "reservation_pricing": {},
      "available_in": [],
      "available_in_metros": []
    },

About nic speed, there is problem with this: (100Gbps ) (Those all all occurrences)

{
      "id": "4b3a3f24-7c87-5e46-9401-13f74a3d2a8b",
      "slug": "nvidia3.a100.medium",
      "name": "nvidia3.a100.medium.x86",
      "description": "nvidia3.a100.medium.x86",
      "line": "baremetal",
      "deployment_types": [],
      "categories": [
        "compute",
        "current_gen"
      ],
      "type": "custom",
      "class": "nvidia3.a100.medium",
      "legacy": false,
      "specs": {
        "cpus": [
          {
            "count": 2,
            "type": "Intel Xeon Gold 6354"
          }
        ],
        "memory": {
          "total": "368GB"
        },
        "drives": [
          {
            "count": 2,
            "size": "480GB",
            "type": "SSD",
            "category": "boot"
          },
          {
            "count": 2,
            "size": "1.92TB",
            "type": "NVME"
          }
        ],
        "nics": [
          {
            "count": 2,
            "type": "25Gbps"
          },
          {
            "count": 2,
            "type": "100Gbps"
          }
        ],
        "features": {
          "raid": true,
          "txt": true
        }
      },
      "pricing": {
        "hour": 0.0
      },
      "reservation_pricing": {},
      "available_in": [],
      "available_in_metros": []
    },
{
      "id": "a500dff5-68fe-5805-8b12-326f51e64e1c",
      "slug": "nvidia3.a30.large",
      "name": "nvidia3.a30.large.x86",
      "description": "nvidia3.a30.large.x86",
      "line": "baremetal",
      "deployment_types": [],
      "categories": [
        "compute",
        "current_gen"
      ],
      "type": "custom",
      "class": "nvidia3.a30.large",
      "legacy": false,
      "specs": {
        "cpus": [
          {
            "count": 2,
            "type": "Intel Xeon Gold 6354"
          }
        ],
        "memory": {
          "total": "368GB"
        },
        "drives": [
          {
            "count": 2,
            "size": "480GB",
            "type": "SSD"
          },
          {
            "count": 8,
            "size": "1.92TB",
            "type": "NVME"
          }
        ],
        "nics": [
          {
            "count": 2,
            "type": "25Gbps"
          },
          {
            "count": 2,
            "type": "100Gbps"
          }
        ],
        "features": {
          "raid": true,
          "txt": true
        }
      },
      "pricing": {
        "hour": 0.0
      },
      "reservation_pricing": {},
      "available_in": [],
      "available_in_metros": []
    },
{
      "id": "9415cc8e-430e-5f99-897b-ddbfc0deadd0",
      "slug": "nvidia3.a30.medium",
      "name": "nvidia3.a30.medium.x86",
      "description": "nvidia3.a30.medium.x86",
      "line": "baremetal",
      "deployment_types": [],
      "categories": [
        "compute",
        "current_gen"
      ],
      "type": "custom",
      "class": "nvidia3.a30.medium",
      "legacy": false,
      "specs": {
        "cpus": [
          {
            "count": 2,
            "type": "Intel Xeon Gold 6354"
          }
        ],
        "memory": {
          "total": "368GB"
        },
        "drives": [
          {
            "count": 2,
            "size": "480GB",
            "type": "SSD"
          },
          {
            "count": 2,
            "size": "1.92TB",
            "type": "NVME"
          }
        ],
        "nics": [
          {
            "count": 2,
            "type": "25Gbps"
          },
          {
            "count": 2,
            "type": "100Gbps"
          }
        ],
        "features": {
          "raid": true,
          "txt": true
        }
      },
      "pricing": {
        "hour": 0.0
      },
      "reservation_pricing": {},
      "available_in": [],
      "available_in_metros": []
    },
{
      "id": "4e8fd752-8b26-5275-8c71-7e882d2c7f1e",
      "slug": "nvidia3.a40.medium",
      "name": "nvidia3.a40.medium.x86",
      "description": "nvidia3.a40.medium.x86",
      "line": "baremetal",
      "deployment_types": [],
      "categories": [
        "compute",
        "current_gen"
      ],
      "type": "custom",
      "class": "nvidia3.a40.medium",
      "legacy": false,
      "specs": {
        "cpus": [
          {
            "count": 2,
            "type": "Intel Xeon Gold 6354"
          }
        ],
        "memory": {
          "total": "368GB"
        },
        "drives": [
          {
            "count": 2,
            "size": "480GB",
            "type": "SSD",
            "category": "boot"
          },
          {
            "count": 2,
            "size": "1.92TB",
            "type": "NVME"
          }
        ],
        "nics": [
          {
            "count": 2,
            "type": "25Gbps"
          },
          {
            "count": 2,
            "type": "100Gbps"
          }
        ],
        "features": {
          "raid": true,
          "txt": true
        }
      },
      "pricing": {
        "hour": 0.0
      },
      "reservation_pricing": {},
      "available_in": [],
      "available_in_metros": []
    },
{
      "id": "a5554896-3a98-5c18-9d52-10ef66c8b6a8",
      "slug": "nvidia3.h100.large.x86",
      "name": "nvidia3.h100.large.x86",
      "description": "nvidia3.h100.large.x86",
      "line": "baremetal",
      "deployment_types": [],
      "categories": [
        "compute",
        "current_gen"
      ],
      "type": null,
      "class": "nvidia3.h100.large.x86",
      "legacy": false,
      "specs": {
        "cpus": [
          {
            "count": 2,
            "type": "Intel Xeon Gold 6354"
          }
        ],
        "memory": {
          "total": "128GB"
        },
        "drives": [
          {
            "count": 2,
            "size": "1.92TB",
            "type": "NVME"
          }
        ],
        "nics": [
          {
            "count": 2,
            "type": "100Gbps"
          }
        ],
        "features": {
          "raid": true,
          "txt": true
        }
      },
      "pricing": {
        "hour": 0.0
      },
      "reservation_pricing": {},
      "available_in": [],
      "available_in_metros": []
    },
{
      "id": "746b9224-e02f-57ce-8595-57249180d0a9",
      "slug": "nvidia3.t4.small",
      "name": "nvidia3.t4.small.x86",
      "description": "nvidia3.t4.small.x86",
      "line": "baremetal",
      "deployment_types": [],
      "categories": [
        "compute",
        "current_gen"
      ],
      "type": "custom",
      "class": "nvidia3.t4.small",
      "legacy": false,
      "specs": {
        "cpus": [
          {
            "count": 2,
            "type": "Intel Xeon Gold 6354"
          }
        ],
        "memory": {
          "total": "368GB"
        },
        "drives": [
          {
            "count": 2,
            "size": "480GB",
            "type": "SSD"
          },
          {
            "count": 2,
            "size": "1.92TB",
            "type": "NVME"
          }
        ],
        "nics": [
          {
            "count": 2,
            "type": "25Gbps"
          },
          {
            "count": 2,
            "type": "100Gbps"
          }
        ],
        "features": {
          "raid": true,
          "txt": true
        }
      },
      "pricing": {
        "hour": 0.0
      },
      "reservation_pricing": {},
      "available_in": [],
      "available_in_metros": []
    },

@ctreatma
Copy link
Contributor

For comparison, in metal-go, we patched the spec to remove these enums from plans because the data was not well-controlled; we raised that issue upstream and were told it was resolved, and I was about to remove that patch from the Go SDK, but since you're still running into issues with it, we should probably adopt the same spec patch in Python. https://github.com/equinix/equinix-sdk-go/blob/main/spec/services/metalv1/patches/20230921-plan-drive-type.patch

@antoninrykalsky
Copy link
Author

@ctreatma Thanks for the clue. I've seen similar removal of the default value. I just didn't make the connection.

@ctreatma ctreatma closed this in #64 Dec 20, 2023
ctreatma added a commit that referenced this pull request Dec 20, 2023
)

This PR removes 2 enums from Plan subschemas, because the enumed values
don't match the API.

Based on:

https://github.com/equinix/equinix-sdk-go/blob/main/spec/services/metalv1/patches/20230921-plan-drive-type.patch

fixes #63 

Most of the diff are tests, the relevant changes are two entries at the
bottom.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants