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

Remove SriovNetwork finalizers on controller shutdown #174

Merged
merged 1 commit into from
Aug 19, 2021
Merged

Remove SriovNetwork finalizers on controller shutdown #174

merged 1 commit into from
Aug 19, 2021

Conversation

mmirecki
Copy link
Contributor

@mmirecki mmirecki commented Aug 6, 2021

The PR is added in response to customer complaints about SriovNetworks being stuck as terminating after uninstalling the sriov operator.
This PR removes the "netattdef.finalizers.sriovnetwork.openshift.io" finalizer from SriovNetworks when the sriovnetwork controller is deleted. This finalizer is added to each SriovNetwork on reconciliation, but it is not removed when the operator is uninstalled, leaving SriovNetworks with finalizers and the SriovNetwork crd hanging in the terminating state forever.
The finalizers will be removed whenever the sriov operator pod is shut down, including pod restarts. The removed finalizer will be added when the pod restarts and the networks are reconciled.

@pliurh
Copy link
Collaborator

pliurh commented Aug 10, 2021

We also use a similar finalizer mechanism for the SriovNetworkPoolConfig. So maybe we should do the same for the SriovNetworkPoolConfig CRs.

main.go Outdated
@@ -178,6 +179,8 @@ func main() {
setupLog.Error(err, "problem running manager")
os.Exit(1)
}
// Remove all finalizers after controller is shut down
utils.Shutdown(mgr.GetClient())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we move this function before the main loop and use defer call instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done
Adding defer before we start the manager

@pliurh pliurh requested a review from zshi-redhat August 10, 2021 06:35
Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

just a small comment

Comment on lines 4 to 7
"context"

"github.com/golang/glog"
sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: just change the order to be

"context"

"github.com/golang/glog"
"sigs.k8s.io/controller-runtime/pkg/client"

sriovnetworkv1 "github.com/k8snetworkplumbingwg/sriov-network-operator/api/v1"
	

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

if err != nil {
glog.Errorf("Failed to list SriovNetworks: %+v", err)
} else {
for _, instance := range networkList.Items {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you need first to check if there is a networkAttachmentDefinition and remove it first

Copy link
Contributor Author

@mmirecki mmirecki Aug 12, 2021

Choose a reason for hiding this comment

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

Note that we are not deleting the SriovNetworks here.
All we do in this PR is to remove the sriovoperator related finalizer, saying "sriov operator not does not hold a grudge when you delete this", so this change would be outside the scope of this PR.

)

func Shutdown(c client.Client) {
networkList := &sriovnetworkv1.SriovNetworkList{}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add some log messages here?
This patch overall looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added logging.
Note that the log messages might be hard to see, as the pod will be removed right after this is executed.

@pliurh pliurh merged commit f635fb9 into k8snetworkplumbingwg:master Aug 19, 2021
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

Successfully merging this pull request may close these issues.

3 participants