Unverified Commit d2edbc30 authored by James Bartlett's avatar James Bartlett Committed by Copybara
Browse files

Remove default values for stirling config flags.


Summary:
We had duplicated the default value for stirling config flags (datastream_buffer_size and datastream_buffer_spike_size) in a lot of places.
This diff removes all the additional places the default is specified such that the source of truth is now only the default specified in the stirling code.

Test Plan: Using my diff to cut a dev release, I tested that a dev release with the new templated yamls, deploys successfully without the datastream parameters specified on the PEMs. Also tested that passing the flags to the CLI ends up with the correct flags going to the PEM.

Reviewers: michelle, vihang

Reviewed By: vihang

Subscribers: oazizi
Signed-off-by: default avatarJames Bartlett <jamesbartlett@pixielabs.ai>

Differential Revision: https://phab.corp.pixielabs.ai/D11703

GitOrigin-RevId: b7962bff9117ebe7fe39ce5259a41eab04c61785
parent c9d86c81
Showing with 32 additions and 26 deletions
+32 -26
...@@ -184,10 +184,10 @@ func init() { ...@@ -184,10 +184,10 @@ func init() {
DeployCmd.Flags().String("data_access", "Full", "Data access level defines the level of data that may be accessed when executing a script on the cluster. Options: 'Full' and 'Restricted'") DeployCmd.Flags().String("data_access", "Full", "Data access level defines the level of data that may be accessed when executing a script on the cluster. Options: 'Full' and 'Restricted'")
viper.BindPFlag("data_access", DeployCmd.Flags().Lookup("data_access")) viper.BindPFlag("data_access", DeployCmd.Flags().Lookup("data_access"))
DeployCmd.Flags().Uint32("datastream_buffer_size", 1024*1024, "Internal data collector parameters: the maximum size of a data stream buffer retained between cycles.") DeployCmd.Flags().Uint32("datastream_buffer_size", 0, "Internal data collector parameters: the maximum size of a data stream buffer retained between cycles.")
viper.BindPFlag("datastream_buffer_size", DeployCmd.Flags().Lookup("datastream_buffer_size")) viper.BindPFlag("datastream_buffer_size", DeployCmd.Flags().Lookup("datastream_buffer_size"))
DeployCmd.Flags().Uint32("datastream_buffer_spike_size", 500*1024*1024, "Internal data collector parameters: the maximum temporary size of a data stream buffer before processing.") DeployCmd.Flags().Uint32("datastream_buffer_spike_size", 0, "Internal data collector parameters: the maximum temporary size of a data stream buffer before processing.")
viper.BindPFlag("datastream_buffer_spike_size", DeployCmd.Flags().Lookup("datastream_buffer_spike_size")) viper.BindPFlag("datastream_buffer_spike_size", DeployCmd.Flags().Lookup("datastream_buffer_spike_size"))
// Super secret flags for Pixies. // Super secret flags for Pixies.
...@@ -303,6 +303,14 @@ func runDeployCmd(cmd *cobra.Command, args []string) { ...@@ -303,6 +303,14 @@ func runDeployCmd(cmd *cobra.Command, args []string) {
} }
pemFlagsMap = pf pemFlagsMap = pf
} }
dataCollectorParams := make(map[string]interface{})
dataCollectorParams["customPEMFlags"] = pemFlagsMap
if datastreamBufferSize != 0 {
dataCollectorParams["datastreamBufferSize"] = datastreamBufferSize
}
if datastreamBufferSpikeSize != 0 {
dataCollectorParams["datastreamBufferSpikeSize"] = datastreamBufferSpikeSize
}
castedDataAccess := vztypes.DataAccessLevel(dataAccess) castedDataAccess := vztypes.DataAccessLevel(dataAccess)
if castedDataAccess != vztypes.DataAccessFull && castedDataAccess != vztypes.DataAccessRestricted { if castedDataAccess != vztypes.DataAccessFull && castedDataAccess != vztypes.DataAccessRestricted {
...@@ -441,13 +449,9 @@ func runDeployCmd(cmd *cobra.Command, args []string) { ...@@ -441,13 +449,9 @@ func runDeployCmd(cmd *cobra.Command, args []string) {
"annotations": annotationMap, "annotations": annotationMap,
"labels": labelMap, "labels": labelMap,
}, },
"patches": patchesMap, "patches": patchesMap,
"dataAccess": castedDataAccess, "dataAccess": castedDataAccess,
"dataCollectorParams": &map[string]interface{}{ "dataCollectorParams": dataCollectorParams,
"datastreamBufferSize": datastreamBufferSize,
"datastreamBufferSpikeSize": datastreamBufferSpikeSize,
"customPEMFlags": pemFlagsMap,
},
}, },
Release: &map[string]interface{}{ Release: &map[string]interface{}{
"Namespace": namespace, "Namespace": namespace,
......
...@@ -21,6 +21,7 @@ package vizieryamls ...@@ -21,6 +21,7 @@ package vizieryamls
import ( import (
"fmt" "fmt"
"os" "os"
"strings"
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
...@@ -36,11 +37,9 @@ const ( ...@@ -36,11 +37,9 @@ const (
// Note: if you update this value, make sure you also update defaultUncappedTableStoreSizeMB in // Note: if you update this value, make sure you also update defaultUncappedTableStoreSizeMB in
// src/cloud/config_manager/controllers/server.go, because we want to make // src/cloud/config_manager/controllers/server.go, because we want to make
// sure that the table store size is about 60% of the total requested memory. // sure that the table store size is about 60% of the total requested memory.
defaultMemoryLimit = "2Gi" defaultMemoryLimit = "2Gi"
defaultDataAccess = "Full" defaultDataAccess = "Full"
defaultDatastreamBufferSize = 1024 * 1024 defaultElectionPeriodMs = 7500
defaultDatastreamBufferSpikeSize = 1024 * 1024 * 500
defaultElectionPeriodMs = 7500
) )
// VizierTmplValues are the template values that can be used to fill out templated Vizier YAMLs. // VizierTmplValues are the template values that can be used to fill out templated Vizier YAMLs.
...@@ -298,6 +297,19 @@ func GenerateSecretsYAML(clientset *kubernetes.Clientset, versionStr string) (st ...@@ -298,6 +297,19 @@ func GenerateSecretsYAML(clientset *kubernetes.Clientset, versionStr string) (st
return secretsYAML, nil return secretsYAML, nil
} }
func patchContainerEnvIfValueExists(containerName string, envName string, valueName string) *yamls.K8sTemplateOptions {
placeholder := fmt.Sprintf("__%s__", strings.Replace(envName, "PL", "PX", 1))
return &yamls.K8sTemplateOptions{
TemplateMatcher: yamls.GenerateContainerNameMatcherFn(containerName),
Patch: fmt.Sprintf(`{"spec": {"template": { "spec": { "containers": [{"name": "%s", "env": [{"name": "%s"}]}] } } } }`, containerName, placeholder),
Placeholder: fmt.Sprintf(`- name: %s`, placeholder),
TemplateValue: fmt.Sprintf(`{{- if .Values.%s }}
- name: %s
value: "{{ .Values.%s }}"
{{- end}}`, valueName, envName, valueName),
}
}
func generateVzDepsYAMLs(clientset *kubernetes.Clientset, yamlMap map[string]string) (string, string, error) { func generateVzDepsYAMLs(clientset *kubernetes.Clientset, yamlMap map[string]string) (string, string, error) {
natsYAML, err := yamls.TemplatizeK8sYAML(clientset, yamlMap[natsYAMLPath], append(GlobalTemplateOptions, []*yamls.K8sTemplateOptions{ natsYAML, err := yamls.TemplatizeK8sYAML(clientset, yamlMap[natsYAMLPath], append(GlobalTemplateOptions, []*yamls.K8sTemplateOptions{
{ {
...@@ -403,18 +415,8 @@ func generateVzYAMLs(clientset *kubernetes.Clientset, yamlMap map[string]string) ...@@ -403,18 +415,8 @@ func generateVzYAMLs(clientset *kubernetes.Clientset, yamlMap map[string]string)
Placeholder: "__PX_DATA_ACCESS__", Placeholder: "__PX_DATA_ACCESS__",
TemplateValue: fmt.Sprintf(`{{ if .Values.dataAccess }}"{{ .Values.dataAccess }}"{{else}}"%s"{{end}}`, defaultDataAccess), TemplateValue: fmt.Sprintf(`{{ if .Values.dataAccess }}"{{ .Values.dataAccess }}"{{else}}"%s"{{end}}`, defaultDataAccess),
}, },
{ patchContainerEnvIfValueExists("pem", "PL_DATASTREAM_BUFFER_SIZE", "datastreamBufferSize"),
TemplateMatcher: yamls.GenerateContainerNameMatcherFn("pem"), patchContainerEnvIfValueExists("pem", "PL_DATASTREAM_BUFFER_SPIKE_SIZE", "datastreamBufferSpikeSize"),
Patch: `{"spec": {"template": { "spec": { "containers": [{"name": "pem", "env": [{"name": "PL_DATASTREAM_BUFFER_SIZE", "value": "__PX_DATASTREAM_BUFFER_SIZE__"}]}] } } } }`,
Placeholder: "__PX_DATASTREAM_BUFFER_SIZE__",
TemplateValue: fmt.Sprintf(`{{ if .Values.datastreamBufferSize }}"{{.Values.datastreamBufferSize}}"{{else}}"%d"{{end}}`, defaultDatastreamBufferSize),
},
{
TemplateMatcher: yamls.GenerateContainerNameMatcherFn("pem"),
Patch: `{"spec": {"template": { "spec": { "containers": [{"name": "pem", "env": [{"name": "PL_DATASTREAM_BUFFER_SPIKE_SIZE", "value": "__PX_DATASTREAM_BUFFER_SPIKE_SIZE__"}]}] } } } }`,
Placeholder: "__PX_DATASTREAM_BUFFER_SPIKE_SIZE__",
TemplateValue: fmt.Sprintf(`{{ if .Values.datastreamBufferSpikeSize }}"{{.Values.datastreamBufferSpikeSize}}"{{else}}"%d"{{end}}`, defaultDatastreamBufferSpikeSize),
},
{ {
TemplateMatcher: yamls.GenerateResourceNameMatcherFn("vizier-metadata"), TemplateMatcher: yamls.GenerateResourceNameMatcherFn("vizier-metadata"),
Patch: `{"spec": {"template": {"spec": {"containers": [{"name": "app", "env": [{"name": "PL_RENEW_PERIOD","value": "__PX_RENEW_PERIOD__"}]}] } } } }`, Patch: `{"spec": {"template": {"spec": {"containers": [{"name": "app", "env": [{"name": "PL_RENEW_PERIOD","value": "__PX_RENEW_PERIOD__"}]}] } } } }`,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment