Skip to content
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

Add configuration for solomon exporter: specify host and some instance tags #258

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ else
DOCKER_BUILD_ARGS += --build-arg VERSION="$(OPERATOR_TAG)"
endif
DOCKER_BUILD_ARGS += --build-arg REVISION="$(shell git rev-parse HEAD)"
DOCKER_BUILD_ARGS += --build-arg BUILD_DATE="$(shell date --rfc-3339=seconds)"
DOCKER_BUILD_ARGS += --build-arg BUILD_DATE="$(shell date -Iseconds)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this to a separate PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, moved here: #260.


# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down
8 changes: 8 additions & 0 deletions pkg/components/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,20 @@ func getConfigPostprocessingCommand(configFileName string) string {
return fmt.Sprintf("sed -i -s \"s/{%v}/${%v}/g\" %v; ", envVar, envVar, configPath)
}

substitutePlaceholderWithCommand := func(placeholder string, command string) string {
// Replace placeholder {placeholder} with the output of the given command.
return fmt.Sprintf("sed -i -s \"s/{%v}/$(%v)/g\" %v; ", placeholder, command, configPath)
}

postprocessScript := fmt.Sprintf("cp %v %v; ", configTemplatePath, configPath)

for _, envVar := range getConfigPostprocessEnv() {
postprocessScript += substituteEnvCommand(envVar.Name)
}

postprocessScript += substitutePlaceholderWithCommand("POD_FQDN", "hostname -f")
postprocessScript += substitutePlaceholderWithCommand("POD_SHORT_HOSTNAME", "hostname -s")

command += fmt.Sprintf("echo '%v' > %v; ", postprocessScript, postprocessScriptPath)
command += fmt.Sprintf("chmod +x '%v'; ", postprocessScriptPath)
command += fmt.Sprintf("source %v; ", postprocessScriptPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
achulkov2 marked this conversation as resolved.
Show resolved Hide resolved
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetDataNodeConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%true;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetDiscoveryConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetExecNodeConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%true;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetHTTPProxyConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetMasterConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
debug={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%true;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
debug={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetQueueAgentConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetRPCProxyConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%true;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetSchedulerConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%true;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetTCPProxyConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetTabletNodeConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%true;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
info={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/canondata/TestGetYQLAgentConfig/test.canondata
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
"enable_ipv6"=%false;
retries=1000;
};
"solomon_exporter"={
host="{POD_SHORT_HOSTNAME}";
"instance_tags"={
"k8s_pod_name"="{K8S_POD_NAME}";
};
};
logging={
writers={
debug={
Expand Down
6 changes: 6 additions & 0 deletions pkg/ytconfig/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ type AddressResolver struct {
LocalhostNameOverride *string `yson:"localhost_name_override,omitempty"`
}

type SolomonExporter struct {
Host *string `yson:"host,omitempty"`
InstanceTags map[string]string `yson:"instance_tags,omitempty"`
}

type PemBlob struct {
FileName string `yson:"file_name,omitempty"`
Value string `yson:"value,omitempty"`
Expand Down Expand Up @@ -95,6 +100,7 @@ type BusServer struct {
// BasicServer is used as a basic config for basic components, such as clocks or discovery.
type BasicServer struct {
AddressResolver AddressResolver `yson:"address_resolver"`
SolomonExporter SolomonExporter `yson:"solomon_exporter"`
Logging Logging `yson:"logging"`
MonitoringPort int32 `yson:"monitoring_port"`
RPCPort int32 `yson:"rpc_port"`
Expand Down
8 changes: 8 additions & 0 deletions pkg/ytconfig/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ func (g *BaseGenerator) fillAddressResolver(c *AddressResolver) {
c.Retries = &retries
}

func (g *BaseGenerator) fillSolomonExporter(c *SolomonExporter) {
c.Host = ptr.String("{POD_SHORT_HOSTNAME}")
c.InstanceTags = map[string]string{
"k8s_pod_name": "{K8S_POD_NAME}",
}
}

func (g *BaseGenerator) fillPrimaryMaster(c *MasterCell) {
c.Addresses = g.getMasterAddresses()
c.Peers = g.getMasterHydraPeers()
Expand Down Expand Up @@ -185,6 +192,7 @@ func (g *BaseGenerator) fillCypressAnnotations(c *map[string]any) {
func (g *BaseGenerator) fillCommonService(c *CommonServer, s *ytv1.InstanceSpec) {
// ToDo(psushin): enable porto resource tracker?
g.fillAddressResolver(&c.AddressResolver)
g.fillSolomonExporter(&c.SolomonExporter)
g.fillClusterConnection(&c.ClusterConnection, s.NativeTransport)
g.fillCypressAnnotations(&c.CypressAnnotations)
c.TimestampProviders.Addresses = g.getMasterAddresses()
Expand Down
Loading