Conversation
fcc79dc to
4c89cfa
Compare
|
I'm not sure what state the integration tests are in but there are a lot of failures that don't seem related to this changeset at all. If you think I need to investigate any of them let me know. |
|
I can confirm they are all known failures and unrelated to this PR. |
pkg/platform/api/settings.go
Outdated
| } | ||
|
|
||
| func getProjectHostFromConfig() string { | ||
| cfg, err := config.New() |
There was a problem hiding this comment.
We should route in the config instance from main / prime. Since that controls closing and writing of the config file. I think we'll run into conflicts if we have multiple instances.
There was a problem hiding this comment.
Hmm this one is a bit awkward. This package is so low-level that passing the config in here will lead to A LOT of cascading changes. Many function signatures will need to be updated to pass a config instance or an interface. I've added a proposal for DB protection in this commit.
We could consider something like above with a lockfile, some sort of global registry of config instances (though this doesn't protect us for inter-process access), bite the bullet and do the updates required to pass the config instance around, or some other solution that I'm not thinking of.
ce038dd to
89ae0b6
Compare
internal/config/instance.go
Outdated
| if err != nil { | ||
| return errs.Wrap(err, "Could not create lock file for %s", i.lockfile) | ||
| } | ||
| defer pidLock.Close() |
There was a problem hiding this comment.
This would close the lock after the connection has been created, which doesn't solve the potential conflict. In order for the lock to be valid it would have to be closed when the config connection is closed, but if that were the case then your use-case would not work either as it would encounter the lock..
I think this might be a scenario where it makes more sense to break our rule of "no globals" given the application of the package (api) is so global, and not contextual. Perhaps in time we can properly solve this once and for all by threading a context everywhere.
So I'd suggest calling something like api.Init(cfg) from main.go. Just make sure that tests are not using this global, because that would break concurrent tests.
There was a problem hiding this comment.
Maybe I'm misunderstanding how the lockfile library works but I believe it's accessing the lockfile only for database writes and then releasing it. Which should prevent us from running into conflicts between the state tool and the service. I'm realizing now that I'm attempting to solve a problem that already exists so I'll look into the app.Init(cfg) approach.
This will be updated in a separate PR
|
@MDrakos oh also, I don't think this is addressing the following AC:
I don't particularly care how, that could be restarting the svc I imagine. |
Yeah, I tried to call this out in one of the integration tests here. The service will pick up the config change after it restarts, or if the config value was set before the service started. The test above my comment specifically sets the config value before the service starts to try to confirm that. |
I could have been more explicit in writing that AC, but the intend is that it picks up the change as it's made, without the user manually restarting the state-svc. It should not require the user to manually restart the svc. If this turns out to be too deep a rabbit hole we can probably descope. |
Naatan
left a comment
There was a problem hiding this comment.
Looking good! Just some churn on the svc restarting stuff -- #3717 (comment)
|
Okay with the latest changes the You have another story for the installers to support config options. If the state tool is installed with the config options set then this will not be an issue. Otherwise it will require a |
Naatan
left a comment
There was a problem hiding this comment.
Looking good, nearly there!
https://activestatef.atlassian.net/browse/CP-1050