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 builds/status and buildconfigs/status subresource #10061

Closed
wants to merge 2 commits into from

Conversation

csrwng
Copy link
Contributor

@csrwng csrwng commented Jul 27, 2016

Introduces 2 new subresources for builds and buildconfigs

  • builds/status
  • buildconfigs/status

For builds, any modifications to the build.Status struct should now be done through the builds/status subresource, with the exception of the build.Status.Cancelled flag. That flag can still be modified through the regular builds resource. Modifications to the build.Spec can only be done through the builds resource.

For buildConfigs, modifications to the buildconfig.Status struct are now only allowed through the buildconfigs/status subresource. Modifications to the buildconfig.Spec struct are only allowed through the buildconfigs resource with the exception of changes to the buildconfig.Spec.Triggers[x].ImageChange.LastImageID field. That field can be modified through the buildconfigs/status subresource.

The intent of these changes is to separate the use cases for regular updates vs status updates. In general, only the system (controllers, API server) should be allowed to change the status of an object. And only users should be allowed to change the Spec of the object. In the case of builds, a build should generally be immutable from a regular user's perspective. The exception to this is the cancel operation.

The build controller service account no longer needs to have create permission on the builds/source, builds/docker, builds/custom subresources because it only needs to do builds/status updates.

Fixes #6886

@csrwng
Copy link
Contributor Author

csrwng commented Jul 27, 2016

[test]

@csrwng
Copy link
Contributor Author

csrwng commented Jul 27, 2016

@bparees ptal

@csrwng
Copy link
Contributor Author

csrwng commented Jul 27, 2016

@openshift/api-review

