Skip to content

Commit 05df3d2

Browse files
committed
guacamole clean up func added when instance deleted
1 parent 5c99905 commit 05df3d2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

service/vm.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ func CreateVM(w http.ResponseWriter, r *http.Request, contextStruct *vms.Control
210210
req.NetConf.NetType = 0
211211
req.Users[0].SSHAuthorizedKeys = []string{publicKeyOpenSSH}
212212

213-
214213
vmRedisInfo := model.VMRedisInfo{
215214
UUID: uuid,
216215
CPU: req.HardwareInfo.CPU,
@@ -221,7 +220,6 @@ func CreateVM(w http.ResponseWriter, r *http.Request, contextStruct *vms.Control
221220
Time: time.Now().Unix(),
222221
}
223222

224-
225223
// HTTP 전송 전에 저장을 완료하여 Core에서 업데이트할 수 있도록 순서 보장
226224
if err := StoreVMInfoToRedis(context.Background(), rdb, vmRedisInfo); err != nil {
227225
log.Warn("failed to store VM info to redis: %v", err, true)
@@ -237,7 +235,6 @@ func CreateVM(w http.ResponseWriter, r *http.Request, contextStruct *vms.Control
237235
return err
238236
}
239237

240-
241238
err = contextStruct.AddInstance(newVM, selectedCoreIndex)
242239
if err != nil {
243240
log.Error("Error database instance insertion failed: %v", err, true)
@@ -286,6 +283,9 @@ func DeleteVM(uuid vms.UUID, contextStruct *vms.ControlContext, rdb *redis.Clien
286283
log.Error("error deleting instance %s from ControlContext: %v", uuid, err)
287284
return err
288285
}
286+
if cleanupErr := CleanupGuacamoleConfig(string(uuid), contextStruct.GuacDB); cleanupErr != nil {
287+
log.Error("Failed to cleanup Guacamole config during rollback: %v", cleanupErr)
288+
}
289289

290290
if err := RemoveVMInfoFromRedis(context.Background(), rdb, uuid); err != nil {
291291
log.Warn("failed to remove vm info from redis (vm deletion succeeded but..): %v", err, true)

0 commit comments

Comments
 (0)