Skip to content
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-asse
COPY ./git-ask-pass.sh /git-ask-pass.sh
RUN chmod +x /git-ask-pass.sh

RUN useradd -ms /bin/bash devtron
RUN chown -R devtron:devtron ./devtron
RUN chown -R devtron:devtron ./git-ask-pass.sh
RUN chown -R devtron:devtron ./auth_model.conf
RUN chown -R devtron:devtron ./scripts

USER devtron

CMD ["./devtron"]


Expand All @@ -37,4 +45,4 @@ CMD ["./devtron"]
#COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/devtron-reference-helm-charts scripts/devtron-reference-helm-charts
#COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.JSON scripts/argo-assets/APPLICATION_TEMPLATE.JSON

#CMD ["./devtron-ea"]
#CMD ["./devtron-ea"]
9 changes: 8 additions & 1 deletion DockerfileEA
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ COPY --from=build-env /go/src/github.com/devtron-labs/devtron/vendor/github.com
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/devtron-reference-helm-charts scripts/devtron-reference-helm-charts
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/argo-assets/APPLICATION_TEMPLATE.JSON scripts/argo-assets/APPLICATION_TEMPLATE.JSON

CMD ["./devtron-ea"]
RUN useradd -ms /bin/bash devtron
RUN chown -R devtron:devtron ./devtron-ea
RUN chown -R devtron:devtron ./auth_model.conf
RUN chown -R devtron:devtron ./scripts

USER devtron

CMD ["./devtron-ea"]
1 change: 1 addition & 0 deletions pkg/pipeline/CdConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type CdConfig struct {
DefaultAddressPoolBaseCidr string `env:"CD_DEFAULT_ADDRESS_POOL_BASE_CIDR"`
DefaultAddressPoolSize int `env:"CD_DEFAULT_ADDRESS_POOL_SIZE"`
UseBlobStorageConfigInCdWorkflow bool `env:"USE_BLOB_STORAGE_CONFIG_IN_CD_WORKFLOW" envDefault:"true"`
BaseLogLocationPath string `env:"BASE_LOG_LOCATION_PATH" envDefault:"/home/devtron/"`
}

