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

pack: skip unavailable configs from etcd and tcs #1066

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

patapenka-alexey
Copy link
Contributor

@patapenka-alexey patapenka-alexey commented Dec 16, 2024

Closes #1038

@TarantoolBot document
Title: pack: skip unavailable configs from etcd and tcs

This patch fixes the tt pack error if etcd or tcs are unavailable during package creation.

@patapenka-alexey patapenka-alexey changed the title pack: skip configs from etcd and tcs pack: skip unavailable configs from etcd and tcs Dec 16, 2024
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch from ddf6386 to c75c205 Compare December 16, 2024 14:07
Copy link
Contributor

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Please, add an entry into CHANGELOG.md.

cli/pack/opts.go Outdated
@@ -49,7 +49,7 @@ func initAppsInfo(cliOpts *config.CliOpts, cmdCtx *cmdcontext.CmdCtx, packCtx *P
}
packCtx.AppList = appList
packCtx.AppsInfo, err = running.CollectInstancesForApps(packCtx.AppList, cliOpts,
cmdCtx.Cli.ConfigDir, cmdCtx.Integrity, true)
cmdCtx.Cli.ConfigDir, cmdCtx.Integrity, false)
Copy link
Contributor

@elhimov elhimov Dec 18, 2024

Choose a reason for hiding this comment

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

It looks like the same approach is to be applied to both instances scripts and cluster config. So both of them are required or both of them are optional and it seems wrong in case of tt pack. I'm not sure about cluster config, maybe it's correct that we treat it as configuration and thus able to drop from package, but it seems we are not able to treat instances scripts in the same way because they contain business logic and thus look like the essential part of the package.

Copy link
Contributor

Choose a reason for hiding this comment

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

And regardless of our ability to drop some part of package while preparing it, it looks quite weird that content of the package depends on current availability of some items. What if next time one pack the same application but etcd/tcs config is available? As the content is changed we will get another package for the same application. Do we expect such a behavior?

test/integration/pack/test_pack.py Outdated Show resolved Hide resolved
test/integration/pack/test_pack.py Outdated Show resolved Hide resolved
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch 3 times, most recently from 30ff7e3 to b64c71a Compare December 23, 2024 13:15
@oleg-jukovec oleg-jukovec added the full-ci Enables full ci tests label Dec 23, 2024
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch from b64c71a to bfb7321 Compare December 26, 2024 08:18
CHANGELOG.md Outdated Show resolved Hide resolved
cli/cmd/replicaset.go Outdated Show resolved Hide resolved
cli/cmd/replicaset.go Outdated Show resolved Hide resolved
cli/running/running.go Outdated Show resolved Hide resolved
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch from bfb7321 to 460b4fa Compare December 27, 2024 12:12
Copy link
Contributor

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

We still not skip a config load, but load a config and skip an error.

@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch 2 times, most recently from bcefd0a to f729a21 Compare January 3, 2025 12:12
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch from f729a21 to 48559b6 Compare January 8, 2025 11:06
@patapenka-alexey patapenka-alexey removed the full-ci Enables full ci tests label Jan 9, 2025
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch from 48559b6 to bf7ba6c Compare January 9, 2025 11:08
@patapenka-alexey patapenka-alexey marked this pull request as draft January 9, 2025 11:09
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch from bf7ba6c to f7e5f77 Compare January 9, 2025 11:58
@TarantoolBot document
Title: pack: skip configs from etcd and tcs

This patch fixes the `tt pack` error if `etcd` or `tcs` are unavailable
during package creation.

Part of #1038
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch 4 times, most recently from 503ded7 to d4f2418 Compare January 10, 2025 13:00
@patapenka-alexey patapenka-alexey added the full-ci Enables full ci tests label Jan 10, 2025
From now on only the `check` and `start` commands do not skip errors
during cluster config generation from local, etcs/tcs and env
sources.

Closes #1038
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch from d4f2418 to 22ada6a Compare January 10, 2025 13:19
@patapenka-alexey
Copy link
Contributor Author

I will update the second commit message after we discussed final solution.

@@ -126,6 +126,14 @@ type providerImpl struct {
instanceCtx *InstanceCtx
}

type SkipClusterConfig int
Copy link
Contributor

Choose a reason for hiding this comment

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

This type name confuses me. It will affect not only cluster config but also instances scripts. I would use for type name something more general, like LoadMode or similar and specific name for certain enum values (see below).

Comment on lines 132 to 134
SkipConfig SkipClusterConfig = iota // Skip cluster config loading at all.
SkipConfigErrors // Skip errors at cluster config loading.
LoadConfig // Load cluster config, trigger an errors if not.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
SkipConfig SkipClusterConfig = iota // Skip cluster config loading at all.
SkipConfigErrors // Skip errors at cluster config loading.
LoadConfig // Load cluster config, trigger an errors if not.
SkipScriptsAndClusterConfig LoadMode = iota // Skip loading of instances scripts and cluster config.
IgnoreClusterConfigErrors // Skip errors at cluster config loading.
LoadScriptsAndClusterConfig // Load instances scripts and cluster config, trigger an errors if not.

@elhimov
Copy link
Contributor

elhimov commented Jan 13, 2025

Please, mark the PR as ready for review (it is draft now).

@patapenka-alexey patapenka-alexey marked this pull request as ready for review January 13, 2025 09:38
@@ -126,6 +126,14 @@ type providerImpl struct {
instanceCtx *InstanceCtx
}

type SkipClusterConfig int
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
type SkipClusterConfig int
type ConfigLoad int

