-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
#1119 disable updating feature #1126
Conversation
Could you please add a possibility to configure explanation message into API, as described in the task |
get: | ||
summary: Collect telemetry data | ||
description: Collect telemetry data including app info, system info, collections info, cluster info, configs and statistics | ||
operationId: telemetry |
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.
could you please add tags, so the API is grouped in UI properly
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.
done
src/actix/api/service_api.rs
Outdated
pub enable: bool, | ||
} | ||
|
||
#[put("/enable_updating")] |
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.
In REST naming convention it is prefered to use noun + (optional) action for API endpoints. For example:
GET /is_updating_enabled -> GET /lock
PUT /enable_updating -> PUT /lock
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.
done, I use write_lock
name instead of lock
openapi/openapi-service.ytt.yaml
Outdated
type: boolean | ||
responses: #@ response(array(reference("TelemetryData"))) | ||
|
||
/enable_updating: |
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.
Is there supposed to be a param?
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.
fixed
#[derive(Deserialize, Serialize, JsonSchema)] | ||
pub struct WriteLockStatus { | ||
pub locked: bool, | ||
pub error_message: Option<String>, |
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.
nitpick: this object mixes both locking and unlocking state together.
What about having two REST APIs:
- lock with optional message
- unlock (no message required)
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.
Sounds good. Do you like such API?
PUT /wtite_lock -> lock writing with optional message
PUT /write_unlock -> unlock writing
GET /write_lock -> check if locked
GET /write_unlock -> check if unlocked
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 for me!
Maybe you could ask for some feedback from the cloud team if they are the main users for it.
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 implemented it. I will fix API if the cloud team will wish something else.
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.
GET /write_lock -> check if locked
GET /write_unlock -> check if unlocked
How is this supposed to work? Look redundant
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.
also lock
is supposed to be a noun, not verb. So I would say that PUT /write_unlock
is redundant too
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.
check if locked and check if unlocked. @agourlay sold me ideas about PUT write_lock
and PUT write_unlock
because lock and unlock have different parameters. And GET
function imho is expected in this both paths
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 going away from this idea of exposing a write lock
which is a bit confusing in terms of naming.
For instance, I find having a read-only
mode clearer.
GET /read-only
PUT /read-only/enable
PUT /read-only/disable
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.
Thanks for the option, LGTM. Do you accept such api @generall?
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.
Final api
POST /locks
{
error_message: "Ram high watermark reached"
write: true
}
GET is the same
pub fn set_write_lock(&self, locked: bool, error_message: Option<String>) -> bool { | ||
let prev_value = self | ||
.write_lock | ||
.swap(locked, std::sync::atomic::Ordering::Relaxed); |
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.
nitpick: it would nice to capture the date at which the lock was enabled.
This would enable to have a since
field in the error message by default.
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.
IMHO Not needed. Because this since
cloud team can format itself in the error message. Only they know about the reasons for blocking and only they should decide about since
timestamp
Co-authored-by: Arnaud Gourlay <arnaud.gourlay@gmail.com>
#1119
This PR implements disabling updates. Cloud team can forbidden any updates from users to prevent large disk usage.
All Submissions:
New Feature Submissions:
cargo fmt
command prior to submission?cargo clippy
command?Changes to Core Features: