Merge pull request #26471 from Luap99/refresh-panic

fix panic on state refresh
This commit is contained in:
openshift-merge-bot[bot] 2025-06-23 15:03:43 +00:00 committed by GitHub
commit b433eb5e6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 29 deletions

View File

@ -293,6 +293,34 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
}
}
}
if cmd.Flag("cpu-profile").Changed {
f, err := os.Create(podmanConfig.CPUProfile)
if err != nil {
return err
}
if err := pprof.StartCPUProfile(f); err != nil {
return err
}
}
if cmd.Flag("memory-profile").Changed {
// Same value as the default in github.com/pkg/profile.
runtime.MemProfileRate = 4096
if rate := os.Getenv("MemProfileRate"); rate != "" {
r, err := strconv.Atoi(rate)
if err != nil {
return err
}
runtime.MemProfileRate = r
}
}
if podmanConfig.MaxWorks <= 0 {
return fmt.Errorf("maximum workers must be set to a positive number (got %d)", podmanConfig.MaxWorks)
}
if err := parallel.SetMaxThreads(uint(podmanConfig.MaxWorks)); err != nil {
return err
}
}
if err := readRemoteCliFlags(cmd, podmanConfig); err != nil {
@ -346,35 +374,6 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
}
}
if !registry.IsRemote() {
if cmd.Flag("cpu-profile").Changed {
f, err := os.Create(podmanConfig.CPUProfile)
if err != nil {
return err
}
if err := pprof.StartCPUProfile(f); err != nil {
return err
}
}
if cmd.Flag("memory-profile").Changed {
// Same value as the default in github.com/pkg/profile.
runtime.MemProfileRate = 4096
if rate := os.Getenv("MemProfileRate"); rate != "" {
r, err := strconv.Atoi(rate)
if err != nil {
return err
}
runtime.MemProfileRate = r
}
}
if podmanConfig.MaxWorks <= 0 {
return fmt.Errorf("maximum workers must be set to a positive number (got %d)", podmanConfig.MaxWorks)
}
if err := parallel.SetMaxThreads(uint(podmanConfig.MaxWorks)); err != nil {
return err
}
}
// Setup Rootless environment, IFF:
// 1) in ABI mode
// 2) running as non-root