From 939f38c562dfc8ff11193cc941b59ee614c458c3 Mon Sep 17 00:00:00 2001 From: Marina Pereskokova Date: Thu, 4 Apr 2024 13:25:06 +0300 Subject: [PATCH] Add yqla token file in container (#140) * Add yqla token file in container * Codestyle * Canonize * Remove trailing newline in yqla token file --------- Co-authored-by: Marina Pereskokova --- pkg/components/yql_agent.go | 1 + pkg/consts/defaults.go | 4 +++- pkg/ytconfig/canondata/TestGetYQLAgentConfig/test.canondata | 1 + pkg/ytconfig/yql_agent.go | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/components/yql_agent.go b/pkg/components/yql_agent.go index 85a4a98b..34296d2a 100644 --- a/pkg/components/yql_agent.go +++ b/pkg/components/yql_agent.go @@ -156,6 +156,7 @@ func (yqla *YqlAgent) doSync(ctx context.Context, dry bool) (ComponentStatus, er if !dry { ss := yqla.server.buildStatefulSet() container := &ss.Spec.Template.Spec.Containers[0] + container.Command = []string{"sh", "-c", fmt.Sprintf("echo -n $YT_TOKEN > %s; %s", consts.DefaultYqlTokenPath, strings.Join(container.Command, " "))} container.EnvFrom = []corev1.EnvFromSource{yqla.secret.GetEnvSource()} if yqla.ytsaurus.GetResource().Spec.UseIPv6 && !yqla.ytsaurus.GetResource().Spec.UseIPv4 { container.Env = []corev1.EnvVar{{Name: "YT_FORCE_IPV4", Value: "0"}, {Name: "YT_FORCE_IPV6", Value: "1"}} diff --git a/pkg/consts/defaults.go b/pkg/consts/defaults.go index 5dfd25c9..1dbbc4a1 100644 --- a/pkg/consts/defaults.go +++ b/pkg/consts/defaults.go @@ -11,9 +11,11 @@ const DefaultCABundlePath = "/etc/ssl/certs/ca-certificates.crt" const UIUserName = "robot-ui" const StrawberryControllerUserName = "robot-strawberry-controller" -const YqlUserName = "yql_agent" const YtsaurusOperatorUserName = "robot-yt-k8s-operator" +const YqlUserName = "yql_agent" +const DefaultYqlTokenPath = "/usr/yql_agent_token" + const StartUID = 19500 const DefaultHTTPProxyRole = "default" diff --git a/pkg/ytconfig/canondata/TestGetYQLAgentConfig/test.canondata b/pkg/ytconfig/canondata/TestGetYQLAgentConfig/test.canondata index 88870681..1754c33a 100644 --- a/pkg/ytconfig/canondata/TestGetYQLAgentConfig/test.canondata +++ b/pkg/ytconfig/canondata/TestGetYQLAgentConfig/test.canondata @@ -106,6 +106,7 @@ ]; }; "yql_plugin_shared_library"="/usr/lib/yql/libyqlplugin.so"; + "yt_token_path"="/usr/yql_agent_token"; "mr_job_binary"="/usr/bin/mrjob"; "udf_directory"="/usr/lib/yql"; "additional_clusters"={ diff --git a/pkg/ytconfig/yql_agent.go b/pkg/ytconfig/yql_agent.go index 532c4096..902b00f5 100644 --- a/pkg/ytconfig/yql_agent.go +++ b/pkg/ytconfig/yql_agent.go @@ -20,6 +20,7 @@ type GatewayConfig struct { type YQLAgent struct { GatewayConfig GatewayConfig `yson:"gateway_config"` YqlPluginSharedLibrary string `yson:"yql_plugin_shared_library"` + YTTokenPath string `yson:"yt_token_path"` // For backward compatibility. MRJobBinary string `yson:"mr_job_binary"` @@ -55,6 +56,7 @@ func getYQLAgentServerCarcass(spec *ytv1.YQLAgentSpec) (YQLAgentServer, error) { // For backward compatibility. c.YQLAgent.UDFDirectory = "/usr/lib/yql" c.YQLAgent.MRJobBinary = "/usr/bin/mrjob" + c.YQLAgent.YTTokenPath = consts.DefaultYqlTokenPath c.Logging = getYQLAgentLogging(spec)