-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Update oc idle
to patch dc's and rc's instead of update
#11634
Update oc idle
to patch dc's and rc's instead of update
#11634
Conversation
[test] |
@@ -90,16 +92,50 @@ func (c *ScaleAnnotater) UpdateObjectScale(namespace string, ref unidlingapi.Cro | |||
if typedObj.Annotations == nil { | |||
typedObj.Annotations = make(map[string]string) | |||
} | |||
|
|||
originalObj, err := json.Marshal(typedObj) |
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.
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 not use an encoder instead of raw json package?
@mfojtik i would like to have this for 1.4 |
@@ -325,7 +326,8 @@ func (c *UnidlingController) handleRequest(info types.NamespacedName, lastFired | |||
|
|||
scale.Spec.Replicas = scalableRef.Replicas | |||
|
|||
if err = scaleAnnotater.UpdateObjectScale(info.Namespace, scalableRef.CrossGroupObjectReference, obj, scale); err != nil { | |||
codec := kapi.Codecs.LegacyCodec(registered.EnabledVersions()...) |
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.
@liggitt Switched to use runtime.Encode()
, however I am not sure if this is the right way of obtaining a codec here
@liggitt
Am I using the wrong encoder? deploymentconfig object when using
same object when using
EDIT: I receicve an empty array of bytes when generating a {"Spec":{"Replicas":0},"annotations":{"idling.alpha.openshift.io/idled-at":"2016-10-31T19:11:43Z","idling.alpha.openshift.io/previous-scale":"1"}} |
Also fixes #10988 |
cc @DirectXMan12 @fabianofranz @smarterclayton Per Solly's suggestion, I have added a |
Win, now this is looking like properly architected. I imagine this is already covered by tests so we don't need to write new ones, correct? |
Can I get a quick summary of why we can't use patch in scale? Do we need On Nov 1, 2016, at 9:46 AM, Fabiano Franz notifications@github.com wrote: Win, now this is looking like properly architected. I imagine this is — |
Patch on scale with name/namespace/uid set should work correctly. |
I think this is patch under scale - an unrelated change should not block On Nov 1, 2016, at 9:56 AM, Jordan Liggitt notifications@github.com wrote: Patch on scale with name/namespace/uid/resourceVersion set should work — |
Yeah, edited that one second after making that comment |
@liggitt @smarterclayton Should I update unidling/controller/controller.go to use |
This is a problem with scale, not with the clients of Scale. If this is a On Tue, Nov 1, 2016 at 1:49 PM, Juan Vallejo notifications@github.com
|
@smarterclayton @DirectXMan12 updated The only times Patch() is not used is when the resource kind is unknown PTAL |
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 don't necessarily want to block this PR, but I'd prefer that the ScaleUpdater
not be touching the innards (fields) of the ScaleAnnotater
. That seems ugly to me. Otherwise, this is probably fine.
b88b477
to
05aad3e
Compare
@DirectXMan12 Thanks for the feedback! Updated |
@@ -12,6 +12,7 @@ import ( | |||
|
|||
cmdutil "github.com/openshift/origin/pkg/cmd/util" | |||
utilerrors "github.com/openshift/origin/pkg/util/errors" |
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.
Move these imports with the rest of the Openshift imports
f797138
to
f7aede6
Compare
Done! |
f7aede6
to
a3ab2c9
Compare
@@ -131,6 +131,40 @@ func prepFakeClient(t *testing.T, nowTime time.Time, scales ...kextapi.Scale) (* | |||
return true, nil, errors.NewNotFound(action.GetResource().GroupResource(), obj.Name) | |||
}) | |||
|
|||
fakeDeployClient.PrependReactor("patch", "deploymentconfigs", func(action ktestingcore.Action) (bool, runtime.Object, 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.
@DirectXMan12 or @Kargakis PTAL
annotator.ChangeAnnotations(typedObj.Spec.Replicas, typedObj.Annotations) | ||
typedObj.Spec.Replicas = scale.Spec.Replicas | ||
|
||
newObj, err := json.Marshal(typedObj) |
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.
That wasn't still addressed, we should not be using raw json package for any kind of encoding. Sooner or later this will bite us hard. I'd rather fix it before that happens. Here and the next call in the following case, as well.
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.
That wasn't still addressed, we should not be using raw json package for any kind of encoding. Sooner or later this will bite us hard. I'd rather fix it before that happens. Here and the next call in the following case, as well.
Thanks for the feedback, done!
268eee8
to
f8ee34f
Compare
conformance flaked on #10988 re[test] |
f8ee34f
to
df345fa
Compare
flaked on #9076 re[test] |
conformance flaked on #11775 re[test] |
9f9173f
to
d0b68d6
Compare
@DirectXMan12 @smarterclayton any other comments here? |
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'd prefer for the scaleUpdater to be moved to utils if it's being used by both the controller and oc
-- oc
shouldn't have to pull in the entire controller code. Once that's done, this is probably fine.
Makes sense, done |
@DirectXMan12 @fabianofranz I will go ahead and squash if there are no more comments, thanks for the review |
aaa2ceb
to
b701818
Compare
Evaluated for origin test up to b701818 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11552/) (Base Commit: 32c2948) |
LGTM [merge] |
Evaluated for origin merge up to b701818 |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11562/) (Base Commit: cdf9282) (Image: devenv-rhel7_5384) |
Fixes #11622 as well as a minor bug when running the command without
--dry-run
cc @openshift/cli-review @Kargakis