Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Fix internal server error and false positive when creating a server #6782

Merged
zrhoffman merged 2 commits intoapache:masterfrom
ericholguin:servers-bug-fix
Apr 27, 2022
Merged

Fix internal server error and false positive when creating a server #6782
zrhoffman merged 2 commits intoapache:masterfrom
ericholguin:servers-bug-fix

Conversation

@ericholguin
Copy link
Copy Markdown
Contributor

@ericholguin ericholguin commented Apr 26, 2022

Fixes: #6779
Fixes: #6781

With this fix there is no internal server error when creating a server without a profile key in v2 and v3

The other fix is when creating a server with multiple profiles in v4, if any of the profiles do not belong to the same CDN it will now fail as expected.


Which Traffic Control components are affected by this PR?

  • Traffic Ops

What is the best way to verify this PR?

Build and test the following in TO:

POST request to /api/2.0/servers with no profile key in the request body

{
    "cachegroupId": 8,
    "cdnId": 2,
    "domainName": "ga.atlanta.kabletown.net",
    "hostName": "atlanta-edge-01",
    "interfaceMtu": 1500,
    "ipAddress": "172.16.239.120",
    "ipGateway": "172.16.239.1",
    "ipNetmask": "255.255.255.0",
    "ipIsService": true,
    "interfaceName": "eth0",
    "physLocationId": 2,
    "statusId": 3,
    "typeId": 11,
    "profileId": 13
}

Should succeed with no error:

HTTP/1.1 200 OK
{
    "alerts": [
        {
            "text": "Server created",
            "level": "success"
        }
    ],
    "response": {...}
}

POST request to /api/3.0/servers with no profile key in the request body

{
    "cachegroupId": 8,
    "cdnId": 2,
    "domainName": "ga.atlanta.kabletown.net",
    "hostName": "atlanta-edge-01",
    "interfaces": [
        {
            "ipAddresses": [
                {
                    "address": "0.0.0.1",
                    "gateway": "0.0.0.1",
                    "serviceAddress": true
                }
            ],
            "name": "eth0"
        }
    ],
    "physLocationId": 2,
    "statusId": 3,
    "typeId": 11,
    "profileId": 13
}

Should succeed with no error:

HTTP/1.1 201 Created
{
    "alerts": [
        {
            "text": "Server created",
            "level": "success"
        }
    ],
    "response": {...}
}

POST request to /api/4.0/servers with multiple profiles, where one profile belongs to a different cdn than the server (regardless of order)

{
    "cachegroupId": 8,
    "cdnId": 2,
    "domainName": "test.net",
    "hostName": "test-01",
    "interfaces": [
        {
            "ipAddresses": [
                {
                    "address": "0.0.0.1",
                    "gateway": "0.0.0.1",
                    "serviceAddress": true
                }
            ],
            "name": "eth0"
        }
    ],
    "physLocationId": 2,
    "statusId": 3,
    "typeId": 11,
    "profileNames": ["ORG_MSO", "TRAFFIC_STATS", "CCR_CIAB"]
}

Should return an error:

HTTP/1.1 400 Bad Request
{
    "alerts": [
        {
            "text": "CDN id '1' for profile 'TRAFFIC_STATS' does not match Server CDN '2'",
            "level": "error"
        }
    ]
}

PR submission checklist

@rawlinp rawlinp added Traffic Ops related to Traffic Ops regression bug a bug in existing functionality introduced by a new version labels Apr 26, 2022
@zrhoffman zrhoffman added this to the 7.0.0 milestone Apr 26, 2022
@mitchell852
Copy link
Copy Markdown
Member

can you make a better title for the PR @ericholguin to describe what this PR does? thanks

@ericholguin ericholguin changed the title Fix regression bugs server profile regression bug fix Apr 26, 2022
@ericholguin ericholguin changed the title server profile regression bug fix Fix internal server error and false positive when creating a server Apr 26, 2022
@rimashah25
Copy link
Copy Markdown
Contributor

rimashah25 commented Apr 26, 2022

LGTM from code perspective but wonder why TO API tests fail..

@zrhoffman zrhoffman merged commit dca71fe into apache:master Apr 27, 2022
@asf-ci asf-ci mentioned this pull request May 1, 2022
4 tasks
@ericholguin ericholguin deleted the servers-bug-fix branch May 10, 2022 19:55
zrhoffman pushed a commit to zrhoffman/trafficcontrol that referenced this pull request Oct 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

regression bug a bug in existing functionality introduced by a new version Traffic Ops related to Traffic Ops

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can create a server with a profile belonging to another CDN /api/3.0/servers POST request with no profile key returns Internal Server Error

5 participants