func GetCdConfig() (*CdConfig, error) {
Expand Down
9 changes: 6 additions & 3 deletions pkg/pipeline/CdHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
"github.com/go-pg/pg"
"go.uber.org/zap"
"os"
"path/filepath"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -628,7 +629,7 @@ func (impl *CdHandlerImpl) getLogsFromRepository(pipelineId int, cdWorkflow *pip
},
}
impl.Logger.Infow("s3 log req ", "req", cdLogRequest)
oldLogsStream, cleanUp, err := impl.ciLogService.FetchLogs(cdLogRequest)
oldLogsStream, cleanUp, err := impl.ciLogService.FetchLogs(impl.ciConfig.BaseLogLocationPath, cdLogRequest)
if err != nil {
impl.Logger.Errorw("err", err)
return nil, nil, err
Expand Down Expand Up @@ -750,11 +751,13 @@ func (impl *CdHandlerImpl) DownloadCdWorkflowArtifacts(pipelineId int, buildId i
CredentialFileJsonData: impl.ciConfig.BlobStorageGcpCredentialJson,
}
key := fmt.Sprintf("%s/"+impl.cdConfig.CdArtifactLocationFormat, impl.cdConfig.DefaultArtifactKeyPrefix, wfr.CdWorkflow.Id, wfr.Id)
baseLogLocationPathConfig := impl.cdConfig.BaseLogLocationPath
blobStorageService := blob_storage.NewBlobStorageServiceImpl(nil)
destinationKey := filepath.Clean(filepath.Join(baseLogLocationPathConfig, item))
request := &blob_storage.BlobStorageRequest{
StorageType: impl.ciConfig.CloudProvider,
SourceKey: key,
DestinationKey: item,
DestinationKey: destinationKey,
AzureBlobBaseConfig: azureBlobBaseConfig,
AwsS3BaseConfig: awsS3BaseConfig,
GcpBlobBaseConfig: gcpBlobBaseConfig,
Expand All @@ -765,7 +768,7 @@ func (impl *CdHandlerImpl) DownloadCdWorkflowArtifacts(pipelineId int, buildId i
return nil, errors.New("failed to download resource")
}

file, err := os.Open(item)
file, err := os.Open(destinationKey)
if err != nil {
impl.Logger.Errorw("unable to open file", "file", item, "err", err)
return nil, errors.New("unable to open file")
Expand Down
1 change: 1 addition & 0 deletions pkg/pipeline/CiConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type CiConfig struct {
DefaultPvcCachePath string `env:"DOCKER_BUILD_CACHE_PATH" envDefault:"/var/lib/docker"`
BuildxPvcCachePath string `env:"BUILDX_CACHE_PATH" envDefault:"/var/lib/devtron/buildx"`
UseBlobStorageConfigInCiWorkflow bool `env:"USE_BLOB_STORAGE_CONFIG_IN_CI_WORKFLOW" envDefault:"true"`
BaseLogLocationPath string `env:"BASE_LOG_LOCATION_PATH" envDefault:"/home/devtron/"`
ClusterConfig *rest.Config
NodeLabel map[string]string
}
Expand Down
11 changes: 7 additions & 4 deletions pkg/pipeline/CiHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
errors2 "k8s.io/apimachinery/pkg/api/errors"
"net/http"
"os"
"path/filepath"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -571,7 +572,7 @@ func (impl *CiHandlerImpl) getLogsFromRepository(pipelineId int, ciWorkflow *pip
CredentialFileJsonData: impl.ciConfig.BlobStorageGcpCredentialJson,
},
}
oldLogsStream, cleanUp, err := impl.ciLogService.FetchLogs(ciLogRequest)
oldLogsStream, cleanUp, err := impl.ciLogService.FetchLogs(impl.ciConfig.BaseLogLocationPath, ciLogRequest)
if err != nil {
impl.Logger.Errorw("err", "err", err)
return nil, nil, err
Expand Down Expand Up @@ -632,11 +633,13 @@ func (impl *CiHandlerImpl) DownloadCiWorkflowArtifacts(pipelineId int, buildId i

key := fmt.Sprintf("%s/"+impl.ciConfig.CiArtifactLocationFormat, impl.ciConfig.DefaultArtifactKeyPrefix, ciWorkflow.Id, ciWorkflow.Id)

baseLogLocationPathConfig := impl.ciConfig.BaseLogLocationPath
blobStorageService := blob_storage.NewBlobStorageServiceImpl(nil)
destinationKey := filepath.Clean(filepath.Join(baseLogLocationPathConfig, item))
request := &blob_storage.BlobStorageRequest{
StorageType: impl.ciConfig.CloudProvider,
SourceKey: key,
DestinationKey: item,
DestinationKey: baseLogLocationPathConfig + item,
AzureBlobBaseConfig: azureBlobConfig,
AwsS3BaseConfig: awsS3BaseConfig,
GcpBlobBaseConfig: gcpBlobBaseConfig,
Expand All @@ -647,7 +650,7 @@ func (impl *CiHandlerImpl) DownloadCiWorkflowArtifacts(pipelineId int, buildId i
return nil, errors.New("failed to download resource")
}

file, err := os.Open(item)
file, err := os.Open(destinationKey)
if err != nil {
impl.Logger.Errorw("unable to open file", "file", item, "err", err)
return nil, errors.New("unable to open file")
Expand Down Expand Up @@ -700,7 +703,7 @@ func (impl *CiHandlerImpl) GetHistoricBuildLogs(pipelineId int, workflowId int,
CredentialFileJsonData: impl.ciConfig.BlobStorageGcpCredentialJson,
},
}
logsFile, cleanUp, err := impl.ciLogService.FetchLogs(ciLogRequest)
logsFile, cleanUp, err := impl.ciLogService.FetchLogs(impl.ciConfig.BaseLogLocationPath, ciLogRequest)
logs, err := ioutil.ReadFile(logsFile.Name())
if err != nil {
impl.Logger.Errorw("err", "err", err)
Expand Down
8 changes: 5 additions & 3 deletions pkg/pipeline/CiLogService.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"os"
"path/filepath"
)

type CiLogService interface {
FetchRunningWorkflowLogs(ciLogRequest BuildLogRequest, token string, host string, isExt bool) (io.ReadCloser, func() error, error)
FetchLogs(ciLogRequest BuildLogRequest) (*os.File, func() error, error)
FetchLogs(baseLogLocationPathConfig string, ciLogRequest BuildLogRequest) (*os.File, func() error, error)
}

type CiLogServiceImpl struct {
Expand Down Expand Up @@ -114,9 +115,10 @@ func (impl *CiLogServiceImpl) FetchRunningWorkflowLogs(ciLogRequest BuildLogRequ
return podLogs, cleanUpFunc, nil
}

func (impl *CiLogServiceImpl) FetchLogs(logRequest BuildLogRequest) (*os.File, func() error, error) {
func (impl *CiLogServiceImpl) FetchLogs(baseLogLocationPathConfig string, logRequest BuildLogRequest) (*os.File, func() error, error) {
tempFile := baseLogLocationPathConfig
tempFile = filepath.Clean(filepath.Join(tempFile, logRequest.PodName+".log"))

tempFile := logRequest.PodName + ".log"
blobStorageService := blob_storage.NewBlobStorageServiceImpl(nil)
request := &blob_storage.BlobStorageRequest{
StorageType: logRequest.CloudProvider,
Expand Down