-
Notifications
You must be signed in to change notification settings - Fork 26
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
NETOBSERV-155: Added sampling field to console frontend configuration #264
Merged
openshift-merge-robot
merged 3 commits into
netobserv:main
from
OlivierCazade:console-sampling
Feb 22, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 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 |
---|---|---|
|
@@ -32,16 +32,15 @@ const lokiCerts = "loki-certs" | |
const tokensPath = "/var/run/secrets/tokens/" | ||
|
||
type builder struct { | ||
namespace string | ||
labels map[string]string | ||
selector map[string]string | ||
desired *flowslatest.FlowCollectorConsolePlugin | ||
desiredLoki *flowslatest.FlowCollectorLoki | ||
imageName string | ||
cWatcher *watchers.CertificatesWatcher | ||
namespace string | ||
labels map[string]string | ||
selector map[string]string | ||
desired *flowslatest.FlowCollectorSpec | ||
imageName string | ||
cWatcher *watchers.CertificatesWatcher | ||
} | ||
|
||
func newBuilder(ns, imageName string, desired *flowslatest.FlowCollectorConsolePlugin, desiredLoki *flowslatest.FlowCollectorLoki, cWatcher *watchers.CertificatesWatcher) builder { | ||
func newBuilder(ns, imageName string, desired *flowslatest.FlowCollectorSpec, cWatcher *watchers.CertificatesWatcher) builder { | ||
version := helper.ExtractVersion(imageName) | ||
return builder{ | ||
namespace: ns, | ||
|
@@ -52,10 +51,9 @@ func newBuilder(ns, imageName string, desired *flowslatest.FlowCollectorConsoleP | |
selector: map[string]string{ | ||
"app": constants.PluginName, | ||
}, | ||
desired: desired, | ||
desiredLoki: desiredLoki, | ||
imageName: imageName, | ||
cWatcher: cWatcher, | ||
desired: desired, | ||
imageName: imageName, | ||
cWatcher: cWatcher, | ||
} | ||
} | ||
|
||
|
@@ -69,7 +67,7 @@ func (b *builder) consolePlugin() *osv1alpha1.ConsolePlugin { | |
Service: osv1alpha1.ConsolePluginService{ | ||
Name: constants.PluginName, | ||
Namespace: b.namespace, | ||
Port: b.desired.Port, | ||
Port: b.desired.ConsolePlugin.Port, | ||
BasePath: "/", | ||
}, | ||
Proxy: []osv1alpha1.ConsolePluginProxy{{ | ||
|
@@ -79,7 +77,7 @@ func (b *builder) consolePlugin() *osv1alpha1.ConsolePlugin { | |
Service: osv1alpha1.ConsolePluginProxyServiceConfig{ | ||
Name: constants.PluginName, | ||
Namespace: b.namespace, | ||
Port: b.desired.Port, | ||
Port: b.desired.ConsolePlugin.Port, | ||
}, | ||
}}, | ||
}, | ||
|
@@ -134,7 +132,7 @@ func (b *builder) deployment(cmDigest string) *appsv1.Deployment { | |
Labels: b.labels, | ||
}, | ||
Spec: appsv1.DeploymentSpec{ | ||
Replicas: &b.desired.Replicas, | ||
Replicas: &b.desired.ConsolePlugin.Replicas, | ||
Selector: &metav1.LabelSelector{ | ||
MatchLabels: b.selector, | ||
}, | ||
|
@@ -144,7 +142,7 @@ func (b *builder) deployment(cmDigest string) *appsv1.Deployment { | |
} | ||
|
||
func tokenPath(desiredLoki *flowslatest.FlowCollectorLoki) string { | ||
if desiredLoki.UseHostToken() { | ||
if helper.LokiUseHostToken(desiredLoki) { | ||
return tokensPath + constants.PluginName | ||
} | ||
return "" | ||
|
@@ -164,7 +162,7 @@ func buildArgs(desired *flowslatest.FlowCollectorConsolePlugin, desiredLoki *flo | |
"-frontend-config", filepath.Join(configPath, configFile), | ||
} | ||
|
||
if desiredLoki.ForwardUserToken() { | ||
if helper.LokiForwardUserToken(desiredLoki) { | ||
args = append(args, "-loki-forward-user-token") | ||
} | ||
|
||
|
@@ -179,7 +177,7 @@ func buildArgs(desired *flowslatest.FlowCollectorConsolePlugin, desiredLoki *flo | |
args = append(args, "--loki-ca-path", helper.GetCACertPath(&desiredLoki.TLS, lokiCerts)) | ||
} | ||
} | ||
if desiredLoki.UseHostToken() { | ||
if helper.LokiUseHostToken(desiredLoki) { | ||
args = append(args, "-loki-token-path", tokenPath(desiredLoki)) | ||
} | ||
return args | ||
|
@@ -216,12 +214,12 @@ func (b *builder) podTemplate(cmDigest string) *corev1.PodTemplateSpec { | |
}, | ||
} | ||
|
||
args := buildArgs(b.desired, b.desiredLoki) | ||
if b.desiredLoki != nil && b.desiredLoki.TLS.Enable && !b.desiredLoki.TLS.InsecureSkipVerify { | ||
volumes, volumeMounts = helper.AppendCertVolumes(volumes, volumeMounts, &b.desiredLoki.TLS, lokiCerts, b.cWatcher) | ||
args := buildArgs(&b.desired.ConsolePlugin, &b.desired.Loki) | ||
if b.desired != nil && b.desired.Loki.TLS.Enable && !b.desired.Loki.TLS.InsecureSkipVerify { | ||
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. Do you still need to check 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.
|
||
volumes, volumeMounts = helper.AppendCertVolumes(volumes, volumeMounts, &b.desired.Loki.TLS, lokiCerts, b.cWatcher) | ||
} | ||
|
||
if b.desiredLoki.UseHostToken() { | ||
if helper.LokiUseHostToken(&b.desired.Loki) { | ||
volumes, volumeMounts = helper.AppendTokenVolume(volumes, volumeMounts, constants.PluginName, constants.PluginName) | ||
} | ||
|
||
|
@@ -236,8 +234,8 @@ func (b *builder) podTemplate(cmDigest string) *corev1.PodTemplateSpec { | |
Containers: []corev1.Container{{ | ||
Name: constants.PluginName, | ||
Image: b.imageName, | ||
ImagePullPolicy: corev1.PullPolicy(b.desired.ImagePullPolicy), | ||
Resources: *b.desired.Resources.DeepCopy(), | ||
ImagePullPolicy: corev1.PullPolicy(b.desired.ConsolePlugin.ImagePullPolicy), | ||
Resources: *b.desired.ConsolePlugin.Resources.DeepCopy(), | ||
VolumeMounts: volumeMounts, | ||
Args: args, | ||
}}, | ||
|
@@ -260,9 +258,9 @@ func (b *builder) autoScaler() *ascv2.HorizontalPodAutoscaler { | |
Kind: "Deployment", | ||
Name: constants.PluginName, | ||
}, | ||
MinReplicas: b.desired.Autoscaler.MinReplicas, | ||
MaxReplicas: b.desired.Autoscaler.MaxReplicas, | ||
Metrics: b.desired.Autoscaler.Metrics, | ||
MinReplicas: b.desired.ConsolePlugin.Autoscaler.MinReplicas, | ||
MaxReplicas: b.desired.ConsolePlugin.Autoscaler.MaxReplicas, | ||
Metrics: b.desired.ConsolePlugin.Autoscaler.Metrics, | ||
}, | ||
} | ||
} | ||
|
@@ -281,7 +279,7 @@ func (b *builder) service(old *corev1.Service) *corev1.Service { | |
Spec: corev1.ServiceSpec{ | ||
Selector: b.selector, | ||
Ports: []corev1.ServicePort{{ | ||
Port: b.desired.Port, | ||
Port: b.desired.ConsolePlugin.Port, | ||
Protocol: "TCP", | ||
Name: "main", | ||
}}, | ||
|
@@ -291,7 +289,7 @@ func (b *builder) service(old *corev1.Service) *corev1.Service { | |
// In case we're updating an existing service, we need to build from the old one to keep immutable fields such as clusterIP | ||
newService := old.DeepCopy() | ||
newService.Spec.Ports = []corev1.ServicePort{{ | ||
Port: b.desired.Port, | ||
Port: b.desired.ConsolePlugin.Port, | ||
Protocol: corev1.ProtocolUDP, | ||
}} | ||
return newService | ||
|
@@ -313,9 +311,10 @@ func buildServiceAccount(ns string) *corev1.ServiceAccount { | |
// detect any configuration change | ||
func (b *builder) configMap() (*corev1.ConfigMap, string) { | ||
config := map[string]interface{}{ | ||
"portNaming": b.desired.PortNaming, | ||
"quickFilters": b.desired.QuickFilters, | ||
"portNaming": b.desired.ConsolePlugin.PortNaming, | ||
"quickFilters": b.desired.ConsolePlugin.QuickFilters, | ||
"alertNamespaces": []string{b.namespace}, | ||
"sampling": helper.GetSampling(b.desired), | ||
} | ||
|
||
configStr := "{}" | ||
|
This file contains 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 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.
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.
(by the way, I don't think it was necessary to add the new helper to the v1alpha1 version, and maybe not doing so would have spared us from the controversy 😅)
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.
Operator controller now point to v1beta1, this functions were not used anyway