Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions common-lib/utils/grpc/GrpcConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package grpc

import "github.com/caarlos0/env"

// CATEGORY=INFRA_SETUP
type Configuration struct {
KubelinkMaxRecvMsgSize int `env:"KUBELINK_GRPC_MAX_RECEIVE_MSG_SIZE" envDefault:"20"` // In mb
KubelinkMaxSendMsgSize int `env:"KUBELINK_GRPC_MAX_SEND_MSG_SIZE" envDefault:"4"` // In mb
KubelinkMaxRecvMsgSize int `env:"KUBELINK_GRPC_MAX_RECEIVE_MSG_SIZE" envDefault:"20"` // In mb
KubelinkMaxSendMsgSize int `env:"KUBELINK_GRPC_MAX_SEND_MSG_SIZE" envDefault:"4"` // In mb
KubelinkGRPCServiceConfig string `env:"KUBELINK_GRPC_SERVICE_CONFIG" envDefault:"{\"loadBalancingPolicy\":\"round_robin\"}" description:"kubelink grpc service config"`
}

func GetConfiguration() (*Configuration, error) {
Expand Down
15 changes: 8 additions & 7 deletions git-sensor/pkg/RepoManages.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ func (impl RepoManagerImpl) backupGitMaterialBeforeUpdate(existingMaterial *sql.

func (impl RepoManagerImpl) UpdateRepo(gitCtx git.GitContext, material *sql.GitMaterial) (*sql.GitMaterial, error) {
updateInitiatedTime := time.Now()

repoLock := impl.locker.LeaseLocker(material.Id)
repoLock.Mutex.Lock()
defer func() {
repoLock.Mutex.Unlock()
impl.locker.ReturnLocker(material.Id)
}()

existingMaterial, err := impl.materialRepository.FindById(material.Id)
if err != nil {
impl.logger.Errorw("error in fetching material", "material", material, "timeTaken", time.Since(updateInitiatedTime), "err", err)
Expand All @@ -314,13 +322,6 @@ func (impl RepoManagerImpl) UpdateRepo(gitCtx git.GitContext, material *sql.GitM
return nil, err
}

repoLock := impl.locker.LeaseLocker(material.Id)
repoLock.Mutex.Lock()
defer func() {
repoLock.Mutex.Unlock()
impl.locker.ReturnLocker(material.Id)
}()

err = impl.repositoryManager.Clean(existingMaterial.CheckoutLocation)
if err != nil {
impl.logger.Errorw("error in refreshing material", "dir", existingMaterial.CheckoutLocation, "timeTaken", time.Since(updateInitiatedTime), "err", err)
Expand Down