-
Notifications
You must be signed in to change notification settings - Fork 226
operator: support multiple interfaces #2537
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
Open
AndrewChubatiuk
wants to merge
1
commit into
master
Choose a base branch
from
multiple-http-interfaces
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,11 +7,15 @@ import ( | |
| "strconv" | ||
|
|
||
| corev1 "k8s.io/api/core/v1" | ||
|
|
||
| vmv1beta1 "github.com/VictoriaMetrics/operator/api/operator/v1beta1" | ||
| ) | ||
|
|
||
| const ( | ||
| healthPath = "/health" | ||
| metricsPath = "/metrics" | ||
| // OTLPGRPCPortName is the Service/container port name generated for the OTLP gRPC listener. | ||
| OTLPGRPCPortName = "otlp-grpc" | ||
| ) | ||
|
|
||
| // TLSServerConfig defines VictoriaMetrics TLS configuration for the application's server | ||
|
|
@@ -51,18 +55,40 @@ type OTLPGRPCSpec struct { | |
| TLSConfig *TLSServerConfig `json:"tlsConfig,omitempty"` | ||
| } | ||
|
|
||
| // Validate checks that ListenPort doesn't collide with httpPort, the port already used for | ||
| // the component's main HTTP listener. | ||
| func (g *OTLPGRPCSpec) Validate(httpPort string) error { | ||
| // Validate checks that ListenPort doesn't collide with httpPort or any configured HTTPListener, | ||
| // and that no HTTPListener is named OTLPGRPCPortName. | ||
| func (g *OTLPGRPCSpec) Validate(httpPort string, listeners []vmv1beta1.HTTPListener) error { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Changing this exported method from Prompt for AI agents |
||
| if g == nil { | ||
| return nil | ||
| } | ||
| if strconv.Itoa(int(g.ListenPort)) == httpPort { | ||
| return fmt.Errorf("spec.grpcSpec.listenPort=%d must not be equal to the HTTP listen port=%s", g.ListenPort, httpPort) | ||
| if len(listeners) == 0 { | ||
| if portsEqual(strconv.Itoa(int(g.ListenPort)), httpPort) { | ||
| return fmt.Errorf("spec.grpcSpec.listenPort=%d must not be equal to the HTTP listen port=%s", g.ListenPort, httpPort) | ||
| } | ||
| return nil | ||
| } | ||
| for i := range listeners { | ||
| if listeners[i].Name == OTLPGRPCPortName { | ||
| return fmt.Errorf("httpListeners[%d].name cannot be %q while spec.grpcSpec is enabled, since it collides with the generated OTLP gRPC port name", i, OTLPGRPCPortName) | ||
| } | ||
| if port := listeners[i].AddrPort(); portsEqual(strconv.Itoa(int(g.ListenPort)), port) { | ||
| return fmt.Errorf("spec.grpcSpec.listenPort=%d must not be equal to httpListeners[%d].addr port=%s", g.ListenPort, i, port) | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // portsEqual compares two port strings numerically when both parse as integers, | ||
| // falling back to a plain string comparison otherwise. | ||
| func portsEqual(a, b string) bool { | ||
| ai, aerr := strconv.Atoi(a) | ||
| bi, berr := strconv.Atoi(b) | ||
| if aerr != nil || berr != nil { | ||
| return a == b | ||
| } | ||
| return ai == bi | ||
| } | ||
|
|
||
| // OAuth2 defines OAuth2 configuration parameters | ||
| // with optional references to secrets with corresponding sensitive values | ||
| type OAuth2 struct { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.