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

using cached config breaks --connection #16282

Closed
cdoern opened this issue Oct 24, 2022 · 6 comments · Fixed by #16328
Closed

using cached config breaks --connection #16282

cdoern opened this issue Oct 24, 2022 · 6 comments · Fixed by #16328
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@cdoern
Copy link
Contributor

cdoern commented Oct 24, 2022

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

The changes introduced in #16238 seem to break --connection, which now when used always results in Error: failed to resolve active destination: "fedora" service destination not found due to the blank config that is returned from https://github.com/vrothberg/libpod/blob/7a9c14d6266a0883c8e95d376ffcae71c7e8621e/cmd/podman/registry/config.go#L83 resulting in an empty service destination array

Steps to reproduce the issue:

  1. podman system connection add

  2. podman --connection=name ps

  3. error out

Describe the results you received:

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Client:       Podman Engine
Version:      4.3.0-dev
API Version:  4.3.0-dev
Go Version:   go1.18.6
Git Commit:   63a8f9aeaacd7ed9aee22d227cc0a68fd9306aba-dirty
Built:        Mon Oct 24 18:55:10 2022
OS/Arch:      linux/amd64
@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 24, 2022
@cdoern
Copy link
Contributor Author

cdoern commented Oct 24, 2022

I can mock up a fix for this or maybe I am doing something wrong but on my machine this completely breaks any usage of --connection

@vrothberg
Copy link
Member

Thanks for opening the issue, @cdoern.

The following diff fixes the issue on my machine:

diff --git a/cmd/podman/root.go b/cmd/podman/root.go                                                                                              
index 7cdc74595ba3..705c1607e077 100644                                                                                                           
--- a/cmd/podman/root.go                                                                                                                          
+++ b/cmd/podman/root.go                                                                                                                          
@@ -176,7 +176,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {                                                             
                                                                                                                                                  
        setupConnection := func() error {                                                                                                         
                var err error                                                                                                                     
-               podmanConfig.URI, podmanConfig.Identity, podmanConfig.MachineMode, err = podmanConfig.ContainersConf.ActiveDestination()          
+               podmanConfig.URI, podmanConfig.Identity, podmanConfig.MachineMode, err = podmanConfig.ContainersConfDefaultsRO.ActiveDestination()
                if err != nil {                                                                                                                   
                        return fmt.Errorf("failed to resolve active destination: %w", err)                                                        
                }                                                                                                                                 

@cdoern would you open a PR to fix it along with tests? CI should have failed IMO.

@cdoern
Copy link
Contributor Author

cdoern commented Oct 25, 2022

Thanks for opening the issue, @cdoern.

The following diff fixes the issue on my machine:

diff --git a/cmd/podman/root.go b/cmd/podman/root.go                                                                                              
index 7cdc74595ba3..705c1607e077 100644                                                                                                           
--- a/cmd/podman/root.go                                                                                                                          
+++ b/cmd/podman/root.go                                                                                                                          
@@ -176,7 +176,7 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {                                                             
                                                                                                                                                  
        setupConnection := func() error {                                                                                                         
                var err error                                                                                                                     
-               podmanConfig.URI, podmanConfig.Identity, podmanConfig.MachineMode, err = podmanConfig.ContainersConf.ActiveDestination()          
+               podmanConfig.URI, podmanConfig.Identity, podmanConfig.MachineMode, err = podmanConfig.ContainersConfDefaultsRO.ActiveDestination()
                if err != nil {                                                                                                                   
                        return fmt.Errorf("failed to resolve active destination: %w", err)                                                        
                }                                                                                                                                 

@cdoern would you open a PR to fix it along with tests? CI should have failed IMO.

Sure will open today!

@cdoern
Copy link
Contributor Author

cdoern commented Oct 25, 2022

@vrothberg even with this patch, my --connection is not honored. On my machine running bin/podman-remote --connection=home --log-level=debug info uses my podman machine connection each time... any ideas why this would be happening?

@vrothberg
Copy link
Member

@vrothberg even with this patch, my --connection is not honored. On my machine running bin/podman-remote --connection=home --log-level=debug info uses my podman machine connection each time... any ideas why this would be happening?

There's probably another change needed. Have a look at commit 4e29ce2 and connection-related changes. ContainersConfDefaultsRO are the default that must be read only. ContainersConf is where we can write values from the CLI to.

@cdoern
Copy link
Contributor Author

cdoern commented Oct 27, 2022

I think the issue is config.Default is returning the wrong active service and that is then used in NewContainerEngine and NewConnection... I am going to look into how to remedy this.

cdoern added a commit to cdoern/podman that referenced this issue Nov 11, 2022
--connection was failing due to the servicedestinations array being empty on runtime.
Fix by making sure the cached config is used

resolves containers#16282

Signed-off-by: Charlie Doern <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants