Coder Social home page Coder Social logo

Comments (14)

zhangtbj avatar zhangtbj commented on August 18, 2024 1

I will work on this feature now.

from build.

zhangtbj avatar zhangtbj commented on August 18, 2024

Hi @sbose78 ,

I did some investigations today. I think there are two ways to add the ownerreference for the new created buildRun.

1. Use mutating admission webhook.
But I think, we just need to add ownerreference for buildRun, add a new wekhook deployment and build process just for this ONE ownerreference requirement is too HEAVY now

2, Set the ownerreference in buildRun controller first.
When a new buildRun is created, buildRun controller notice that and add the ownerreference at the beginning of controller reconcile logic.
Such as add:

  ownerReferences:
  - apiVersion: build.dev/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: Build
    name: buildpack-nodejs-build
    uid: 9b197859-7bdf-4d58-ac47-f7aea2564bbd

to this buildRun. And I have checked, the generation won't be increased if I add this ownerreference. So we can add it safely in the controller logic and update the ownerreference in the buildRun controller logic.

I prefer to use the second way because it is easy and less dependencies.
But I don't know what we plan to implement in the issue Validate the Build on creation (#83)

Will we introduce the validating webhook to do that? (Also FYI @qu1queee )

If yes, we can also introduce the mutating webhook for the ownerreference together.

If we don't plan to use webhook for validation too. I think we can use option 2.

Any idea, all?

Thanks!

from build.

sbose78 avatar sbose78 commented on August 18, 2024

Stay away from webhooks as much as possible ;)
So, yes, the second one is better.

from build.

zhangtbj avatar zhangtbj commented on August 18, 2024

Agree. Let me try the second way first. :)

from build.

sbose78 avatar sbose78 commented on August 18, 2024

I have a design question though. If I delete the build configuration and all buildruns also get removed, would that lead to loss of trace-ability of complete|successful|failed builds ?

from build.

zhangtbj avatar zhangtbj commented on August 18, 2024

How do you do in the build v1?

If the end-user deletes the BuildConfig, will you also delete the related Builds in build v1 now?

Will those buildRuns to be the orphan resources if we don't delete them together?

from build.

sbose78 avatar sbose78 commented on August 18, 2024

Yes, in Build v1, they were ownerRef'd. Yeah, they will be orphan resources for sure - but I'm wondering if there's a good reason for having them stick around 🤔.

( you can go ahead with the changes - I was thinking out aloud..)

from build.

zhangtbj avatar zhangtbj commented on August 18, 2024

em..... I just had a try on OpenShift v4.x.

Interesting, there is a dialog pop up when you want to delete a BuildConfig:

Delete Build Config
Delete dotnet?

Are you sure you want to delete dotnet in namespace default?
[x] Delete dependent objects of this resource
  • If you choose Delete dependent objects of this resource, the Builds will be deleted together.
  • If you don't choose Delete dependent objects of this resource, the Builds will be kept

So..... should we add the logic in Build controller?

  • If there is any parameter (like a new annotation) from UX to ask to delete dependencies, then query all related resources and delete them?

from build.

sbose78 avatar sbose78 commented on August 18, 2024

Yeah, the annotation path looks good. Maybe we label the buildRuns in a way that they are easy to look up?

from build.

zhangtbj avatar zhangtbj commented on August 18, 2024
  • Add annotation path and delete logic in Build controller
  • Add label for buildRuns in buildRun controller reconcile at the beginning if it doesn't exist

How about this way? :)

from build.

sbose78 avatar sbose78 commented on August 18, 2024

Add annotation path and delete logic in Build controller

While handling deletion, check if there's an annotation that says "don't delete BuildRuns. If present, then skip deletion of BuildRuns.

Add label for buildRuns in buildRun controller reconcile at the beginning if it doesn't exist

Helps us query, yes.

Is that what you had in mind?

from build.

zhangtbj avatar zhangtbj commented on August 18, 2024

yes, that is my point.

from build.

sbose78 avatar sbose78 commented on August 18, 2024

Sounds good, Jordan!

from build.

qu1queee avatar qu1queee commented on August 18, 2024

this is done , closing

from build.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.