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

Fix queue agent init script usage for 24.* #356

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
30 changes: 28 additions & 2 deletions pkg/components/queue_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,37 @@ func (qa *QueueAgent) init(ctx context.Context, ytClient yt.Client) (err error)

func (qa *QueueAgent) prepareInitQueueAgentState() {
path := "/usr/bin/init_queue_agent_state"
proxy := qa.cfgen.GetHTTPProxiesServiceAddress(consts.DefaultHTTPProxyRole)

// Somewhere in 24.1 this script has changed signature and since it is not tied to some version we can check
// we will try to call it new way and fallback to old way on error.
// COMPAT(l0kix2): Remove after 23.1 not supported in the yt operator.
oldVersionInvokation := fmt.Sprintf("%s --create-registration-table --create-replicated-table-mapping-table --recursive --ignore-existing --proxy %s",
path,
proxy,
)
newVersionInvokation := fmt.Sprintf("%s --latest --proxy %s",
path,
proxy,
)

script := []string{
initJobWithNativeDriverPrologue(),
fmt.Sprintf("if [[ -f \"%s\" ]]; then %s --create-registration-table --create-replicated-table-mapping-table --recursive --ignore-existing --proxy %s; fi",
path, path, qa.cfgen.GetHTTPProxiesServiceAddress(consts.DefaultHTTPProxyRole)),
fmt.Sprintf(`if [ ! -f %s ]; then`, path),
fmt.Sprintf(`echo "%s doesn't exist, nothing to do"`, path),
`exit 0`,
`fi`,
// Temporary turning off exiting on non-zero status, since we expect this command may fail on
// unexpected arguments in the older server versions.
// In case arguments are valid and other error occurs it is not a problem, since new binary will fail with
// the old arguments later anyway.
`set +e`,
newVersionInvokation,
`if [ $? -ne 0 ]; then`,
`set -e`,
`echo "Binary execution failed. Running with an old set of arguments"`,
oldVersionInvokation,
`fi`,
}

qa.initQAState.SetInitScript(strings.Join(script, "\n"))
Expand Down
11 changes: 11 additions & 0 deletions pkg/testutil/spec_builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ func WithQueryTracker(ytsaurus *ytv1.Ytsaurus) *ytv1.Ytsaurus {
return ytsaurus
}

func WithQueueAgent(ytsaurus *ytv1.Ytsaurus) *ytv1.Ytsaurus {
ytsaurus.Spec.QueueAgents = &ytv1.QueueAgentSpec{
InstanceSpec: ytv1.InstanceSpec{
InstanceCount: 1,
// Older version doesn't have /usr/bin/ytserver-queue-agent
Image: ptr.To(CoreImageNextVer),
},
}
return ytsaurus
}

func WithRPCProxies(ytsaurus *ytv1.Ytsaurus) *ytv1.Ytsaurus {
ytsaurus.Spec.RPCProxies = []ytv1.RPCProxiesSpec{
createRPCProxiesSpec(),
Expand Down
1 change: 1 addition & 0 deletions test/e2e/ytsaurus_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ var _ = Describe("Basic test for Ytsaurus controller", func() {

ytsaurus := testutil.CreateBaseYtsaurusResource(namespace)
ytsaurus = testutil.WithQueryTracker(ytsaurus)
ytsaurus = testutil.WithQueueAgent(ytsaurus)

g := ytconfig.NewGenerator(ytsaurus, "local")

Expand Down
Loading