Skip to content

Commit

Permalink
Merge e9c6d44 into 0725c27
Browse files Browse the repository at this point in the history
  • Loading branch information
tanyatukade committed Apr 9, 2021
2 parents 0725c27 + e9c6d44 commit 5fc157c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
17 changes: 17 additions & 0 deletions cmd/crd-example/qos-CR.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: aci.qos/v1
kind: QosPolicy
metadata:
name: test-qos
namespace: default
spec:
podSelector:
matchLabels:
app: test
ingress:
policing_rate: 1000
policing_burst: 2000
egress:
policing_rate: 3000
policing_burst: 400
dscpmark: 25

20 changes: 11 additions & 9 deletions pkg/controller/qos.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ func (cont *AciController) initQosInformerBase(listWatch *cache.ListWatch) {
}

func (cont *AciController) qosPolicyUpdated(obj interface{}) {
qosPolicy := obj.(*qospolicy.QosPolicy)
qosPolicy, ok := obj.(*qospolicy.QosPolicy)
if !ok {
cont.log.Error("qosPolicyUpdated: Bad object type")
return
}
key, err := cache.MetaNamespaceKeyFunc(qosPolicy)
if err != nil {
QosPolicyLogger(cont.log, qosPolicy).
Error("Could not create key:" + err.Error())
return
}
cont.queueQosUpdateByKey(key)
cont.log.Infof("qos policy updated: %s", qosPolicy.ObjectMeta.Name)

}

Expand Down Expand Up @@ -125,17 +130,14 @@ func (cont *AciController) handleQosPolUpdate(obj interface{}) bool {
return false
}
labelKey := cont.aciNameForKey("qp", key)
cont.log.Debug("create qospolicy")
cont.log.Infof("Creating qos policy: %s", qp.ObjectMeta.Name)
qr := apicapi.NewQosRequirement(cont.config.AciPolicyTenant, labelKey)
qrDn := qr.GetDn()
apicSlice := apicapi.ApicSlice{qr}

// Pushing EpDscpMarking Mo if dscp_mark not equal to 0
if qp.Spec.Mark != 0 {
DscpMarking := apicapi.NewQosEpDscpMarking(qrDn, "EpDscpMarking")
DscpMarking.SetAttr("mark", strconv.Itoa(qp.Spec.Mark))
qr.AddChild(DscpMarking)
}
DscpMarking := apicapi.NewQosEpDscpMarking(qrDn, "EpDscpMarking")
DscpMarking.SetAttr("mark", strconv.Itoa(qp.Spec.Mark))
qr.AddChild(DscpMarking)

// Generate ingress policies
if qp.Spec.Ingress.PolicingRate != 0 && qp.Spec.Ingress.PolicingBurst != 0 {
Expand All @@ -162,7 +164,7 @@ func (cont *AciController) handleQosPolUpdate(obj interface{}) bool {
qr.AddChild(RsEgressDppPol)
apicSlice = append(apicSlice, DppPolEgress)
}

cont.log.Info("qos APIC slice: ", apicSlice)
cont.apicConn.WriteApicObjects(labelKey, apicSlice)

return false
Expand Down
12 changes: 10 additions & 2 deletions pkg/qospolicy/apis/aci.qos/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ type QosPolicySpec struct {
Selector PodSelector `json:"selector,omitempty"`
Ingress PolicingType `json:"ingress,omitempty"`
Egress PolicingType `json:"egress,omitempty"`
Mark int `json:"dscpmark,omitempty"`
// +kubebuilder:validation:Minimum=0
// +kubebuilder:validation:Minimum=63
// +kubebuilder:default:=0
// +optional
Mark int `json:"dscpmark,omitempty"`
}

//PolicingType
type PolicingType struct {
PolicingRate int `json:"policing_rate"`
// +kubebuilder:validation:Minimum=1
// +optional
PolicingRate int `json:"policing_rate"`
// +kubebuilder:validation:Minimum=1
// +optional
PolicingBurst int `json:"policing_burst"`
}

Expand Down

0 comments on commit 5fc157c

Please sign in to comment.