Skip to content

Commit

Permalink
setting the updated logConfig values on node pods during node registr…
Browse files Browse the repository at this point in the history
…ation.
  • Loading branch information
shashank-netapp authored Apr 11, 2024
1 parent 9e48130 commit fcb152b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/orchestrator_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5150,6 +5150,16 @@ func (o *TridentOrchestrator) AddNode(
node.PublicationState = existingNode.PublicationState
}

// Setting log level, log workflows and log layers on the node same as to what is set on the controller.
logLevel := GetDefaultLogLevel()
node.LogLevel = logLevel

logWorkflows := GetSelectedWorkFlows()
node.LogWorkflows = logWorkflows

logLayers := GetSelectedLogLayers()
node.LogLayers = logLayers

if err = o.storeClient.AddOrUpdateNode(ctx, node); err != nil {
return
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/csi/controller_api/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ func (c *ControllerRestClient) InvokeAPI(

type CreateNodeResponse struct {
TopologyLabels map[string]string `json:"topologyLabels"`
LogLevel string `json:"logLevel"`
LogWorkflows string `json:"logWorkflows"`
LogLayers string `json:"logLayers"`
}

// CreateNode registers the node with the CSI controller server
Expand Down
11 changes: 11 additions & 0 deletions frontend/csi/node_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,17 @@ func (p *Plugin) nodeRegisterWithController(ctx context.Context, timeout time.Du
if err == nil {
topologyLabels = nodeDetails.TopologyLabels
node.TopologyLabels = nodeDetails.TopologyLabels

// Setting log level, log workflows and log layers on the node same as to what is set on the controller.
if err = p.orchestrator.SetLogLevel(ctx, nodeDetails.LogLevel); err != nil {
Logc(ctx).WithError(err).Error("Unable to set log level.")
}
if err = p.orchestrator.SetLoggingWorkflows(ctx, nodeDetails.LogWorkflows); err != nil {
Logc(ctx).WithError(err).Error("Unable to set logging workflows.")
}
if err = p.orchestrator.SetLogLayers(ctx, nodeDetails.LogLayers); err != nil {
Logc(ctx).WithError(err).Error("Unable to set logging layers.")
}
}
return err
}
Expand Down
10 changes: 10 additions & 0 deletions frontend/rest/controller_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,9 @@ func DeleteStorageClass(w http.ResponseWriter, r *http.Request) {
type AddNodeResponse struct {
Name string `json:"name"`
TopologyLabels map[string]string `json:"topologyLabels,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
LogWorkflows string `json:"logWorkflows,omitempty"`
LogLayers string `json:"logLayers,omitempty"`
Error string `json:"error,omitempty"`
}

Expand Down Expand Up @@ -947,6 +950,9 @@ func AddNode(w http.ResponseWriter, r *http.Request) {
Name: "",
TopologyLabels: make(map[string]string),
Error: "",
LogLayers: "",
LogLevel: "",
LogWorkflows: "",
}

const auditMsg = "AddNode endpoint called."
Expand Down Expand Up @@ -997,11 +1003,15 @@ func AddNode(w http.ResponseWriter, r *http.Request) {
nodeEventCallback := func(eventType, reason, message string) {
helper.RecordNodeEvent(ctx, node.Name, eventType, reason, message)
}

err = orchestrator.AddNode(ctx, node, nodeEventCallback)
if err != nil {
response.setError(err)
}
updateResponse.Name = node.Name
updateResponse.LogLevel = node.LogLevel
updateResponse.LogWorkflows = node.LogWorkflows
updateResponse.LogLayers = node.LogLayers
return httpStatusCodeForAdd(err)
},
)
Expand Down
3 changes: 3 additions & 0 deletions persistent_store/crd/apis/netapp/v1/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func (in *TridentNode) Apply(persistent *utils.Node) error {
in.IPs = persistent.IPs
in.Deleted = persistent.Deleted
in.PublicationState = string(persistent.PublicationState)
in.LogLevel = persistent.LogLevel
in.LogWorkflows = persistent.LogWorkflows
in.LogLayers = persistent.LogLayers

nodePrep, err := json.Marshal(persistent.NodePrep)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions persistent_store/crd/apis/netapp/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,12 @@ type TridentNode struct {
Deleted bool `json:"deleted"`
// PublicationState indicates whether the node is safe for volume publications
PublicationState string `json:"publicationState"`
// LogLevel indicates the log level which is currently set for the node
LogLevel string `json:"logLevel"`
// LogWorkflows indicates the selected workflows which are currently set for the node
LogWorkflows string `json:"logWorkflows"`
// LogLayers indicates the selected log layers which are currently set for the node
LogLayers string `json:"logLayers"`
}

// TridentNodeList is a list of TridentNode objects.
Expand Down
9 changes: 9 additions & 0 deletions utils/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ type Node struct {
HostInfo *HostSystem `json:"hostInfo,omitempty"`
Deleted bool `json:"deleted"`
PublicationState NodePublicationState `json:"publicationState"`
LogLevel string `json:"logLevel"`
LogWorkflows string `json:"logWorkflows"`
LogLayers string `json:"logLayers"`
}

type NodeExternal struct {
Expand All @@ -180,6 +183,9 @@ type NodeExternal struct {
HostInfo *HostSystem `json:"hostInfo,omitempty"`
Deleted *bool `json:"deleted,omitempty"`
PublicationState NodePublicationState `json:"publicationState,omitempty"`
LogLevel string `json:"logLevel"`
LogWorkflows string `json:"logWorkflows"`
LogLayers string `json:"logLayers"`
}

func (n *Node) Copy() *Node {
Expand Down Expand Up @@ -209,6 +215,9 @@ func (n *Node) ConstructExternal() *NodeExternal {
HostInfo: node.HostInfo,
Deleted: Ptr(node.Deleted),
PublicationState: node.PublicationState,
LogLevel: node.LogLevel,
LogWorkflows: node.LogWorkflows,
LogLayers: node.LogLayers,
}
}

Expand Down

0 comments on commit fcb152b

Please sign in to comment.