Skip to content

Commit b2380b5

Browse files
Ansible fail early when path in api URL (#4987)
* modified files Signed-off-by: laxmikantbpandhare <[email protected]> * fix for the path issue - #4980 Signed-off-by: laxmikantbpandhare <[email protected]> * added changelog Signed-off-by: laxmikantbpandhare <[email protected]> * worked on review comments Signed-off-by: laxmikantbpandhare <[email protected]> * testdata Signed-off-by: laxmikantbpandhare <[email protected]> * modified error Signed-off-by: laxmikantbpandhare <[email protected]> * modified error Signed-off-by: laxmikantbpandhare <[email protected]> * modified changelog Signed-off-by: laxmikantbpandhare <[email protected]> * changelog change Signed-off-by: laxmikantbpandhare <[email protected]> * Update internal/cmd/ansible-operator/run/cmd.go Signed-off-by: Fabian von Feilitzsch <[email protected]> Co-authored-by: Fabian von Feilitzsch <[email protected]>
1 parent 35bc0a2 commit b2380b5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
entries:
2+
- description: >
3+
For Ansible operators, if an API endpoint has path component in it then the ansible-operator binary will terminate early with an error, due to a bug in the proxy that would cause the operator to target the wrong cluster.
4+
kind: change
5+
breaking: true
6+
migration:
7+
header: The ansible-operator binary will reject the kubeconfig if the server URL contains a path.
8+
body: >
9+
There is currently no workaround other than running the operator as a pod in the cluster (where it will use the internal endpoint). The fix for this issue is currently blocked waiting on a fix to the apimachinery package. Once the upstream issue is merged then a proper fix will be done for ansible-operator. Work on this issue is being tracked here: https://github.com/operator-framework/operator-sdk/issues/4925

internal/cmd/ansible-operator/run/cmd.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"errors"
1919
"flag"
2020
"fmt"
21+
"net/url"
2122
"os"
2223
"runtime"
2324
"strconv"
@@ -103,6 +104,18 @@ func run(cmd *cobra.Command, f *flags.Flags) {
103104
os.Exit(1)
104105
}
105106

107+
urlPath, err := url.Parse(cfg.Host)
108+
109+
if err != nil {
110+
log.Error(err, "Failed to Parse the Path URL.")
111+
os.Exit(1)
112+
}
113+
114+
if urlPath != nil && urlPath.Path != "" {
115+
log.Error(fmt.Errorf("api endpoint '%s' contains a path component, which the proxy server is currently unable to handle properly. Work on this issue is being tracked here: https://github.com/operator-framework/operator-sdk/issues/4925", cfg.Host), "")
116+
os.Exit(1)
117+
}
118+
106119
// TODO(2.0.0): remove
107120
// Deprecated: OPERATOR_NAME environment variable is an artifact of the
108121
// legacy operator-sdk project scaffolding. Flag `--leader-election-id`

0 commit comments

Comments
 (0)