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

Add previous-scale annotation for idled resources #10421

Merged

Conversation

DirectXMan12
Copy link
Contributor

This records the previous scale of an idled resource on idling.
This is useful in situations where finding and loading the associated
endpoints object would non-ideal (e.g. the web console).

@DirectXMan12
Copy link
Contributor Author

cc @smarterclayton @jwforres

@knobunc
Copy link
Contributor

knobunc commented Aug 15, 2016

LGTM

@sjenning
Copy link
Contributor

lgtm

@ncdc
Copy link
Contributor

ncdc commented Aug 16, 2016

@smarterclayton who is doing the api review? you / @deads2k / @liggitt / @jwforres ?

@@ -9,6 +9,10 @@ const (
// objects associated with the idled endpoints
UnidleTargetAnnotation = "idling.alpha.openshift.io/unidle-targets"

// PreviousScaleAnnotation contains the previous scale of a scalable object
// (currently only applied by the idler)
PreviousScaleAnnotation = "scale.openshift.io/previous-scale"
Copy link
Contributor

Choose a reason for hiding this comment

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

This name doesn't match what this is doing. When I scale an object, I don't get this value filled in. This looks tightly coupled to idling.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I would probably call this idling.alpha.openshift.io/previous-scale or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can, but when I was talking to @smarterclayton, we were discussing the idea of making something like this automatically applied on scales in the future (and then have scale.openshift.io/xyz passed through the scale subresource so that it can act like a prototype API field, just like other objects), so using something like this would future-proof that somewhat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(although using scale.openshift.io instead of scale.kubernetes.io might complicate that somewhat)

Copy link
Contributor

Choose a reason for hiding this comment

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

I can, but when I was talking to @smarterclayton, we were discussing the idea of making something like this automatically applied on scales in the future (and then have scale.openshift.io/xyz passed through the scale subresource so that it can act like a prototype API field, just like other objects), so using something like this would future-proof that somewhat.

I'm not really convinced that I'd like to use an annotation to remember previous state (see problems with the other kube attempts to use annotations to store history). I'm also not seeing a lot of value for "undo" in the general case. It seems like it would open us up to a new class of privilege escalation attacks if we had a controller that attempted to reconcile this annotation automatically.

I'd rather target the information that we want to preserve for its current usage.

@smarterclayton is there some more complete design that covers how we'd resolve the problems of history tracking annotations and privilege escalation attacks based on controllers watching annotations (think DC scaling existing RC, not scaling the current object)? Are you ok with scoping this to address our current, narrow need first?

@deads2k
Copy link
Contributor

deads2k commented Aug 16, 2016

Name needs updating and it would be nice to see a CLI usage demonstrating your intent, which I think is something like:

  1. create thing
  2. scale thing up
  3. idle thing
  4. knowing only the thing.Name, scale it back to the value from step 2.

Other than the name, I'm fine with this.

@DirectXMan12
Copy link
Contributor Author

CLI usage

ack, will add tomorrow

@deads2k
Copy link
Contributor

deads2k commented Aug 16, 2016

ack, will add tomorrow

Thanks. There's probably a test/cmd/*.sh script that would fit.

@smarterclayton
Copy link
Contributor

Edit on a resource is edit on scale, so what's the privilege escalation?

Preserving the user's previous scale value is important - if the user has
an idled pet set, restoring scale to 1 on unidle is completely wrong,
likewise an app that is supposed to be HA (2 pods) that gets idled back to
1, but no human notices.

On Tue, Aug 16, 2016 at 5:18 PM, David Eads [email protected]
wrote:

ack, will add tomorrow

Thanks. There's probably a test/cmd/*.sh script that would fit.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#10421 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p89IQC-PXl_Hw_ft_SOtFtdzwdrNks5qgikfgaJpZM4JknXz
.

@deads2k
Copy link
Contributor

deads2k commented Aug 16, 2016

Preserving the user's previous scale value is important - if the user has
an idled pet set, restoring scale to 1 on unidle is completely wrong,

For idling, sure. No issue with this for idling. In the general case though, I don't see why I would try to build a scaling history

@smarterclayton
Copy link
Contributor

Maybe I missed the context, but some status displaying recent scaling might
actually be useful for automated controllers. Hard to say, knowing "why"
someone last scaled (human, or automated) might be relevant. And is
relevant for idling in some contexts.

On Tue, Aug 16, 2016 at 6:02 PM, David Eads [email protected]
wrote:

Preserving the user's previous scale value is important - if the user has
an idled pet set, restoring scale to 1 on unidle is completely wrong,

For idling, sure. No issue with this for idling. In the general case
though, I don't see why I would try to build a scaling history


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#10421 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_p96lK1xzvY3f9NPO4gF78suoRU7Zks5qgjNxgaJpZM4JknXz
.

@deads2k
Copy link
Contributor

deads2k commented Aug 16, 2016

Maybe I missed the context, but some status displaying recent scaling might
actually be useful for automated controllers.

Maybe, but I'd rather add it for a concrete reason, set in a way that makes sense, and get a name that makes sense. To be generally useful, you need to have the contract on the polymorphic scale endpoint change the annotation. This pull does none of those things.

To be clear, we're arguing over an annotation name here, not the use in this narrow case. The annotation is set only by idling for a narrow reason, I think it deserves a narrowly scoped name.

@deads2k
Copy link
Contributor

deads2k commented Aug 16, 2016

Also, scale on a DC does not edit the DC and without access to the rcs you can never reproduce the effect since you don't know the shape of the RC you're scaling by touching the DC. It's like a dc status. It's actually mucking directly with rcs.

@DirectXMan12
Copy link
Contributor Author

Also, scale on a DC does not edit the DC

I believe it does, unless someone changed it since I added support for the /scale subresource on DCs. oc scale didn't used to, but when I added the scale endpoint, we changed it to edit the DC and reconcile the RCs with the DCs, so unless someone changed it after that, the /scale subresource modifies DCs.

@smarterclayton
Copy link
Contributor

smarterclayton commented Aug 17, 2016 via email

@DirectXMan12
Copy link
Contributor Author

To be generally useful, you need to have the contract on the polymorphic scale endpoint change the annotation. This pull does none of those things.

Sure, that's a thing that requires an update in the future (and it's something I intend to work on, as it would be generally useful to be able to prototype scale API fields the same way we prototype the addition of fields to other API objects), but I mainly wanted to have something that was forwards compatible, so to speak.