Comment on lines 132 to 134
SkipConfig SkipClusterConfig = iota // Skip cluster config loading at all.
SkipConfigErrors // Skip errors at cluster config loading.
LoadConfig // Load cluster config, trigger an errors if not.
Copy link
Contributor

@oleg-jukovec oleg-jukovec Jan 13, 2025

Choose a reason for hiding this comment

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

The idiomatic way to name a enums in Go:

Suggested change
SkipConfig SkipClusterConfig = iota // Skip cluster config loading at all.
SkipConfigErrors // Skip errors at cluster config loading.
LoadConfig // Load cluster config, trigger an errors if not.
ConfigSkip SkipClusterConfig = iota // Skip cluster config loading at all.
ConfigLoadWIthErrors // Skip errors at cluster config loading.
ConfigLoadAlways // Load cluster config, trigger an errors if not.

Copy link
Contributor

Choose a reason for hiding this comment

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

LoadMode
LoadConfigSkip
LoadConfigSkipErrors
LoadConfigAlways

cli/cmd/clean.go Outdated
@@ -104,7 +104,7 @@ func internalCleanModule(cmdCtx *cmdcontext.CmdCtx, args []string) error {
}

var runningCtx running.RunningCtx
if err := running.FillCtx(cliOpts, cmdCtx, &runningCtx, args, false); err != nil {
if err := running.FillCtx(cliOpts, cmdCtx, &runningCtx, args, running.SkipConfig); err != nil {
Copy link
Contributor

@oleg-jukovec oleg-jukovec Jan 13, 2025

Choose a reason for hiding this comment

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

load/skip scripts?

@@ -140,7 +140,8 @@ func resolveConnectOpts(cmdCtx *cmdcontext.CmdCtx, cliOpts *config.CliOpts,
newArgs = args[1:]
// FillCtx returns error if no instances found.
var runningCtx running.RunningCtx
if fillErr := running.FillCtx(cliOpts, cmdCtx, &runningCtx, args, false); fillErr == nil {
if fillErr := running.FillCtx(
cliOpts, cmdCtx, &runningCtx, args, running.SkipConfigErrors); fillErr == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Load?

cli/cmd/log.go Outdated
@@ -133,7 +133,7 @@ func internalLogModule(cmdCtx *cmdcontext.CmdCtx, args []string) error {

var err error
var runningCtx running.RunningCtx
if err = running.FillCtx(cliOpts, cmdCtx, &runningCtx, args, false); err != nil {
if err = running.FillCtx(cliOpts, cmdCtx, &runningCtx, args, running.SkipConfig); err != nil {
Copy link
Contributor

@oleg-jukovec oleg-jukovec Jan 13, 2025

Choose a reason for hiding this comment

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

Load - instance scripts?

cli/cmd/play.go Outdated
@@ -99,7 +99,8 @@ func internalPlayModule(cmdCtx *cmdcontext.CmdCtx, args []string) error {
// FillCtx returns error if no instances found.
var runningCtx running.RunningCtx

if err := running.FillCtx(cliOpts, cmdCtx, &runningCtx, []string{args[0]}, false); err == nil {
if err := running.FillCtx(
cliOpts, cmdCtx, &runningCtx, []string{args[0]}, running.SkipConfig); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Load.

@@ -518,7 +519,8 @@ func replicasetFillCtx(cmdCtx *cmdcontext.CmdCtx, ctx *replicasetCtx, args []str
}
// Re-fill context for an application.
ctx.InstName = instName
err := running.FillCtx(cliOpts, cmdCtx, &ctx.RunningCtx, []string{appName}, false)
err := running.FillCtx(
Copy link
Contributor

Choose a reason for hiding this comment

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

Load, expected replicaset status.

@@ -31,7 +31,7 @@ func ListInstances(cmdCtx *cmdcontext.CmdCtx, cliOpts *config.CliOpts) error {
fmt.Printf("instances enabled directory: %s\n", cliOpts.Env.InstancesEnabled)

applications, err := running.CollectInstancesForApps(appList, cliOpts, cmdCtx.Cli.ConfigDir,
cmdCtx.Integrity, false)
cmdCtx.Integrity, running.LoadConfig)
Copy link
Contributor

@oleg-jukovec oleg-jukovec Jan 13, 2025

Choose a reason for hiding this comment

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

Skip/instance script required?

@@ -60,7 +60,7 @@ func cleanDataFiles(instCtx running.InstanceCtx) error {
// and starting it again.
func Rebootstrap(cmdCtx cmdcontext.CmdCtx, cliOpts config.CliOpts, rbCtx RebootstrapCtx) error {
apps, err := running.CollectInstancesForApps([]string{rbCtx.AppName}, &cliOpts,
cmdCtx.Cli.ConfigDir, cmdCtx.Integrity, true)
cmdCtx.Cli.ConfigDir, cmdCtx.Integrity, running.SkipConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

Load.

@@ -35,7 +35,7 @@ func Test_CollectInstances(t *testing.T) {
instances, err := CollectInstances("script", instancesEnabledPath,
integrity.IntegrityCtx{
Repository: &mockRepository{},
}, true)
}, LoadConfig)
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests with a new functionality are missed.

change configuration loading logic
@patapenka-alexey patapenka-alexey force-pushed the patapenka-alexey/gh-1038-tt-pack-error-etcd branch from 17c32a0 to 94c464a Compare January 14, 2025 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full-ci Enables full ci tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tt pack завершается ошибкой при недоступном etcd
5 participants