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 3 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
9 changes: 5 additions & 4 deletions cmd/sriov-network-operator-config-cleanup/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ func newConfigController() *configController {
platformHelper.EXPECT().IsHypershift().Return(false).AnyTimes()

err = (&controllers.SriovOperatorConfigReconciler{
Client: k8sManager.GetClient(),
Scheme: k8sManager.GetScheme(),
PlatformHelper: platformHelper,
FeatureGate: featuregate.New(),
Client: k8sManager.GetClient(),
Scheme: k8sManager.GetScheme(),
PlatformHelper: platformHelper,
FeatureGate: featuregate.New(),
UncachedAPIReader: k8sManager.GetAPIReader(),
}).SetupWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

Expand Down
10 changes: 6 additions & 4 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ import (
// SriovOperatorConfigReconciler reconciles a SriovOperatorConfig object
type SriovOperatorConfigReconciler struct {
client.Client
Scheme *runtime.Scheme
PlatformHelper platforms.Interface
FeatureGate featuregate.FeatureGate
Scheme *runtime.Scheme
PlatformHelper platforms.Interface
FeatureGate featuregate.FeatureGate
UncachedAPIReader client.Reader
}

//+kubebuilder:rbac:groups=sriovnetwork.openshift.io,resources=sriovoperatorconfigs,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -413,7 +414,8 @@ 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)
// use uncached api reader to get machineconfig to reduce memory footprint
err := r.UncachedAPIReader.Get(context.TODO(), types.NamespacedName{Name: consts.SystemdServiceOcpMachineConfigName}, obj)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not to use ctx that is passed to syncOpenShiftSystemdService as arg?

Copy link
Author

Choose a reason for hiding this comment

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

Not sure why ctx wasn't used as a arg before, so no modifications have been made here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @crliu3227 please lets use the context from the function probably it was missed in the review process :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

also dont we need to disable cache for MachineConfig in mgr (under main) ?

Copy link
Author

Choose a reason for hiding this comment

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

Hi @crliu3227 please lets use the context from the function probably it was missed in the review process :)

Ok

Copy link
Author

Choose a reason for hiding this comment

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

also dont we need to disable cache for MachineConfig in mgr (under main) ?

SriovNetworkPoolConfigReconciler will reconiler hardware offload MachineConfig, disable cache for MachineConfig might not be very appropriate, so add a label to MachineConfigs interested by sriov-network-operator ?

if err != nil {
if apierrors.IsNotFound(err) {
return nil
Expand Down
9 changes: 5 additions & 4 deletions controllers/sriovoperatorconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ var _ = Describe("SriovOperatorConfig controller", Ordered, func() {
platformHelper.EXPECT().IsHypershift().Return(false).AnyTimes()

err = (&SriovOperatorConfigReconciler{
Client: k8sManager.GetClient(),
Scheme: k8sManager.GetScheme(),
PlatformHelper: platformHelper,
FeatureGate: featuregate.New(),
Client: k8sManager.GetClient(),
Scheme: k8sManager.GetScheme(),
PlatformHelper: platformHelper,
FeatureGate: featuregate.New(),
UncachedAPIReader: k8sManager.GetAPIReader(),
}).SetupWithManager(k8sManager)
Expect(err).ToNot(HaveOccurred())

Expand Down
9 changes: 5 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,11 @@ func main() {
os.Exit(1)
}
if err = (&controllers.SriovOperatorConfigReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
PlatformHelper: platformsHelper,
FeatureGate: featureGate,
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
PlatformHelper: platformsHelper,
FeatureGate: featureGate,
UncachedAPIReader: mgr.GetAPIReader(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "SriovOperatorConfig")
os.Exit(1)
Expand Down
Loading