Remove Generation field (#57)

This commit is contained in:
Nikolay Edigaryev 2023-03-24 21:23:07 +04:00 committed by GitHub
parent 49753ebf4c
commit 7647ccdc10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 0 additions and 13 deletions

View File

@ -39,7 +39,6 @@ func (controller *Controller) createServiceAccount(ctx *gin.Context) responder.R
}
serviceAccount.CreatedAt = time.Now()
serviceAccount.Generation = 0
return controller.storeUpdate(func(txn storepkg.Transaction) responder.Responder {
// Does the Service Account resource with this name already exists?
@ -81,8 +80,6 @@ func (controller *Controller) updateServiceAccount(ctx *gin.Context) responder.R
return responder.Error(err)
}
dbServiceAccount.Generation++
if err := txn.SetServiceAccount(dbServiceAccount); err != nil {
return responder.Code(http.StatusInternalServerError)
}

View File

@ -29,7 +29,6 @@ func (controller *Controller) createVM(ctx *gin.Context) responder.Responder {
vm.Status = v1.VMStatusPending
vm.CreatedAt = time.Now()
vm.UID = uuid.New().String()
vm.Generation = 0
return controller.storeUpdate(func(txn storepkg.Transaction) responder.Responder {
// Does the VM resource with this name already exists?
@ -73,7 +72,6 @@ func (controller *Controller) updateVM(ctx *gin.Context) responder.Responder {
dbVM.Status = userVM.Status
dbVM.StatusMessage = userVM.StatusMessage
dbVM.Generation++
if err := txn.SetVM(*dbVM); err != nil {
return responder.Code(http.StatusInternalServerError)

View File

@ -30,7 +30,6 @@ func (controller *Controller) createWorker(ctx *gin.Context) responder.Responder
worker.LastSeen = currentTime
}
worker.CreatedAt = currentTime
worker.Generation = 0
return controller.storeUpdate(func(txn storepkg.Transaction) responder.Responder {
// In case there already exist a worker with the same name,
@ -70,7 +69,6 @@ func (controller *Controller) updateWorker(ctx *gin.Context) responder.Responder
}
dbWorker.LastSeen = userWorker.LastSeen
dbWorker.Generation++
if err := txn.SetWorker(*dbWorker); err != nil {
return responder.Code(http.StatusInternalServerError)

View File

@ -121,7 +121,6 @@ func (controller *Controller) EnsureServiceAccount(serviceAccount *v1.ServiceAcc
}
serviceAccount.CreatedAt = time.Now()
serviceAccount.Generation = 0
return controller.store.Update(func(txn storepkg.Transaction) error {
return txn.SetServiceAccount(serviceAccount)

View File

@ -16,11 +16,6 @@ type Meta struct {
// It is populated by the Controller with the current time
// when receiving a POST request.
CreatedAt time.Time `json:"createdAt"`
// Generation is a useful field for avoiding data races within a single UID.
//
// It is populated by the controller when receiving POST or PUT requests.
Generation int64 `json:"generation"`
}
type Worker struct {