You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by da...@apache.org on 2018/07/04 02:39:31 UTC
[trafficcontrol] 06/15: fix bug with insert query introduced by
conflict
This is an automated email from the ASF dual-hosted git repository.
dangogh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit c679b4999ded10eca26e10d6005079376b023e6d
Author: Dylan Volz <Dy...@comcast.com>
AuthorDate: Tue Jun 26 22:51:58 2018 -0600
fix bug with insert query introduced by conflict
---
.../deliveryservice/deliveryservicesv13.go | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go
index 10d3182..3eab671 100644
--- a/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go
+++ b/traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go
@@ -50,7 +50,7 @@ type TODeliveryServiceV13 struct {
}
func (ds *TODeliveryServiceV13) V12() *TODeliveryServiceV12 {
- return &TODeliveryServiceV12{DeliveryServiceNullableV12: ds.DeliveryServiceNullableV12}
+ return &TODeliveryServiceV12{ReqInfo:ds.ReqInfo, DeliveryServiceNullableV12: ds.DeliveryServiceNullableV12}
}
func (ds TODeliveryServiceV13) MarshalJSON() ([]byte, error) {
@@ -119,20 +119,18 @@ func CreateV13() http.HandlerFunc {
defer inf.Close()
ds := tc.DeliveryServiceNullableV13{}
- if err := json.NewDecoder(r.Body).Decode(&ds); err != nil {
- api.HandleErr(w, r, http.StatusBadRequest, errors.New("malformed JSON: "+err.Error()), nil)
+ if err := api.Parse(r.Body, inf.Tx.Tx, &ds); err != nil {
+ api.HandleErr(w, r, http.StatusBadRequest, errors.New("decoding: "+err.Error()), nil)
return
}
if ds.RoutingName == nil || *ds.RoutingName == "" {
ds.RoutingName = util.StrPtr("cdn")
}
-
if errs := ds.Validate(inf.Tx.Tx); len(errs) > 0 {
api.HandleErr(w, r, http.StatusBadRequest, errors.New("invalid request: "+util.JoinErrs(errs).Error()), nil)
return
}
-
if authorized, err := isTenantAuthorized(inf.User, inf.Tx, &ds.DeliveryServiceNullableV12); err != nil {
api.HandleErr(w, r, http.StatusInternalServerError, nil, errors.New("checking tenant: "+err.Error()))
return
@@ -140,7 +138,6 @@ func CreateV13() http.HandlerFunc {
api.HandleErr(w, r, http.StatusForbidden, errors.New("not authorized on this tenant"), nil)
return
}
-
ds, errCode, userErr, sysErr = create(inf.Tx.Tx, *inf.Config, inf.User, ds)
if userErr != nil || sysErr != nil {
api.HandleErr(w, r, errCode, userErr, sysErr)
@@ -160,8 +157,7 @@ func create(tx *sql.Tx, cfg config.Config, user *auth.CurrentUser, ds tc.Deliver
deepCachingType = ds.DeepCachingType.String() // necessary, because DeepCachingType's default needs to insert the string, not "", and Query doesn't call .String().
}
- resultRows, err := tx.Query(insertQuery(), &ds.Active, &ds.CacheURL, &ds.CCRDNSTTL, &ds.CDNID, &ds.CheckPath, &deepCachingType, &ds.DisplayName, &ds.DNSBypassCNAME, &ds.DNSBypassIP, &ds.DNSBypassIP6, &ds.DNSBypassTTL, &ds.DSCP, &ds.EdgeHeaderRewrite, &ds.GeoLimitRedirectURL, &ds.GeoLimit, &ds.GeoLimitCountries, &ds.GeoProvider, &ds.GlobalMaxMBPS, &ds.GlobalMaxTPS, &ds.FQPacingRate, &ds.HTTPBypassFQDN, &ds.InfoURL, &ds.InitialDispersion, &ds.IPV6RoutingEnabled, &ds.LogsEnabled, &ds.LongD [...]
-
+ resultRows, err := tx.Query(insertQuery(), &ds.Active, &ds.AnonymousBlockingEnabled, &ds.CacheURL, &ds.CCRDNSTTL, &ds.CDNID, &ds.CheckPath, &deepCachingType, &ds.DisplayName, &ds.DNSBypassCNAME, &ds.DNSBypassIP, &ds.DNSBypassIP6, &ds.DNSBypassTTL, &ds.DSCP, &ds.EdgeHeaderRewrite, &ds.GeoLimitRedirectURL, &ds.GeoLimit, &ds.GeoLimitCountries, &ds.GeoProvider, &ds.GlobalMaxMBPS, &ds.GlobalMaxTPS, &ds.FQPacingRate, &ds.HTTPBypassFQDN, &ds.InfoURL, &ds.InitialDispersion, &ds.IPV6RoutingEnabl [...]
if err != nil {
if pqerr, ok := err.(*pq.Error); ok {
err, _ := dbhelpers.ParsePQUniqueConstraintError(pqerr)
@@ -575,7 +571,7 @@ func update(tx *sql.Tx, cfg config.Config, user *auth.CurrentUser, ds *tc.Delive
//The DeliveryService implementation of the Deleter interface
//all implementations of Deleter should use transactions and return the proper errorType
func (ds *TODeliveryServiceV13) Delete() (error, tc.ApiErrorType) {
- return GetTypeV12Factory()(ds.ReqInfo).Delete()
+ return ds.V12().Delete()
}
// IsTenantAuthorized implements the Tenantable interface to ensure the user is authorized on the deliveryservice tenant