@deads2k
Copy link
Contributor

deads2k commented Aug 17, 2016

but I mainly wanted to have something that was forwards compatible, so to speak.

Narrow name for a narrow case. The general solution to a theoretical general problem that requires upstream API changes we won't pick for a general need we don't have is probably more than is worth picking up here.

@deads2k
Copy link
Contributor

deads2k commented Aug 17, 2016

Narrow name for a narrow case. The general solution to a theoretical general problem that requires upstream API changes we won't pick for a general need we don't have is probably more than is worth picking up here.

"idling.alpha.openshift.io/previous-scale" is perfect. It's scoped to its use, the name identifies who is setting it and it matches the behavior you'd expect when idling and unidling.

"scale.openshift.io/previous-scale" is overly broad. It suggests that the scale operation is controlling this (it isn't). To make it behave as expected, you'd have to change the contract on the polymorphic /scale endpoint. Even if you did that, such an annotation wouldn't be scoped to openshift. And, if you want this power out of scale, then retrieving via scale makes sense and this doesn't do that either.

@ncdc
Copy link
Contributor

ncdc commented Aug 17, 2016

We can always deprecate idling.alpha.openshift.io/previous-scale and replace it with something else that's more appropriate for a broader scope when the time comes. I suggest we just use idling.alpha.openshift.io/previous-scale for now.

@DirectXMan12
Copy link
Contributor Author

yeah, for the sake of moving this forward I'll just change it to the annotation suggested by @deads2k

@deads2k
Copy link
Contributor

deads2k commented Aug 17, 2016

lgtm [merge]

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@DirectXMan12
Copy link
Contributor Author

Missing quote in the cmd test. Fixed.

@smarterclayton
Copy link
Contributor

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Aug 17, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/8206/) (Image: devenv-rhel7_4873)

@DirectXMan12 DirectXMan12 force-pushed the feature/idling-prev-scale branch from 13d4018 to 20ab280 Compare August 18, 2016 14:31
This records the previous scale of an idled resource on idling.
This is useful in situations where finding and loading the associated
endpoints object would non-ideal (e.g. the web console).
@deads2k
Copy link
Contributor

deads2k commented Aug 18, 2016

@DirectXMan12 any real changes?

@DirectXMan12
Copy link
Contributor Author

@deads2k no, just rebased b/c there was a weird error in the console log of the tests about one of the files needing a merge.

@deads2k
Copy link
Contributor

deads2k commented Aug 18, 2016

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 20ab280

@ncdc
Copy link
Contributor

ncdc commented Aug 18, 2016

[test] for fun

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 20ab280

@openshift-bot openshift-bot merged commit d4a64c0 into openshift:master Aug 19, 2016
@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/8208/)

@DirectXMan12 DirectXMan12 deleted the feature/idling-prev-scale branch August 19, 2016 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants