@@ -130,7 +130,10 @@ func (h *CreateClusterHandlerImpl) Handle(params cluster.PostClusterParams, prin
130
130
log .Warningf ("configured storage dir incompatible with cluster configuration: %s" , errStorageDir )
131
131
return h .err409 (errStorageDir , nil )
132
132
}
133
-
133
+ // Init NOTICE file to inform user that the cluster storage folder is programmatically managed by Fusion API
134
+ if errStorageInit := configuration .InitStorageNoticeFile (key ["storage-dir" ]); errStorageInit != nil {
135
+ log .Warningf ("unable to create notice file, %s: skipping it" , errStorageInit .Error ())
136
+ }
134
137
// enforcing API advertising options
135
138
if a := params .AdvertisedAddress ; a != nil {
136
139
h .Config .APIOptions .APIAddress = * a
@@ -176,18 +179,18 @@ func (h *DeleteClusterHandlerImpl) Handle(params cluster.DeleteClusterParams, pr
176
179
if params .Configuration == nil || * params .Configuration != "keep" {
177
180
log .Warning ("clearing configuration as requested" )
178
181
179
- configuration , err := h .Client .Configuration ()
182
+ conf , err := h .Client .Configuration ()
180
183
if err != nil {
181
184
return h .err500 (err , nil )
182
185
}
183
- version , errVersion := configuration .GetVersion ("" )
186
+ version , errVersion := conf .GetVersion ("" )
184
187
if errVersion != nil || version < 1 {
185
188
// silently fallback to 1
186
189
version = 1
187
190
}
188
191
189
192
config := fmt .Sprintf (DummyConfig , time .Now ().Format ("01-02-2006 15:04:05 MST" ), h .Config .Name .Load ())
190
- if err = configuration .PostRawConfiguration (& config , version , true ); err != nil {
193
+ if err = conf .PostRawConfiguration (& config , version , true ); err != nil {
191
194
return h .err500 (err , nil )
192
195
}
193
196
@@ -196,6 +199,13 @@ func (h *DeleteClusterHandlerImpl) Handle(params cluster.DeleteClusterParams, pr
196
199
if err != nil {
197
200
return h .err500 (err , nil )
198
201
}
202
+ // Deleting the storage directory used by Fusion:
203
+ // avoiding at all entering any nil pointer dereference.
204
+ if storageData := h .Config .GetStorageData (); storageData != nil && storageData .Cluster != nil && storageData .Cluster .StorageDir != nil {
205
+ if storageErr := configuration .RemoveStorageFolder (* storageData .Cluster .StorageDir ); storageErr != nil {
206
+ log .Warningf ("failed to clean-up the cluster storage directory: %s" , storageErr .Error ())
207
+ }
208
+ }
199
209
}
200
210
h .Config .Cluster .BootstrapKey .Store ("" )
201
211
h .Config .Mode .Store (configuration .ModeSingle )
0 commit comments