func ValidateBuildStatusUpdate(build *buildapi.Build, older *buildapi.Build) field.ErrorList {
allErrs := field.ErrorList{}
// Ensure that the cancelled flag is not changed in a status update
if older.Status.Cancelled != build.Status.Cancelled {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we have a field in status that can't be changed by updating status?

Copy link
Contributor

Choose a reason for hiding this comment

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

because we have made bad choices in life.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shouldn't have been put in status in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cancelled is user input. It should be reflected into status, but they are two separate fields.

  1. Users set spec cancelled.
  2. Build controller reacts with status cancelled.

Not the same field.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, cancelled is one way.

@csrwng csrwng force-pushed the build_status_subresource branch from 5886133 to 0897179 Compare July 27, 2016 19:13

func validateBuildConfigTriggerStatusUpdate(trigger buildapi.BuildTriggerPolicy, older buildapi.BuildTriggerPolicy, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
if trigger.Type != older.Type {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use a deep reflection and exclude the fields you want to copy (see upstream for examples) instead of doing this. This is extremely fragile - we want a "whitelist" approach for "is this allowed to change, not blacklist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, fixed

@csrwng csrwng force-pushed the build_status_subresource branch from 0897179 to 77f9ee3 Compare July 27, 2016 23:38
@@ -117,12 +117,7 @@ func init() {
// BuildController.BuildUpdater (OSClientBuildClient)
{
Verbs: sets.NewString("update"),
Resources: sets.NewString("builds"),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can't do this here. Doing this will break old controllers running against new masters, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it will, I didn't know that was a thing :)
What's the use case ?

@csrwng csrwng force-pushed the build_status_subresource branch from 77f9ee3 to 61f1bbd Compare July 28, 2016 16:52
@csrwng
Copy link
Contributor Author

csrwng commented Jul 28, 2016

@deads2k updated policy and update strategies to allow the previous type of updates (and TODOs to get rid of them when appropriate)

@csrwng
Copy link
Contributor Author

csrwng commented Jul 28, 2016

flake #9775
[test]

@csrwng csrwng force-pushed the build_status_subresource branch from 61f1bbd to 0d40e06 Compare July 29, 2016 16:07
@csrwng
Copy link
Contributor Author

csrwng commented Jul 29, 2016

Added commit to move the Cancelled flag to the Build.Spec in the internal Build type based on @bparees suggestion.

@csrwng
Copy link
Contributor Author

csrwng commented Jul 29, 2016

[test]

@csrwng
Copy link
Contributor Author

csrwng commented Jul 29, 2016

flake #9775
[test]

@csrwng
Copy link
Contributor Author

csrwng commented Jul 29, 2016

@csrwng
Copy link
Contributor Author

csrwng commented Jul 29, 2016

[test]

@stevekuznetsov
Copy link
Contributor

@csrwng I guess this could have been clearer -- the job that failed that we were looking for was technically the super-job, not the integration sub-job. When the new feature gets rolled out again I'll send out a clearer e-mail.

@csrwng
Copy link
Contributor Author

csrwng commented Jul 30, 2016

Flake #10080
Flake #9959
[test]

@csrwng
Copy link
Contributor Author

csrwng commented Jul 30, 2016

flake #9959
[test]

@stevekuznetsov
Copy link
Contributor

re[test]

@@ -63,6 +36,12 @@ func (c OSClientBuildClient) Update(namespace string, build *buildapi.Build) err
return e
}

// Update updates build status using the OpenShift client.
Copy link
Contributor

Choose a reason for hiding this comment

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

UpdateStatus

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@csrwng csrwng force-pushed the build_status_subresource branch from 0d40e06 to f5dc258 Compare August 2, 2016 14:15
newBC.Spec = oldBC.Spec
// Allow changes to triggers for LastImageID. If anything else in triggers is
// changed, validation of the update will fail.
newBC.Spec.Triggers = newTriggers
Copy link
Contributor

Choose a reason for hiding this comment

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

This is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because we're keeping status inside the trigger spec (LastTriggeredImageID). I'm all in favor of moving it to the status field. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not backwards compatible unfortunately to change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't we do it via conversion? keep it in the same place in v1 and eventually expose it in the right place in v2?

@bparees
Copy link
Contributor

bparees commented Aug 2, 2016

this PR needs to be on @pweil- 's radar as it includes significant api changes and we still want it for 3.3 hopefully.

@csrwng csrwng force-pushed the build_status_subresource branch from f5dc258 to acffaff Compare August 2, 2016 20:47
@csrwng
Copy link
Contributor Author

csrwng commented Aug 2, 2016

@bparees fixed conversion, thx to @deads2k
I needed a // +genconversion=false comment on each field that should not be converted.

@csrwng
Copy link
Contributor Author

csrwng commented Aug 2, 2016

#9856
[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to acffaff

@openshift-bot
Copy link
Contributor

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

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 13, 2016
@smarterclayton
Copy link
Contributor

What's the status of this?

@csrwng
Copy link
Contributor Author

csrwng commented Oct 24, 2016

@smarterclayton the problem with this pull was that we wanted to convince ourselves that making a change like this would not introduce backward compatibility problems. I have since introduced extended tests for builds that test compatibility with a previous version -> #10707. Right now it's running build integration tests on the following combinations:
prev controller + prev api + current client
prev controller + current api + current client
current controller + current api + current client

At this point, I'm not sure if the existing set of tests is sufficient or we need more tests. However, I do think that doing this split of spec v. status is the right thing to do.

@smarterclayton
Copy link
Contributor

Ok, can discuss in 1.5.

On Mon, Oct 24, 2016 at 9:43 AM, Cesar Wong [email protected]
wrote:

@smarterclayton https://github.com/smarterclayton the problem with this
pull was that we wanted to convince ourselves that making a change like
this would not introduce backward compatibility problems. I have since
introduced extended tests for builds that test compatibility with a
previous version -> #10707
#10707. Right now it's running
build integration tests on the following combinations:
prev controller + prev api + current client
prev controller + current api + current client
current controller + current api + current client

At this point, I'm not sure if the existing set of tests is sufficient or
we need more tests. However, I do think that doing this split of spec v.
status is the right thing to do.


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

@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 1, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 11, 2016
@smarterclayton
Copy link
Contributor

Still has outstanding questions.

@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 2, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 15, 2016
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2017
@openshift-bot
Copy link
Contributor

Origin Action Required: Pull request cannot be automatically merged, please rebase your branch from latest HEAD and push again

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 27, 2017
@csrwng
Copy link
Contributor Author

csrwng commented Feb 6, 2017

Closing for now. Will revisit in the next API revision.
Trello: https://trello.com/c/2vkORAHW/1139-add-a-status-sub-resource-to-builds-and-buildconfigs-builds

@csrwng csrwng closed this Feb 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-api-review needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants