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

Comments

Remove cacheurl from Delivery Services#4644

Merged
rawlinp merged 84 commits intoapache:masterfrom
shamrickus:cacheurl
Feb 19, 2021
Merged

Remove cacheurl from Delivery Services#4644
rawlinp merged 84 commits intoapache:masterfrom
shamrickus:cacheurl

Conversation

@shamrickus
Copy link
Member

@shamrickus shamrickus commented Apr 17, 2020

What does this PR (Pull Request) do?

This does not finish #3225 as CacheURL exists in ATC5 and TO API v3, so until those are no longer supported CacheURL cannot be completely removed.

Which Traffic Control components are affected by this PR?

  • CDN in a Box
  • Documentation
  • Traffic Control Client
  • Traffic Ops
  • Traffic Portal
  • Traffic Router

What is the best way to verify this PR?

Ensure db migration works
Verify CDN still works (specificially TO, TR, TP)
Verify modify/delete/create of DS in TP/TO

The following criteria are ALL met by this PR

  • This PR includes tests OR I have explained why tests are unnecessary
  • This PR includes documentation OR I have explained why documentation is unnecessary
  • This PR includes an update to CHANGELOG.md OR such an update is not necessary
  • This PR includes any and all required license headers
  • This PR ensures that database migration sequence is correct OR this PR does not include a database migration
  • This PR DOES NOT FIX A SERIOUS SECURITY VULNERABILITY (see the Apache Software Foundation's security guidelines for details)

@mitchell852 mitchell852 added cdn-in-a-box related to the Docker-based CDN-in-a-Box system documentation related to documentation TO Client (Go) related to the Go implementation of a TC client Traffic Ops related to Traffic Ops Traffic Portal v1 related to Traffic Portal version 1 Traffic Router related to Traffic Router labels Apr 20, 2020
Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to be clear, this PR removes support for the cacheurl, but does not remove it from the API? Like it'll always show it as null in responses because if you do a POST with some cacheurl value that doesn't get unmarshaled and doesn't get stored in the database, but from what I can see the structures marshaled for responses still have it.

I'm also not sure if imparting that behavior on API versions 1.x and 2.x constitutes a breaking change.

@shamrickus
Copy link
Member Author

shamrickus commented Jun 15, 2020

So to be clear, this PR removes support for the cacheurl, but does not remove it from the API? Like it'll always show it as null in responses because if you do a POST with some cacheurl value that doesn't get unmarshaled and doesn't get stored in the database, but from what I can see the structures marshaled for responses still have it.

Only when querying old API versions on an update server. V3 should not have these fields while v1/v2 should.

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compile error at traffic_ops/traffic_ops_golang/routing/routes.go:1232:119:

undefined: atscdn.GetCacheURLDotConfig

@ocket8888
Copy link
Contributor

So like I was saying before, this removes support for cacheurl, but does not actually remove it from the API? I can still see it in v3:

GET /api/3.0/deliveryservices?limit=1 HTTP/1.1
User-Agent: python-requests/2.22.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Cookie: mojolicious=eyJhdXRoX2RhdGEiOiJhZG1pbiIsImV4cGlyZXMiOjE1OTI5NTcyNjgsImJ5IjoidHJhZmZpY2NvbnRyb2wtZ28tdG9jb29raWUifQ--625c11141971227d3862de47c92810086ebd7389

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Set-Cookie, Cookie
Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
Access-Control-Allow-Origin: *
Content-Encoding: gzip
Content-Type: application/json
Set-Cookie: mojolicious=eyJhdXRoX2RhdGEiOiJhZG1pbiIsImV4cGlyZXMiOjE1OTI5MzkyNjgsImJ5IjoidHJhZmZpY2NvbnRyb2wtZ28tdG9jb29raWUifQ--784bea340410815bda72048f7fa1c6cc6520e590; Path=/; Expires=Tue, 23 Jun 2020 19:07:48 GMT; Max-Age=3600; HttpOnly
Vary: Accept-Encoding
Whole-Content-Sha512: 94qFFF5yps/vfOFe/E3M285fBWJzgmpylXwwdGf4xa8w/J32nPboY2jgd2Ehi52jt1pK0zYtOc+Vtud3f/rVSA==
X-Server-Name: traffic_ops_golang/
Date: Tue, 23 Jun 2020 18:07:48 GMT
Content-Length: 806

{
	"response": [
		{
			"active": true,
			"anonymousBlockingEnabled": false,
			"cacheurl": null,
			"ccrDnsTtl": null,
			"cdnId": 2,
			"cdnName": "CDN-in-a-Box",
			"checkPath": null,
			"displayName": "Demo 1",
			"dnsBypassCname": null,
			"dnsBypassIp": null,
			"dnsBypassIp6": null,
			"dnsBypassTtl": null,
			"dscp": 0,
			"edgeHeaderRewrite": null,
			"geoLimit": 0,
			"geoLimitCountries": null,
			"geoLimitRedirectURL": null,
			"geoProvider": 0,
			"globalMaxMbps": null,
			"globalMaxTps": null,
			"httpBypassFqdn": null,
			"id": 1,
			"infoUrl": null,
			"initialDispersion": 1,
			"ipv6RoutingEnabled": true,
			"lastUpdated": "2020-06-23 18:04:18+00",
			"logsEnabled": true,
			"longDesc": "Apachecon North America 2018",
			"longDesc1": null,
			"longDesc2": null,
			"matchList": [
				{
					"type": "HOST_REGEXP",
					"setNumber": 0,
					"pattern": ".*\\.demo1\\..*"
				}
			],
			"maxDnsAnswers": null,
			"midHeaderRewrite": null,
			"missLat": 42,
			"missLong": -88,
			"multiSiteOrigin": false,
			"originShield": null,
			"orgServerFqdn": "http://origin.infra.ciab.test",
			"profileDescription": null,
			"profileId": null,
			"profileName": null,
			"protocol": 2,
			"qstringIgnore": 0,
			"rangeRequestHandling": 0,
			"regexRemap": null,
			"regionalGeoBlocking": false,
			"remapText": null,
			"routingName": "video",
			"signed": false,
			"sslKeyVersion": null,
			"tenantId": 1,
			"type": "HTTP",
			"typeId": 1,
			"xmlId": "demo1",
			"exampleURLs": [
				"http://video.demo1.mycdn.ciab.test",
				"https://video.demo1.mycdn.ciab.test"
			],
			"deepCachingType": "NEVER",
			"fqPacingRate": null,
			"signingAlgorithm": null,
			"tenant": "root",
			"trResponseHeaders": null,
			"trRequestHeaders": null,
			"consistentHashRegex": null,
			"consistentHashQueryParams": [
				"abc",
				"pdq",
				"xxx",
				"zyx"
			],
			"maxOriginConnections": 0,
			"ecsEnabled": false,
			"rangeSliceBlockSize": null,
			"topology": null
		}
	]
}

@shamrickus
Copy link
Member Author

With my original changes that didn't remove the unused methods this was not possible. Since those have now been removed I can remove it from the v3 api.

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API/client integration tests (v1) broken:

# github.com/apache/trafficcontrol/traffic_ops/testing/api/v1 [github.com/apache/trafficcontrol/traffic_ops/testing/api/v1.test]
./deliveryservices_test.go:362:35: ds.DeliveryServiceNullableV11 undefined (type tc.DeliveryServiceNullable has no field or method DeliveryServiceNullableV11)
FAIL	github.com/apache/trafficcontrol/traffic_ops/testing/api/v1 [build failed]

v2 tests pass

v3 tests failing on TestDeliveryServices with:

    topologies_test.go:57: Response:  &{{a topology my-topology [{0 parentCachegroup [] <nil>} {0 secondaryCachegroup [] <nil>} {0 cachegroup1 [0 1] <nil>}] <nil>} {[{topology was created. success}]}}
    topologies_test.go:57: Response:  &{{another topology another-topology [{0 parentCachegroup [] <nil>} {0 cachegroup1 [0] <nil>} {0 secondaryCachegroup [] <nil>} {0 cachegroup2 [2] <nil>}] <nil>} {[{topology was created. success}]}}
    topologies_test.go:57: Response:  &{{A topology with secondary parents secondary-parents [{0 parentCachegroup [] <nil>} {0 cachegroup1 [0 2] <nil>} {0 secondaryCachegroup [] <nil>} {0 fallback1 [2 0] <nil>} {0 fallback2 [2 0] <nil>}] <nil>} {[{topology was created. success}]}}
    topologies_test.go:57: Response:  &{{A 4-tier topology 4-tiers [{0 parentCachegroup [] <nil>} {0 parentCachegroup2 [0] <nil>} {0 cachegroup1 [1] <nil>} {0 secondaryCachegroup [1 0] <nil>} {0 fallback1 [3] <nil>}] <nil>} {[{topology was created. success}]}}
    deliveryservices_test.go:248: expected: no error updating topology-based header rewrite fields for topology-based DS, actual: 404 Not Found[404] - Error requesting Traffic Ops https://localhost:6443/api/3.0/deliveryservices/215 {"alerts":[{"text":"topology not found","level":"error"}]}

@shamrickus
Copy link
Member Author

Test failures should be fixed now

@ocket8888
Copy link
Contributor

Seeing this in the v1 tests:

 deliveryservices_test.go:121: cannot UPDATE DeliveryService by ID: 500 Internal Server Error[500] - Error requesting Traffic Ops https://localhost:6443/api/1.5/deliveryservices/65.json {"alerts":[{"text":"Internal Server Error","level":"error"}]}
         - <nil>
    deliveryservices_test.go:134: results do not match actual: d s 1, expected: something different
    deliveryservices_test.go:135: results do not match actual: 0, expected: 164598
    deliveryservices_test.go:136: results do not match actual: 0, expected: 100
    deliveryservices_test.go:170: cannot UPDATE DeliveryService by ID: 500 Internal Server Error[500] - Error requesting Traffic Ops https://localhost:6443/api/1.5/deliveryservices/65.json {"alerts":[{"text":"Internal Server Error","level":"error"}]}
         - <nil>

@shamrickus
Copy link
Member Author

v1 issues should be fixed

@mitchell852
Copy link
Member

just following up on status of this. is this waiting for after 5.0 release?

@shamrickus
Copy link
Member Author

At the least, probably best for whatever release perl gets removed in.

@shamrickus
Copy link
Member Author

Should be ready for re-review. Not mentioned in the original PR but it is good to also test compatibility with old versions.

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should only edit the tc-fixtures.json in v4/ - also, why'd you delete the userdeliveryservices_test.go file in v1/?

Also, I think you already know this, but the docs have a bunch of references to the now-undefined ds-cacheurl label.

@ocket8888 ocket8888 self-assigned this Feb 8, 2021
Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding GoDoc comments to the new exported symbols?

Copy link
Contributor

@rawlinp rawlinp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a bunch of comments as I went along, but it might be easier to understand if you go through all the comments first before making changes. Basically it boils down to reducing duplication and making it easier to make future changes to the DS API.

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This changes DSRs to use APIv4 Delivery Services - across all API versions - which is technically a breaking change. But the only fixes are to either quadruple the DSR handling code or rewrite it to not use the CRUDer. Since the latter is already in progress, I'm inclined to let that be tomorrow's problem.

@ocket8888 ocket8888 requested a review from rawlinp February 17, 2021 21:17
dsNullable := tc.DeliveryServiceNullableV30(dsV31)
ds := dsNullable.UpgradeToV4()
res, status, userErr, sysErr := createV40(w, r, inf, tc.DeliveryServiceV40(ds))
if res == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be checking userErr != nil || sysErr != nil instead?

Copy link
Member Author

@shamrickus shamrickus Feb 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just doing what the previous versions of this function did (but flipped). It looks like if there is an error in createV40, res will always be nil, otherwise it will have a value. I can still change it, but if I think it would make sense to also change all the create/updateV{old} functions too since they do the same thing.

@rawlinp rawlinp merged commit 56ef357 into apache:master Feb 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cdn-in-a-box related to the Docker-based CDN-in-a-Box system documentation related to documentation TO Client (Go) related to the Go implementation of a TC client Traffic Ops related to Traffic Ops Traffic Portal v1 related to Traffic Portal version 1 Traffic Router related to Traffic Router

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cache url expression configs do not get added to mid profiles

5 participants