Skip to content

Commit

Permalink
fix: use non-caching client to get pod in getPodPrivateIP also in E…
Browse files Browse the repository at this point in the history
…IP controller (#22)
  • Loading branch information
alfredkrohmer authored Aug 19, 2024
1 parent 8c10c8c commit 9db1162
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions controllers/eip_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ import (
// EIPReconciler reconciles a EIP object
type EIPReconciler struct {
client.Client
Log logr.Logger
EC2 *ec2.EC2
NonCachingClient client.Client
Log logr.Logger
EC2 *ec2.EC2
}

// +kubebuilder:rbac:groups=aws.k8s.logmein.com,resources=eips,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -270,7 +271,7 @@ func (r *EIPReconciler) releaseEIP(ctx context.Context, eip *awsv1alpha1.EIP, lo

func (r *EIPReconciler) getPodPrivateIP(ctx context.Context, namespace, podName string) (string, error) {
pod := &corev1.Pod{}
if err := r.Client.Get(ctx, client.ObjectKey{
if err := r.NonCachingClient.Get(ctx, client.ObjectKey{
Namespace: namespace,
Name: podName,
}, pod); err != nil {
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ func main() {
}

err = (&controllers.EIPReconciler{
Client: cachingClient,
Log: ctrl.Log.WithName("controllers").WithName("EIP"),
EC2: ec2,
Client: cachingClient,
NonCachingClient: nonCachingClient,
Log: ctrl.Log.WithName("controllers").WithName("EIP"),
EC2: ec2,
}).SetupWithManager(mgr)
if err != nil {
setupLog.Error(err, "unable to create controller", "controller", "EIP")
Expand Down

0 comments on commit 9db1162

Please sign in to comment.