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

We should need an event return #374

Closed
jjmengze opened this issue Mar 27, 2019 · 6 comments
Closed

We should need an event return #374

jjmengze opened this issue Mar 27, 2019 · 6 comments

Comments

@jjmengze
Copy link

Question

What did you do?

We can get the return of the event etc Create,Delete ...

What did you expect to see?

If we design an action here, we can know the state of the current resource.

type Request struct {
	// NamespacedName is the name and namespace of the object to reconcile.
	types.NamespacedName
}

What did you see instead? Under which circumstances?
By passing the action through the handler, the user can know the current resource situation.

// Create is called in response to an create event - e.g. Pod Creation.
func (h *NetHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) {
	if evt.Meta == nil {
		fmt.Printf("evt.Meta == nil")
		return
	}

	q.Add(reconcile.Request{NamespacedName: types.NamespacedName{
		Name:      evt.Meta.GetName(),
		Namespace: evt.Meta.GetNamespace(),
		Action:    Create,
	}})
}
@j900155
Copy link

j900155 commented Mar 28, 2019

I have the same problem, @mengzn do you want to implement it?

@shawn-hurley
Copy link

Could you explain the use case and how you would use this field in your reconciler?

@jjmengze
Copy link
Author

jjmengze commented Apr 2, 2019

@shawn-hurley
It's still useful if the operator knows that an object has been deleted or modified!
The operator can handle his related business logic.

@shawn-hurley
Copy link

To handle the deletion, I believe that you should be using a finalizer.

Can you explain how you intend to use the modified data?

@jjmengze
Copy link
Author

jjmengze commented Apr 3, 2019

I think that it is not just a deletion.
If the operator can know the correction status of the object in the business. Help external operators understand changes in objects

@DirectXMan12
Copy link
Contributor

You should never be writing reconcilers that differentiate between the different operations. That's bound to get you into trouble. Instead, each reconcile, you should check to see if the state of the world is different from what you expect, and act accordingly. It shouldn't matter if the object was just created or has been updated, what matters is that the state of the world conforms to what's specified in the object.

This request is explicitly against the design principles of controller-runtime, so I'm going to close it now. If I'm misunderstanding you, please let me know, and I'll re-open the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants