Skip to content

Commit d9add5a

Browse files
authored
Merge pull request #281 from devtron-labs/kubelink-grpc-service-config-expose
fix: git sensor update repo lock after update status fix and kubelink grpc service config expose
2 parents d94e313 + 92902b3 commit d9add5a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

common-lib/utils/grpc/GrpcConfig.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package grpc
22

33
import "github.com/caarlos0/env"
44

5+
// CATEGORY=INFRA_SETUP
56
type Configuration struct {
6-
KubelinkMaxRecvMsgSize int `env:"KUBELINK_GRPC_MAX_RECEIVE_MSG_SIZE" envDefault:"20"` // In mb
7-
KubelinkMaxSendMsgSize int `env:"KUBELINK_GRPC_MAX_SEND_MSG_SIZE" envDefault:"4"` // In mb
7+
KubelinkMaxRecvMsgSize int `env:"KUBELINK_GRPC_MAX_RECEIVE_MSG_SIZE" envDefault:"20"` // In mb
8+
KubelinkMaxSendMsgSize int `env:"KUBELINK_GRPC_MAX_SEND_MSG_SIZE" envDefault:"4"` // In mb
9+
KubelinkGRPCServiceConfig string `env:"KUBELINK_GRPC_SERVICE_CONFIG" envDefault:"{\"loadBalancingPolicy\":\"round_robin\"}" description:"kubelink grpc service config"`
810
}
911

1012
func GetConfiguration() (*Configuration, error) {

git-sensor/pkg/RepoManages.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,14 @@ func (impl RepoManagerImpl) backupGitMaterialBeforeUpdate(existingMaterial *sql.
288288

289289
func (impl RepoManagerImpl) UpdateRepo(gitCtx git.GitContext, material *sql.GitMaterial) (*sql.GitMaterial, error) {
290290
updateInitiatedTime := time.Now()
291+
292+
repoLock := impl.locker.LeaseLocker(material.Id)
293+
repoLock.Mutex.Lock()
294+
defer func() {
295+
repoLock.Mutex.Unlock()
296+
impl.locker.ReturnLocker(material.Id)
297+
}()
298+
291299
existingMaterial, err := impl.materialRepository.FindById(material.Id)
292300
if err != nil {
293301
impl.logger.Errorw("error in fetching material", "material", material, "timeTaken", time.Since(updateInitiatedTime), "err", err)
@@ -314,13 +322,6 @@ func (impl RepoManagerImpl) UpdateRepo(gitCtx git.GitContext, material *sql.GitM
314322
return nil, err
315323
}
316324

317-
repoLock := impl.locker.LeaseLocker(material.Id)
318-
repoLock.Mutex.Lock()
319-
defer func() {
320-
repoLock.Mutex.Unlock()
321-
impl.locker.ReturnLocker(material.Id)
322-
}()
323-
324325
err = impl.repositoryManager.Clean(existingMaterial.CheckoutLocation)
325326
if err != nil {
326327
impl.logger.Errorw("error in refreshing material", "dir", existingMaterial.CheckoutLocation, "timeTaken", time.Since(updateInitiatedTime), "err", err)

0 commit comments

Comments
 (0)