Skip to content

Commit

Permalink
Adding log for determining REST/ZAPI client and resolving gob encodin…
Browse files Browse the repository at this point in the history
…g-decoding bug wrt useREST
  • Loading branch information
shashank-netapp authored Jun 6, 2024
1 parent 1938cd6 commit b7e0c72
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions storage_drivers/ontap/ontap_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1077,9 +1077,14 @@ func InitializeOntapAPI(
var ontapAPI api.OntapAPI
var err error

useRESTValue := "<nil>"
if config.UseREST != nil {
useRESTValue = strconv.FormatBool(*config.UseREST)
}
fields := LogFields{
"Method": "InitializeOntapAPI", "Type": "ontap_common",
"useREST": config.UseREST,
"Method": "InitializeOntapAPI",
"Type": "ontap_common",
"useREST": useRESTValue,
}
Logd(ctx, config.StorageDriverName,
config.DebugTraceFlags["method"]).WithFields(fields).Trace(">>>> InitializeOntapAPI")
Expand Down Expand Up @@ -1172,6 +1177,19 @@ func InitializeOntapAPI(
}
}

fields = LogFields{
"Backend": config.BackendName,
}
switch ontapAPI.(type) {
case api.OntapAPIREST:
Logc(ctx).WithFields(fields).Info("Using REST client")
case api.OntapAPIZAPI:
Logc(ctx).WithFields(fields).Info("Using ZAPI client")
default:
// We should never reach this point, but putting this here just in case.
Logc(ctx).WithFields(fields).Warn("Unknown ONTAP API client type.")
}

Logc(ctx).WithField("SVM", ontapAPI.SVMName()).Debug("Using SVM.")
return ontapAPI, nil
}
Expand Down Expand Up @@ -2770,6 +2788,14 @@ func getExternalConfig(ctx context.Context, config drivers.OntapStorageDriverCon
drivers.KeyName: utils.REDACTED,
drivers.KeyType: utils.REDACTED,
} // redact the credentials

// https://github.com/golang/go/issues/4609
// It's how gob encoding-decoding works, it flattens the pointer while encoding,
// and during the decoding phase, if the default value is encountered, it is assigned as nil.
if config.UseREST != nil {
cloneConfig.UseREST = utils.Ptr(*config.UseREST)
}

return cloneConfig
}

Expand Down

0 comments on commit b7e0c72

Please sign in to comment.