Skip to content

Commit b7e0c72

Browse files
Adding log for determining REST/ZAPI client and resolving gob encoding-decoding bug wrt useREST
1 parent 1938cd6 commit b7e0c72

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

storage_drivers/ontap/ontap_common.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,9 +1077,14 @@ func InitializeOntapAPI(
10771077
var ontapAPI api.OntapAPI
10781078
var err error
10791079

1080+
useRESTValue := "<nil>"
1081+
if config.UseREST != nil {
1082+
useRESTValue = strconv.FormatBool(*config.UseREST)
1083+
}
10801084
fields := LogFields{
1081-
"Method": "InitializeOntapAPI", "Type": "ontap_common",
1082-
"useREST": config.UseREST,
1085+
"Method": "InitializeOntapAPI",
1086+
"Type": "ontap_common",
1087+
"useREST": useRESTValue,
10831088
}
10841089
Logd(ctx, config.StorageDriverName,
10851090
config.DebugTraceFlags["method"]).WithFields(fields).Trace(">>>> InitializeOntapAPI")
@@ -1172,6 +1177,19 @@ func InitializeOntapAPI(
11721177
}
11731178
}
11741179

1180+
fields = LogFields{
1181+
"Backend": config.BackendName,
1182+
}
1183+
switch ontapAPI.(type) {
1184+
case api.OntapAPIREST:
1185+
Logc(ctx).WithFields(fields).Info("Using REST client")
1186+
case api.OntapAPIZAPI:
1187+
Logc(ctx).WithFields(fields).Info("Using ZAPI client")
1188+
default:
1189+
// We should never reach this point, but putting this here just in case.
1190+
Logc(ctx).WithFields(fields).Warn("Unknown ONTAP API client type.")
1191+
}
1192+
11751193
Logc(ctx).WithField("SVM", ontapAPI.SVMName()).Debug("Using SVM.")
11761194
return ontapAPI, nil
11771195
}
@@ -2770,6 +2788,14 @@ func getExternalConfig(ctx context.Context, config drivers.OntapStorageDriverCon
27702788
drivers.KeyName: utils.REDACTED,
27712789
drivers.KeyType: utils.REDACTED,
27722790
} // redact the credentials
2791+
2792+
// https://github.com/golang/go/issues/4609
2793+
// It's how gob encoding-decoding works, it flattens the pointer while encoding,
2794+
// and during the decoding phase, if the default value is encountered, it is assigned as nil.
2795+
if config.UseREST != nil {
2796+
cloneConfig.UseREST = utils.Ptr(*config.UseREST)
2797+
}
2798+
27732799
return cloneConfig
27742800
}
27752801

0 commit comments

Comments
 (0)