-
Notifications
You must be signed in to change notification settings - Fork 840
Add endpoints to deactivate and restore config #629
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
Conversation
9abb7c0 to
62bcea7
Compare
|
Fixes weaveworks/service#1595 |
|
You need to run |
a3a2106 to
820a5a4
Compare
|
Now I've looked at this a bit more, it will do something slightly surprising. The DB has potentially many configs for an instance, each with a new ID number. The code in this PR will mark all rows for an instance as deleted on This wouldn't play well if, for instance, some other component was marking individual rows as deleted. (Although I can't see anything like that). Another issue is that I'm not sure what to do about this. #332 covers garbage-collecting old rows |
|
There is an issue to report deleted configs - #329 |
rndstr
left a comment
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.
just a few comments while passing by!
pkg/configs/db/timed.go
Outdated
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.
"DeactivateConfig" & same in traced.go
pkg/configs/db/timed.go
Outdated
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.
"RestoreConfig" & same in traced.go
pkg/configs/db/memory/memory.go
Outdated
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.
return c.deletedAt.IsZero()?
pkg/configs/db/postgres/postgres.go
Outdated
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.
What about using WARN here? Unless DEBUG is the default level, it doesn't say that it's stalling
|
In regard to "ruler will only see the config as changed if there is one for the same instance with a higher ID number" - #329, Elena and I discussed IRL an idea to change the way deleted configs are interpreted. At present, the DB queries fetch the last active (non-deleted) config. So you can revert from the latest config to the one before by setting The code that updates ruler has a note of the highest ID number it has seen, and polls looking for active configs with higher numbers. So it will never report a deleted row, new or otherwise. Suppose we change the behaviour to return the config with the highest ID, deleted or not. Then we can implement "delete a config" by adding a single new row with If we wanted a 'revert to previous' feature, it would now be implemented by adding a new row with the previous config. cc @jml @tomwilkie |
c903b6a to
2432316
Compare
|
Changed deactivation as @bboreham described (add new config row with |
|
@bboreham PTAL |
bboreham
left a comment
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.
Good overall: I think you'd have to change ruler to inspect DeletedAt before this could be merged.
And at least make an issue to make any other users of the data (GUIs, ...) aware that they can now receive deleted records.
pkg/configs/configs.go
Outdated
| Config Config `json:"config"` | ||
| ID ID `json:"id"` | ||
| Config Config `json:"config"` | ||
| DeletedAt time.Time |
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.
why doesn't this have a json tag?
pkg/configs/db/postgres/postgres.go
Outdated
| } | ||
|
|
||
| // GetLastConfig gets a last configuration (active or deleted). | ||
| func (d DB) GetLastConfig(userID string) (configs.View, error) { |
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.
I have a feeling this function isn't necessary: GetConfig is good enough for the purpose.
pkg/configs/db/postgres/postgres.go
Outdated
| return cfgView, err | ||
| } | ||
|
|
||
| // SetDeletedAtConfig sets a deletedAt for configuration. |
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.
I think it's worth commenting why "set" is actually an "insert".
|
What happens in |
6e27d2d to
15878d3
Compare
I suppose the same when config changes in the middle of the operation, this config will be updated/deleted on next |
|
@bboreham PTAL |
- call deactivate on instance deletion
should call this to deactivate config after instance deletion