-
Notifications
You must be signed in to change notification settings - Fork 12
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
base: master
Are you sure you want to change the base?
pack: skip unavailable configs from etcd and tcs #1066
Conversation
ddf6386
to
c75c205
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
c75c205
to
7b9cd77
Compare
30ff7e3
to
b64c71a
Compare
b64c71a
to
bfb7321
Compare
bfb7321
to
460b4fa
Compare
There was a problem hiding this 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.
bcefd0a
to
f729a21
Compare
f729a21
to
48559b6
Compare
48559b6
to
bf7ba6c
Compare
bf7ba6c
to
f7e5f77
Compare
@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
503ded7
to
d4f2418
Compare
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
d4f2418
to
22ada6a
Compare
I will update the second commit message after we discussed final solution. |
cli/running/running.go
Outdated
@@ -126,6 +126,14 @@ type providerImpl struct { | |||
instanceCtx *InstanceCtx | |||
} | |||
|
|||
type SkipClusterConfig int |
There was a problem hiding this comment.
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).
cli/running/running.go
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Please, mark the PR as ready for review (it is draft now). |
cli/running/running.go
Outdated
@@ -126,6 +126,14 @@ type providerImpl struct { | |||
instanceCtx *InstanceCtx | |||
} | |||
|
|||
type SkipClusterConfig int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type SkipClusterConfig int | |
type ConfigLoad int |
cli/running/running.go
Outdated
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. |
There was a problem hiding this comment.
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:
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. |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
load/skip scripts?
cli/cmd/connect.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Load, expected replicaset status
.
cli/instances/list.go
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip/instance script required?
cli/replicaset/rebootstrap.go
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Load.
cli/running/running_test.go
Outdated
@@ -35,7 +35,7 @@ func Test_CollectInstances(t *testing.T) { | |||
instances, err := CollectInstances("script", instancesEnabledPath, | |||
integrity.IntegrityCtx{ | |||
Repository: &mockRepository{}, | |||
}, true) | |||
}, LoadConfig) |
There was a problem hiding this comment.
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
17c32a0
to
94c464a
Compare
Closes #1038
@TarantoolBot document
Title: pack: skip unavailable configs from etcd and tcs
This patch fixes the
tt pack
error ifetcd
ortcs
are unavailable during package creation.