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

Set webhook failurePolicy to Ignore on controller pod shutdown #177

Merged
merged 1 commit into from
Sep 6, 2021
Merged

Set webhook failurePolicy to Ignore on controller pod shutdown #177

merged 1 commit into from
Sep 6, 2021

Conversation

mmirecki
Copy link
Contributor

This PR sets the failurePolicy of sriov webhooks to Ignore when an operator pod is exiting. This ensures that the policy does not cause incoming resources to fail when the sriov pods are down. The policy is changed to back to Fail on the next sriovconfig reconciliation loop (for example when the controller pod is started again).

The PR also changes the kubernetes API used in the shutdown function from the controller-runtime api to the basic client-go api.
This is due issues with the controller api during the controller shutdown. It was noticed that the api calls sometimes failed due to Informer not able to sync, probably caused by the manager being closed before the shutdown function was invoked.


func Shutdown() {
updateFinalizers()
//updateWebhooks()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall it be commented out?

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

shutdownLog.Info("Clearing finalizers on exit")
networkList := &sriovnetworkv1.SriovNetworkList{}
err := c.List(context.TODO(), networkList)
c, err := dynamic.NewForConfig(getConfig())
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 use the GetConfigOrDie from "sigs.k8s.io/controller-runtime/pkg/client/config" instead getConfig()? So that we can support running the operator in both in-cluster and local mode. The local mode is quite handy for development.

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 {
shutdownLog.Error(err, "Error creating client")
}
sriovNetworkClient := c.Resource(sriovnetworksGVR)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a go-client implementation under package/client for the SriovNetwork CRDs, I think we can use it here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this tip
Done

if err != nil {
shutdownLog.Error(err, "Error getting client")
}
validatingWebhookClient := clientset.AdmissionregistrationV1().ValidatingWebhookConfigurations()
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 also create a updateValidatingWebhooks function as the updateMutatingWebhooks function bellow?

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

shutdownLog.Info("Clearing finalizers on exit")
networkList := &sriovnetworkv1.SriovNetworkList{}
err := c.List(context.TODO(), networkList)
//c2, err := dynamic.NewForConfig(conf.GetConfigOrDie())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall this line be removed?

Copy link
Contributor Author

@mmirecki mmirecki Aug 24, 2021

Choose a reason for hiding this comment

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

removed, sorry for that one

@pliurh pliurh merged commit 26af04e into k8snetworkplumbingwg:master Sep 6, 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.

2 participants