-
Notifications
You must be signed in to change notification settings - Fork 2
Fix error of dataservices: mongodb, logme2, search, prometheus #50
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
base: main
Are you sure you want to change the base?
Conversation
provider-anynines/apis/servicebinding/v1/servicebinding_types.go
Outdated
Show resolved
Hide resolved
provider-anynines/internal/controller/servicebinding/servicebinding.go
Outdated
Show resolved
Hide resolved
provider-anynines/internal/controller/servicebinding/servicebinding.go
Outdated
Show resolved
Hide resolved
provider-anynines/internal/controller/servicebinding/servicebinding.go
Outdated
Show resolved
Hide resolved
provider-anynines/internal/controller/servicebinding/servicebinding.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L
provider-anynines/apis/servicebinding/v1/servicebinding_types.go
Outdated
Show resolved
Hide resolved
provider-anynines/internal/controller/servicebinding/servicebinding.go
Outdated
Show resolved
Hide resolved
provider-anynines/internal/controller/servicebinding/servicebinding.go
Outdated
Show resolved
Hide resolved
@@ -368,6 +371,16 @@ func getInstanceCredentials(instance osbclient.GetInstanceResponse, sb *v1.Servi | |||
return nil | |||
} | |||
|
|||
func (c external) parseHostAndPort(input string) (host, port string, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment of how this function works, with a expected format string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -376,14 +389,97 @@ func (c external) initializeConnectionDetails(ctx context.Context, sb *v1.Servic | |||
return err | |||
} | |||
|
|||
sb.Status.AtProvider.ConnectionDetails.HostURL = string(secret.Data["host"]) | |||
sb.Status.AtProvider.ConnectionDetails.Port = string(secret.Data["port"]) | |||
var hostURL, port string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
if strings.Contains(instanceName, "search") { | ||
host, found := secret.Data["host"] | ||
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add an else condition that the host is not in a recognised format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if found && len(host) >= 0 { | ||
hostURL, port, err = c.parseHostAndPort(string(host)) | ||
if err != nil { | ||
return err | ||
} | ||
sb.AddConnectionDetails(hostURL, port) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { | ||
hostURL, port, err = c.parseHostAndPort(string(host[1 : len(host)-1])) | ||
if err != nil { | ||
return err | ||
} | ||
sb.AddConnectionDetails(hostURL, port) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { | ||
parsedURL, err := url.Parse(string(host[1 : len(host)-1])) | ||
if err != nil { | ||
return err | ||
} | ||
hostURL, port, err = c.parseHostAndPort(parsedURL.Scheme + "://" + parsedURL.Host) | ||
if err != nil { | ||
return err | ||
} | ||
sb.AddConnectionDetails(hostURL, port) | ||
} | ||
host, found = secret.Data["alertmanager_urls"] | ||
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { | ||
parsedURL, err := url.Parse(string(host[1 : len(host)-1])) | ||
if err != nil { | ||
return err | ||
} | ||
hostURL, port, err = c.parseHostAndPort(parsedURL.Scheme + "://" + parsedURL.Host) | ||
if err != nil { | ||
return err | ||
} | ||
sb.AddConnectionDetails(hostURL, port) | ||
} | ||
host, found = secret.Data["grafana_urls"] | ||
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { | ||
parsedURL, err := url.Parse(string(host[1 : len(host)-1])) | ||
if err != nil { | ||
return err | ||
} | ||
hostURL, port, err = c.parseHostAndPort(parsedURL.Scheme + "://" + parsedURL.Host) | ||
if err != nil { | ||
return err | ||
} | ||
sb.AddConnectionDetails(hostURL, port) | ||
} | ||
host, found = secret.Data["graphite_exporters"] | ||
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { | ||
hostURL = string(string(host[1 : len(host)-1])) | ||
port, found := secret.Data["graphite_exporter_port"] | ||
if found { | ||
sb.AddConnectionDetails(hostURL, string(port)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// Validate status | ||
if sb.Status.AtProvider.ConnectionDetails.HasMissingFields() { | ||
if !sb.ConnectionDetailsIsNotEmpty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
if strings.Contains(instanceName, "search") { | ||
host, found := secret.Data["host"] | ||
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also these conditions and the code inside these conditions are repeating, maybe create a function to make it easier on the eyes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left feedback
|
||
func (c external) extractBracketHost(sb *v1.ServiceBinding, secret map[string][]byte, key string) error { | ||
host, found := secret[key] | ||
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { | |
if found && len(host) > 2 && host[0] == '[' && host[len(host)-1] == ']' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
func (c external) extractPlainHost(sb *v1.ServiceBinding, secret map[string][]byte, key string) error { | ||
host, found := secret[key] | ||
if found && len(host) >= 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if found && len(host) >= 0 { | |
if found && len(host) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
func (c external) extractPrometheusHost(sb *v1.ServiceBinding, secret map[string][]byte, key string, port string) error { | ||
host, found := secret[key] | ||
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if found && len(host) >= 2 && host[0] == '[' && host[len(host)-1] == ']' { | |
if found && len(host) > 2 && host[0] == '[' && host[len(host)-1] == ']' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -376,12 +446,54 @@ func (c external) initializeConnectionDetails(ctx context.Context, sb *v1.Servic | |||
return err | |||
} | |||
|
|||
sb.Status.AtProvider.ConnectionDetails.HostURL = string(secret.Data["host"]) | |||
sb.Status.AtProvider.ConnectionDetails.Port = string(secret.Data["port"]) | |||
instanceName := sb.ObjectMeta.Labels["klutch.io/instance-name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instanceName := sb.ObjectMeta.Labels["klutch.io/instance-name"] | |
instanceType := sb.ObjectMeta.Labels["klutch.io/instance-type"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…f servicebindings
There is currently a bug in the provider-anynines which prevents the status of a service binding from being updated correctly for certain dataservices. As a result, the provider continuously attempts to update the status in a loop.
Affected Dataservices: