Skip to content

Commit d6f4290

Browse files
committed
storage deletion logic
1 parent e52bd3c commit d6f4290

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

cloud/services/compute/storage/reconcile.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ func (s *Service) Reconcile(ctx context.Context) error {
2828
}
2929

3030
func (s *Service) Delete(ctx context.Context) error {
31-
// to do
31+
// return s.deleteStorage(ctx)
32+
// not worthy to delete Storage
33+
// since deleting Storage will block vm deletion
34+
// and does not delete actual content in the node
3235
return nil
3336
}
3437

@@ -62,6 +65,26 @@ func (s *Service) createStorage(options storage.StorageCreateOptions) error {
6265
return nil
6366
}
6467

68+
func (s *Service) deleteStorage(ctx context.Context) error {
69+
log := log.FromContext(ctx)
70+
nodes, err := s.client.Nodes()
71+
if err != nil {
72+
return err
73+
}
74+
for _, node := range nodes {
75+
storage, err := node.Storage(s.scope.Storage().Name)
76+
if err != nil {
77+
log.Info(err.Error())
78+
continue
79+
}
80+
if _, err := storage.Delete(); err != nil {
81+
log.Info(err.Error())
82+
return err
83+
}
84+
}
85+
return nil
86+
}
87+
6588
func generateVMStorageOptions(scope Scope) storage.StorageCreateOptions {
6689
storageSpec := scope.Storage()
6790
options := storage.StorageCreateOptions{

controllers/proxmoxcluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (r *ProxmoxClusterReconciler) reconcileDelete(ctx context.Context, clusterS
144144
log.Info("Reconciling Delete ProxmoxCluster")
145145

146146
reconcilers := []cloud.Reconciler{
147-
// to do
147+
storage.NewService(clusterScope),
148148
}
149149

150150
for _, r := range reconcilers {

0 commit comments

Comments
 (0)