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

use kubeclient to get and delete machineconfig #848

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/sriov-network-operator-config-cleanup/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func newConfigController() *configController {
Scheme: k8sManager.GetScheme(),
PlatformHelper: platformHelper,
FeatureGate: featuregate.New(),
KubeClient: k8sClient,
}).SetupWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

Expand Down
5 changes: 3 additions & 2 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type SriovOperatorConfigReconciler struct {
Scheme *runtime.Scheme
PlatformHelper platforms.Interface
FeatureGate featuregate.FeatureGate
KubeClient client.Client
Copy link
Member

Choose a reason for hiding this comment

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

Can we be more specific and use mgr.GetAPIReader(). It would be clearer if anyone else needs to do operations avoiding the cache,

Suggested change
KubeClient client.Client
uncachedAPIReader client.Reader

Copy link
Author

Choose a reason for hiding this comment

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

OK, I will modify this part and resubmit the PR again

}

//+kubebuilder:rbac:groups=sriovnetwork.openshift.io,resources=sriovoperatorconfigs,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -413,7 +414,7 @@ func (r *SriovOperatorConfigReconciler) syncOpenShiftSystemdService(ctx context.

if cr.Spec.ConfigurationMode != sriovnetworkv1.SystemdConfigurationMode {
obj := &machinev1.MachineConfig{}
err := r.Get(context.TODO(), types.NamespacedName{Name: consts.SystemdServiceOcpMachineConfigName}, obj)
err := r.KubeClient.Get(context.TODO(), types.NamespacedName{Name: consts.SystemdServiceOcpMachineConfigName}, obj)
if err != nil {
if apierrors.IsNotFound(err) {
return nil
Expand All @@ -424,7 +425,7 @@ func (r *SriovOperatorConfigReconciler) syncOpenShiftSystemdService(ctx context.
}

logger.Info("Systemd service was deployed but the operator is now operating on daemonset mode, removing the machine config")
err = r.Delete(context.TODO(), obj)
err = r.KubeClient.Delete(context.TODO(), obj)
if err != nil {
logger.Error(err, "failed to remove the systemd service machine config")
return err
Expand Down
1 change: 1 addition & 0 deletions controllers/sriovoperatorconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var _ = Describe("SriovOperatorConfig controller", Ordered, func() {
Scheme: k8sManager.GetScheme(),
PlatformHelper: platformHelper,
FeatureGate: featuregate.New(),
KubeClient: k8sClient,
}).SetupWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func main() {
Scheme: mgr.GetScheme(),
PlatformHelper: platformsHelper,
FeatureGate: featureGate,
KubeClient: kubeClient,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "SriovOperatorConfig")
os.Exit(1)
Expand Down
Loading