Skip to content

Commit

Permalink
Fixed ASN Update logic for APIv5 (#7767)
Browse files Browse the repository at this point in the history
* fixing the logic for asn-update for v5

* update changelog
  • Loading branch information
rimashah25 committed Aug 31, 2023
1 parent e835435 commit 2257ddb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#7765](https://github.com/apache/trafficcontrol/pull/7765) *Traffic Stats* now uses Traffic Ops APIv5

### Fixed
- [#7767](https://github.com/apache/trafficcontrol/pull/7767) *Traffic Ops* Fixed ASN update logic for APIv5
- [RFC3339](https://github.com/apache/trafficcontrol/issues/5911)
- [#7759](https://github.com/apache/trafficcontrol/pull/7759) *Traffic Ops* Fixed `/profiles/{{ID}}/parameters` and `profiles/name/{{name}}/parameters` v5 APIs to respond with `RFC3339` timestamps.
- [#7734](https://github.com/apache/trafficcontrol/pull/7734) *Traffic Ops* Fixed `/profiles` v5 APIs to respond with `RFC3339` timestamps.
Expand Down
8 changes: 4 additions & 4 deletions traffic_ops/traffic_ops_golang/asn/asns.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ func Update(w http.ResponseWriter, r *http.Request) {
}

// check if asn already exists
var count int
err := tx.QueryRow("SELECT count(*) from asn where asn=$1", asn.ASN).Scan(&count)
if err != nil {
var id int
err := tx.QueryRow("SELECT id from asn where asn=$1", asn.ASN).Scan(&id)
if err != nil && err != sql.ErrNoRows {
api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, fmt.Errorf("error: %w, when checking if asn '%d' exists", err, asn.ASN))
return
}
if count == 1 {
if id != 0 && id != requestedAsnId {
api.HandleErr(w, r, tx, http.StatusBadRequest, fmt.Errorf("asn:'%d' already exists", asn.ASN), nil)
return
}
Expand Down

0 comments on commit 2257ddb

Please sign in to comment.