Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Server Capabilities apis to respond with RFC3339 date/time Format #7408 #7482

Merged

Conversation

jagan-parthiban
Copy link
Contributor

@jagan-parthiban jagan-parthiban commented May 3, 2023

Closes: #7465
Related: #5911


  • Documentation
  • Traffic Ops

What is the best way to verify this PR?

Make Api calls to service_category 5.0

curl --request GET \
  --url https://localhost:8443/api/5.0/server_capabilities

{
	"response": [
		{
			"name": "disk",
			"lastUpdated": "2023-05-03T12:24:40.408349+05:30",
			"description": "server capability disk"
		},
		{
			"name": "ram",
			"lastUpdated": "2023-05-03T12:24:40.406796+05:30",
			"description": "server capability ram"
		}
	]
}

If this is a bugfix, which Traffic Control versions contained the bug?

  • 7.0.1

PR submission checklist

@jagan-parthiban jagan-parthiban marked this pull request as ready for review May 3, 2023 09:17
@ocket8888 ocket8888 added Traffic Ops related to Traffic Ops low impact affects only a small portion of a CDN, and cannot itself break one tech debt rework due to choosing easy/limited solution labels May 3, 2023

selectQuery := "SELECT name, description, last_updated FROM server_capability sc"
query := selectQuery + where + orderBy + pagination
rows, err := tx.NamedQuery(query, queryValues)

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources

This query depends on a [user-provided value](1).
Copy link
Member

Choose a reason for hiding this comment

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

This alert is valid but already exists in the current version, this is not a new vuln.

@codecov
Copy link

codecov bot commented May 3, 2023

Codecov Report

Merging #7482 (272d11b) into master (f87bcdf) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master    #7482      +/-   ##
============================================
- Coverage     30.32%   30.31%   -0.01%     
  Complexity       98       98              
============================================
  Files           789      789              
  Lines         82307    82304       -3     
  Branches        815      815              
============================================
- Hits          24957    24954       -3     
  Misses        55245    55245              
  Partials       2105     2105              
Flag Coverage Δ
traffic_ops_integration 69.42% <100.00%> (ø)
v3 57.79% <ø> (ø)
v4 79.18% <ø> (ø)
v5 78.63% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
traffic_ops/traffic_ops_golang/routing/routes.go 95.53% <ø> (-0.02%) ⬇️
...ic_ops_golang/servercapability/servercapability.go 15.20% <ø> (ø)
traffic_ops/v5-client/servercapability.go 87.50% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zrhoffman
Copy link
Member

@jagan-parthiban If you rebase this onto the master branch, the CiaB workflow should pass, since #7489 is what makes it fail

Copy link
Member

@zrhoffman zrhoffman left a comment

Choose a reason for hiding this comment

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

Type parameters were not in Go when this code was first written. Now that we need to support a new API version, we should be able to save a lot of lines of code using type parameters, rather than copying.

@@ -367,3 +367,157 @@ func (v *TOServerCapability) SelectMaxLastUpdatedQuery(where, orderBy, paginatio

func (v *TOServerCapability) Create() (error, error, int) { return api.GenericCreateNameBasedID(v) }
func (v *TOServerCapability) Delete() (error, error, int) { return api.GenericDelete(v) }

func GetServerCapabilityV5(w http.ResponseWriter, r *http.Request) {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than copying all of the content from GetServerCapability to GetServerCapabilityV5, we should be able to use the same function for either and use a type parameter for which ServerCapability type to use.


selectQuery := "SELECT name, description, last_updated FROM server_capability sc"
query := selectQuery + where + orderBy + pagination
rows, err := tx.NamedQuery(query, queryValues)
Copy link
Member

Choose a reason for hiding this comment

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

This alert is valid but already exists in the current version, this is not a new vuln.

return
}

func CreateServerCapabilityV5(w http.ResponseWriter, r *http.Request) {
Copy link
Member

@zrhoffman zrhoffman May 17, 2023

Choose a reason for hiding this comment

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

Same here: CreateServerCapability can be reused if it accepts a type parameter.

return
}

func UpdateServerCapabilityV5(w http.ResponseWriter, r *http.Request) {
Copy link
Member

@zrhoffman zrhoffman May 17, 2023

Choose a reason for hiding this comment

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

Same here: UpdateServerCapability can be reused if it accepts a type parameter.

@zrhoffman
Copy link
Member

On second thought, maybe this is a little complicated to be able to easily save time with generics. Once the branch is rebased onto the master branch, #7482 should be good to merge.

@jagan-parthiban jagan-parthiban force-pushed the improve/rfc3339-server-capabilities branch from be7638c to 0682d59 Compare May 18, 2023 17:40
Copy link
Member

@zrhoffman zrhoffman left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@zrhoffman zrhoffman merged commit 147db8d into apache:master May 18, 2023
@jagan-parthiban jagan-parthiban deleted the improve/rfc3339-server-capabilities branch June 8, 2023 10:50
@rimashah25 rimashah25 added this to the 8.0.0 milestone Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low impact affects only a small portion of a CDN, and cannot itself break one tech debt rework due to choosing easy/limited solution Traffic Ops related to Traffic Ops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server Capabilities in TO API uses non-RFC3339 date/time strings
4 participants