[GitHub] [trafficcontrol] srijeet0406 commented on a diff in pull request #7079: Assign multiple servers to a capability
srijeet0406 commented on code in PR #7079: URL: https://github.com/apache/trafficcontrol/pull/7079#discussion_r1007454984 ## traffic_ops/traffic_ops_golang/server/servers_server_capability.go: ## @@ -453,77 +443,185 @@ func AssignMultipleServerCapabilities(w http.ResponseWriter, r *http.Request) { } defer inf.Close() - var msc tc.MultipleServerCapabilities - if err := json.NewDecoder(r.Body).Decode(); err != nil { - api.HandleErr(w, r, tx, http.StatusBadRequest, err, nil) + var mssc tc.MultipleServersCapabilities + if err := json.NewDecoder(r.Body).Decode(); err != nil { + api.HandleErr(w, r, tx, http.StatusBadRequest, fmt.Errorf("error decoding POST request body into MultipleServersCapabilities struct %w", err), nil) return } - // Check existence prior to checking type - _, exists, err := dbhelpers.GetServerNameFromID(tx, int64(msc.ServerID)) - if err != nil { - api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, err) - } - if !exists { - userErr := fmt.Errorf("server %d does not exist", msc.ServerID) - api.HandleErr(w, r, tx, http.StatusNotFound, userErr, nil) - return + if len(mssc.ServerIDs) >= 1 { + errCode, userErr, sysErr = checkExistingServer(tx, mssc.ServerIDs, inf.User.UserName) + if userErr != nil || sysErr != nil { + api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr) + return + } } // Ensure type is correct - correctType := true - if err := tx.QueryRow(scCheckServerTypeQuery(), msc.ServerID).Scan(); err != nil { - api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, fmt.Errorf("checking server type: %w", err)) + errCode, userErr, sysErr = checkServerType(tx, mssc.ServerIDs) + if userErr != nil || sysErr != nil { + api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr) return } - if !correctType { - userErr := fmt.Errorf("server %d has an incorrect server type. Server capabilities can only be assigned to EDGE or MID servers", msc.ServerID) - api.HandleErr(w, r, tx, http.StatusBadRequest, userErr, nil) - return + + // Insert rows in DB + sid := make([]int64, len(mssc.ServerCapabilities)) + scs := make([]string, len(mssc.ServerIDs)) + if len(mssc.ServerIDs) == 1 { Review Comment: I thought the whole point of adding the pagetype was so that we didn't have to do length checks anymore? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] srijeet0406 commented on a diff in pull request #7079: Assign multiple servers to a capability
srijeet0406 commented on code in PR #7079: URL: https://github.com/apache/trafficcontrol/pull/7079#discussion_r1007454708 ## traffic_ops/traffic_ops_golang/server/servers_server_capability.go: ## @@ -453,77 +443,185 @@ func AssignMultipleServerCapabilities(w http.ResponseWriter, r *http.Request) { } defer inf.Close() - var msc tc.MultipleServerCapabilities - if err := json.NewDecoder(r.Body).Decode(); err != nil { - api.HandleErr(w, r, tx, http.StatusBadRequest, err, nil) + var mssc tc.MultipleServersCapabilities + if err := json.NewDecoder(r.Body).Decode(); err != nil { + api.HandleErr(w, r, tx, http.StatusBadRequest, fmt.Errorf("error decoding POST request body into MultipleServersCapabilities struct %w", err), nil) return } - // Check existence prior to checking type - _, exists, err := dbhelpers.GetServerNameFromID(tx, int64(msc.ServerID)) - if err != nil { - api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, err) - } - if !exists { - userErr := fmt.Errorf("server %d does not exist", msc.ServerID) - api.HandleErr(w, r, tx, http.StatusNotFound, userErr, nil) - return + if len(mssc.ServerIDs) >= 1 { + errCode, userErr, sysErr = checkExistingServer(tx, mssc.ServerIDs, inf.User.UserName) + if userErr != nil || sysErr != nil { + api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr) + return + } } // Ensure type is correct - correctType := true - if err := tx.QueryRow(scCheckServerTypeQuery(), msc.ServerID).Scan(); err != nil { - api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, fmt.Errorf("checking server type: %w", err)) + errCode, userErr, sysErr = checkServerType(tx, mssc.ServerIDs) + if userErr != nil || sysErr != nil { + api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr) return } - if !correctType { - userErr := fmt.Errorf("server %d has an incorrect server type. Server capabilities can only be assigned to EDGE or MID servers", msc.ServerID) - api.HandleErr(w, r, tx, http.StatusBadRequest, userErr, nil) - return + + // Insert rows in DB + sid := make([]int64, len(mssc.ServerCapabilities)) + scs := make([]string, len(mssc.ServerIDs)) + if len(mssc.ServerIDs) == 1 { + if len(mssc.ServerCapabilities) >= 1 { + for i := range mssc.ServerCapabilities { + sid[i] = mssc.ServerIDs[0] + } + scs = mssc.ServerCapabilities + } + } else if len(mssc.ServerCapabilities) == 1 { + if len(mssc.ServerIDs) >= 1 { + for i := range mssc.ServerIDs { + scs[i] = mssc.ServerCapabilities[0] + } + sid = mssc.ServerIDs + } + } else { + scs = mssc.ServerCapabilities + sid = mssc.ServerIDs } - cdnName, err := dbhelpers.GetCDNNameFromServerID(tx, int64(msc.ServerID)) + msscQuery := `INSERT INTO server_server_capability + select "server_capability", "server" + FROM UNNEST($1::text[], $2::int[]) AS tmp("server_capability", "server")` + _, err := tx.Query(msscQuery, pq.Array(scs), pq.Array(sid)) if err != nil { - api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, err) + useErr, sysErr, statusCode := api.ParseDBError(err) + api.HandleErr(w, r, tx, statusCode, useErr, sysErr) return } - userErr, sysErr, errCode = dbhelpers.CheckIfCurrentUserCanModifyCDN(tx, string(cdnName), inf.User.UserName) + var alerts tc.Alerts + if mssc.PageType == "sc" { + alerts = tc.CreateAlerts(tc.SuccessLevel, "Assign Server(s) to a capability") + } else { + alerts = tc.CreateAlerts(tc.SuccessLevel, "Assign Server Capability(ies) to a server") + } + api.WriteAlertsObj(w, r, http.StatusOK, alerts, mssc) + return +} + +// DeleteMultipleServersCapabilities deletes multiple servers to a capability or multiple server capabilities to a server +func DeleteMultipleServersCapabilities(w http.ResponseWriter, r *http.Request) { + inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil) + tx := inf.Tx.Tx if userErr != nil || sysErr != nil { - api.HandleErr(w, r, tx, errCode, userErr, sysErr) + api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr) return } + defer inf.Close() -
[GitHub] [trafficcontrol] ocket8888 merged pull request #7160: Consider DS Regional field for MaxOriginConnections of Edge Caches
ocket merged PR #7160: URL: https://github.com/apache/trafficcontrol/pull/7160 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] zrhoffman commented on pull request #7162: updated tomcat version to 1.2.35
zrhoffman commented on PR #7162: URL: https://github.com/apache/trafficcontrol/pull/7162#issuecomment-1293800151 Although this works, the next time the tomcat-native version is updated, it should be something like `tomcat-native-1.*`, since any tomcat-native version 1 will work (version 2 breaks TR currently) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] zrhoffman merged pull request #7162: updated tomcat version to 1.2.35
zrhoffman merged PR #7162: URL: https://github.com/apache/trafficcontrol/pull/7162 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] ragen14 opened a new pull request, #7162: updated tomcat version to 1.2.35
ragen14 opened a new pull request, #7162: URL: https://github.com/apache/trafficcontrol/pull/7162 ## Which Traffic Control components are affected by this PR? - Traffic Router - Automation ## What is the best way to verify this PR? install traffic router using TR role in ansible ## If this is a bugfix, which Traffic Control versions contained the bug? N/A ## PR submission checklist - [x] This PR has tests - [x] This PR has documentation - [x] This PR has a CHANGELOG.md entry - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://apache.org/security) for details) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] zrhoffman commented on a diff in pull request #7160: Consider DS Regional field for MaxOriginConnections of Edge Caches
zrhoffman commented on code in PR #7160: URL: https://github.com/apache/trafficcontrol/pull/7160#discussion_r1007114313 ## lib/go-atscfg/headerrewritedotconfig_test.go: ## @@ -496,42 +407,91 @@ func TestGetAssignedMids(t *testing.T) { ID: util.Ptr(2), Status: util.Ptr(string(tc.CacheStatusReported)), }, - + } + mids := []Server{ { Cachegroup: util.Ptr("mid1"), CDNName:util.Ptr("mycdn"), HostName: util.Ptr("midCache1"), ID: util.Ptr(3), Status: util.Ptr(string(tc.CacheStatusReported)), + Type: tc.MidTypePrefix, }, { Cachegroup: util.Ptr("mid2"), CDNName:util.Ptr("mycdn"), HostName: util.Ptr("midCache2"), ID: util.Ptr(4), Status: util.Ptr(string(tc.CacheStatusReported)), + Type: tc.MidTypePrefix, }, } + allServers := append(edges, mids...) + _ = allServers - allDeliveryServices := []DeliveryService{{}, {}} + topology := tc.Topology{ + Name: "mytopology", + Nodes: []tc.TopologyNode{ + { + Cachegroup: "edge1", + Parents:[]int{2}, + }, + { + Cachegroup: "edge2", + Parents:[]int{2}, + }, + { + Cachegroup: "org1", + }, + }, + } + _ = topology Review Comment: Removed do-nothing lines in 3b25d1aeae -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] ocket8888 commented on a diff in pull request #7160: Consider DS Regional field for MaxOriginConnections of Edge Caches
ocket commented on code in PR #7160: URL: https://github.com/apache/trafficcontrol/pull/7160#discussion_r1007048872 ## lib/go-atscfg/headerrewritedotconfig_test.go: ## @@ -496,42 +407,91 @@ func TestGetAssignedMids(t *testing.T) { ID: util.Ptr(2), Status: util.Ptr(string(tc.CacheStatusReported)), }, - + } + mids := []Server{ { Cachegroup: util.Ptr("mid1"), CDNName:util.Ptr("mycdn"), HostName: util.Ptr("midCache1"), ID: util.Ptr(3), Status: util.Ptr(string(tc.CacheStatusReported)), + Type: tc.MidTypePrefix, }, { Cachegroup: util.Ptr("mid2"), CDNName:util.Ptr("mycdn"), HostName: util.Ptr("midCache2"), ID: util.Ptr(4), Status: util.Ptr(string(tc.CacheStatusReported)), + Type: tc.MidTypePrefix, }, } + allServers := append(edges, mids...) + _ = allServers - allDeliveryServices := []DeliveryService{{}, {}} + topology := tc.Topology{ + Name: "mytopology", + Nodes: []tc.TopologyNode{ + { + Cachegroup: "edge1", + Parents:[]int{2}, + }, + { + Cachegroup: "edge2", + Parents:[]int{2}, + }, + { + Cachegroup: "org1", + }, + }, + } + _ = topology Review Comment: I think this line does literally nothing -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] rimashah25 commented on a diff in pull request #7099: Delivery Service Active Flag Rework
rimashah25 commented on code in PR #7099: URL: https://github.com/apache/trafficcontrol/pull/7099#discussion_r1006437034 ## traffic_ops/testing/api/v4/tc-fixtures.json: ## @@ -907,7 +907,7 @@ "regexRemap": null, "regionalGeoBlocking": false, "remapText": null, -"routingName": "cdn", +"routingName": "ccr-ds1", Review Comment: oh.. ok -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [trafficcontrol] rimashah25 commented on a diff in pull request #7099: Delivery Service Active Flag Rework
rimashah25 commented on code in PR #7099: URL: https://github.com/apache/trafficcontrol/pull/7099#discussion_r1006436587 ## traffic_ops/v5-client/deliveryservice_requests.go: ## @@ -58,31 +58,31 @@ func (to *Session) CreateDeliveryServiceRequest(dsr tc.DeliveryServiceRequestV4, dsr.AuthorID = res.Response[0].ID } - var ds *tc.DeliveryServiceV4 + var ds *tc.DeliveryServiceV5 if dsr.ChangeType == tc.DSRChangeTypeDelete { ds = dsr.Original } else { ds = dsr.Requested } - if ds.TypeID == nil && ds.Type.String() != "" { + if ds.TypeID <= 0 && ds.Type != nil && *ds.Type != "" { Review Comment: Ok, Thanks for the explanation. You can resolve this comment. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@trafficcontrol.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org