[VOL-3187]Pass Context down the execution call hierarchy across ofagent codebase
Change-Id: Ia5f2fa1509beefe0ddc427b83e39d2702782db8f
diff --git a/internal/pkg/openflow/client.go b/internal/pkg/openflow/client.go
index 635c712..86bb6b9 100644
--- a/internal/pkg/openflow/client.go
+++ b/internal/pkg/openflow/client.go
@@ -114,7 +114,7 @@
}
type RoleManager interface {
- UpdateRoles(from string, request *ofp.RoleRequest) bool
+ UpdateRoles(ctx context.Context, from string, request *ofp.RoleRequest) bool
}
func distance(a uint64, b uint64) int64 {
@@ -122,8 +122,8 @@
}
// UpdateRoles validates a role request and updates role state for connections where it changed
-func (ofc *OFClient) UpdateRoles(from string, request *ofp.RoleRequest) bool {
- log.Debug("updating role", log.Fields{
+func (ofc *OFClient) UpdateRoles(ctx context.Context, from string, request *ofp.RoleRequest) bool {
+ logger.Debug(ctx, "updating role", log.Fields{
"from": from,
"to": request.Role,
"id": request.GenerationId})
@@ -168,7 +168,7 @@
// NewClient returns an initialized OFClient instance based on the configuration
// specified
-func NewOFClient(config *OFClient) *OFClient {
+func NewOFClient(ctx context.Context, config *OFClient) *OFClient {
ofc := OFClient{
DeviceID: config.DeviceID,
@@ -184,7 +184,7 @@
}
if ofc.ConnectionRetryDelay <= 0 {
- logger.Warnw("connection retry delay not valid, setting to default",
+ logger.Warnw(ctx, "connection retry delay not valid, setting to default",
log.Fields{
"device-id": ofc.DeviceID,
"value": ofc.ConnectionRetryDelay.String(),
@@ -228,10 +228,10 @@
}
}
-func (ofc *OFClient) SendMessage(message Message) error {
+func (ofc *OFClient) SendMessage(ctx context.Context, message Message) error {
for _, connection := range ofc.connections {
if connection.role == ofcRoleMaster || connection.role == ofcRoleEqual {
- err := connection.SendMessage(message)
+ err := connection.SendMessage(ctx, message)
if err != nil {
return err
}