Do not try to reconcile a suspended object
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
@@ -64,13 +64,17 @@ func reconcileAlertCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating Alert %s in %s namespace", name, namespace)
|
|
||||||
var alert notificationv1.Alert
|
var alert notificationv1.Alert
|
||||||
err = kubeClient.Get(ctx, namespacedName, &alert)
|
err = kubeClient.Get(ctx, namespacedName, &alert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if alert.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating Alert %s in %s namespace", name, namespace)
|
||||||
if alert.Annotations == nil {
|
if alert.Annotations == nil {
|
||||||
alert.Annotations = map[string]string{
|
alert.Annotations = map[string]string{
|
||||||
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
@@ -78,6 +82,7 @@ func reconcileAlertCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
} else {
|
} else {
|
||||||
alert.Annotations[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
alert.Annotations[meta.ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := kubeClient.Update(ctx, &alert); err != nil {
|
if err := kubeClient.Update(ctx, &alert); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ func reconcileHrCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if helmRelease.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
if syncHrWithSource {
|
if syncHrWithSource {
|
||||||
switch helmRelease.Spec.Chart.Spec.SourceRef.Kind {
|
switch helmRelease.Spec.Chart.Spec.SourceRef.Kind {
|
||||||
case sourcev1.HelmRepositoryKind:
|
case sourcev1.HelmRepositoryKind:
|
||||||
|
|||||||
@@ -84,6 +84,10 @@ func reconcileKsCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if kustomization.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
if syncKsWithSource {
|
if syncKsWithSource {
|
||||||
switch kustomization.Spec.SourceRef.Kind {
|
switch kustomization.Spec.SourceRef.Kind {
|
||||||
case sourcev1.GitRepositoryKind:
|
case sourcev1.GitRepositoryKind:
|
||||||
|
|||||||
@@ -64,13 +64,17 @@ func reconcileReceiverCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating Receiver %s in %s namespace", name, namespace)
|
|
||||||
var receiver notificationv1.Receiver
|
var receiver notificationv1.Receiver
|
||||||
err = kubeClient.Get(ctx, namespacedName, &receiver)
|
err = kubeClient.Get(ctx, namespacedName, &receiver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if receiver.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Actionf("annotating Receiver %s in %s namespace", name, namespace)
|
||||||
if receiver.Annotations == nil {
|
if receiver.Annotations == nil {
|
||||||
receiver.Annotations = map[string]string{
|
receiver.Annotations = map[string]string{
|
||||||
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
meta.ReconcileAtAnnotation: time.Now().Format(time.RFC3339Nano),
|
||||||
|
|||||||
@@ -74,6 +74,10 @@ func reconcileSourceBucketCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if bucket.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
lastHandledReconcileAt := bucket.Status.LastHandledReconcileAt
|
lastHandledReconcileAt := bucket.Status.LastHandledReconcileAt
|
||||||
logger.Actionf("annotating Bucket source %s in %s namespace", name, namespace)
|
logger.Actionf("annotating Bucket source %s in %s namespace", name, namespace)
|
||||||
if err := requestBucketReconciliation(ctx, kubeClient, namespacedName, &bucket); err != nil {
|
if err := requestBucketReconciliation(ctx, kubeClient, namespacedName, &bucket); err != nil {
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ func reconcileSourceGitCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if repository.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating GitRepository source %s in %s namespace", name, namespace)
|
logger.Actionf("annotating GitRepository source %s in %s namespace", name, namespace)
|
||||||
if err := requestGitRepositoryReconciliation(ctx, kubeClient, namespacedName, &repository); err != nil {
|
if err := requestGitRepositoryReconciliation(ctx, kubeClient, namespacedName, &repository); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ func reconcileSourceHelmCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if repository.Spec.Suspend {
|
||||||
|
return fmt.Errorf("resource is suspended")
|
||||||
|
}
|
||||||
|
|
||||||
logger.Actionf("annotating HelmRepository source %s in %s namespace", name, namespace)
|
logger.Actionf("annotating HelmRepository source %s in %s namespace", name, namespace)
|
||||||
if err := requestHelmRepositoryReconciliation(ctx, kubeClient, namespacedName, &repository); err != nil {
|
if err := requestHelmRepositoryReconciliation(ctx, kubeClient, namespacedName, &repository); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user