Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes to the log and stream process #262

Merged
merged 1 commit into from
Jan 7, 2025
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
2 changes: 1 addition & 1 deletion src/catalog/cacheservice/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (cs *CacheService) checkNeedCleanup() (*CleanupRequirements, error) {

manifestUsedSize := cs.manifest.Size * 2
// if we can stream then we do no need the double size request
if cs.rss.CanStream() {
if cs.rss.CanStream() && cs.cfg.IsRemoteProviderStreamEnabled() {
manifestUsedSize = cs.manifest.Size
}

Expand Down
3 changes: 2 additions & 1 deletion src/catalog/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,9 @@ func (s *CatalogManifestService) pullAndDecompressPackFile(r *models.PullCatalog
if rss == nil {
return errors.NewWithCode("Remote storage service is nil", 500)
}
cfg := config.Get()
cleanupSvc := cleanupservice.NewCleanupService()
if rss.CanStream() {
if rss.CanStream() && cfg.IsRemoteProviderStreamEnabled() {
if err := s.processFileWithStream(r.LocalMachineFolder, rss, manifest, cleanupSvc); err != nil {
return err
}
Expand Down
9 changes: 9 additions & 0 deletions src/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,15 @@ func (c *Config) EnableReverseProxy(value bool) bool {
return true
}

func (c *Config) IsRemoteProviderStreamEnabled() bool {
streamingDisabled := c.GetKey(constants.DISABLE_CATALOG_PROVIDER_STREAMING_ENV_VAR)
if streamingDisabled == "" {
return true
}

return !helpers.StringToBool(streamingDisabled)
}

func (c *Config) GetKey(key string) string {
value := helper.GetFlagValue(key, "")
exists := false
Expand Down
2 changes: 2 additions & 0 deletions src/constants/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const (
REVERSE_PROXY_PORT_ENV_VAR = "REVERSE_PROXY_PORT"
REVERSE_PROXY_HOST_ENV_VAR = "REVERSE_PROXY_HOST"
LOG_TO_FILE_ENV_VAR = "PRL_DEVOPS_LOG_TO_FILE"
LOG_FILE_PATH_ENV_VAR = "PRL_DEVOPS_LOG_FILE_PATH"
DISABLE_CATALOG_PROVIDER_STREAMING_ENV_VAR = "DISABLE_CATALOG_PROVIDER_STREAMING"
)

const (
Expand Down
16 changes: 16 additions & 0 deletions src/helpers/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,19 @@ func ObfuscateString(value string) string {
func ClearLine() {
fmt.Printf("\r\033[K")
}

func StringToBool(s string) bool {
if s == "true" ||
s == "1" ||
s == "yes" ||
s == "y" ||
s == "t" ||
s == "on" ||
s == "enable" ||
s == "enabled" ||
s == "active" {
return true
}

return false
}
11 changes: 11 additions & 0 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -82,6 +83,16 @@ func main() {
enableLogToFile := os.Getenv(constants.LOG_TO_FILE_ENV_VAR)
if enableLogToFile == "true" {
logFilename := "prldevops.log"
filePath := os.Getenv(constants.LOG_FILE_PATH_ENV_VAR)
if filePath != "" {
baseFolder := filepath.Dir(filePath)
if _, err := os.Stat(baseFolder); os.IsNotExist(err) {
ctx.LogErrorf("[Core] Log file path does not exist: %s, using executable path", filePath)
} else {
logFilename = filepath.Join(filePath, logFilename)
}
}

executable, err := os.Executable()
if err == nil && !strings.Contains(executable, "__debug") {
logFilename = executable + ".log"
Expand Down
Loading