Skip to content

Commit

Permalink
update desired obj after apply
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhachyan committed Dec 15, 2023
1 parent b3d753d commit 0dd725b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 0 additions & 6 deletions pkg/config/configcheck/configcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,6 @@ func (cc *ConfigCheck) Run(ctx context.Context) (string, error) {
return "", err
}

vectorConfigCheckSecret, err = k8s.GetSecret(ctx, types.NamespacedName{Namespace: cc.Namespace, Name: vectorConfigCheckSecret.Name}, cc.Client)

if err != nil {
return "", err
}

// Set OwnerReference to pod
if err = controllerutil.SetOwnerReference(vectorConfigCheckSecret, vectorConfigCheckPod, cc.Client.Scheme()); err != nil {
return "", err
Expand Down
10 changes: 10 additions & 0 deletions pkg/utils/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func createOrUpdateDeployment(ctx context.Context, desired *appsv1.Deployment, c
if err != nil {
return fmt.Errorf("failed to create or update Deployment: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -96,6 +97,7 @@ func createOrUpdateStatefulSet(ctx context.Context, desired *appsv1.StatefulSet,
if err != nil {
return fmt.Errorf("failed to create or update StatefulSet: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -110,6 +112,7 @@ func createOrUpdateDaemonSet(ctx context.Context, desired *appsv1.DaemonSet, c c
if err != nil {
return fmt.Errorf("failed to create or update Daemonset: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -124,6 +127,7 @@ func createOrUpdateSecret(ctx context.Context, desired *corev1.Secret, c client.
if err != nil {
return fmt.Errorf("failed to create or update Secret: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -138,6 +142,7 @@ func createOrUpdateService(ctx context.Context, desired *corev1.Service, c clien
if err != nil {
return fmt.Errorf("failed to create or update Deployment: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -151,6 +156,7 @@ func createOrUpdateServiceAccount(ctx context.Context, desired *corev1.ServiceAc
if err != nil {
return fmt.Errorf("failed to create or update ServiceAccount: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -165,6 +171,7 @@ func createOrUpdateClusterRole(ctx context.Context, desired *rbacv1.ClusterRole,
if err != nil {
return fmt.Errorf("failed to create or update ClusterRole: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -180,6 +187,7 @@ func createOrUpdateClusterRoleBinding(ctx context.Context, desired *rbacv1.Clust
if err != nil {
return fmt.Errorf("failed to create or update ClusterRoleBinding: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -194,6 +202,7 @@ func createOrUpdatePodMonitor(ctx context.Context, desired *monitorv1.PodMonitor
if err != nil {
return fmt.Errorf("failed to create or update PodMonitor: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand All @@ -208,6 +217,7 @@ func createOrUpdatePodSrape(ctx context.Context, desired *victoriametricsv1beta1
if err != nil {
return fmt.Errorf("failed to create or update VMPodScrape: %w", err)
}
existing.DeepCopyInto(desired)
return nil
}

Expand Down

0 comments on commit 0dd725b

Please sign in to comment.