Skip to content

Commit

Permalink
stop synchronizing resources list if any kustomization folder fails (#…
Browse files Browse the repository at this point in the history
…375)

Signed-off-by: Xiangjing Li <xiangli@redhat.com>
  • Loading branch information
xiangjingli authored Oct 27, 2023
1 parent c33c61f commit dcce8c6
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/subscriber/git/git_subscriber_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,12 @@ func (ghsi *SubscriberItem) doSubscription() error {
ghsi.successful = false

errMsg += err.Error()

metrics.LocalDeploymentFailedPullTime.
WithLabelValues(ghsi.SubscriberItem.Subscription.Namespace, ghsi.SubscriberItem.Subscription.Name).
Observe(0)

return errors.New("kustomization failed, stop synchronizing. err: " + errMsg)
}

klog.Info("Applying helm charts..")
Expand Down Expand Up @@ -437,7 +443,13 @@ func (ghsi *SubscriberItem) subscribeKustomizations() error {
out, err := utils.RunKustomizeBuild(kustomizeDir)

if err != nil {
klog.Error("Failed to apply kustomization, error: ", err.Error())
klog.Error("Failed to apply kustomization, clean up all resources that will deploy. error: ", err.Error())

// If applying one kustomize folder fails after some other kustomize folder success, clean up the memory git resource list for stopping synchronizer.
// Or only successfully kustomized resources are deployed,
// that will trigger synchronizer to delete those resources that haven't been kustomized but deployed previously
ghsi.resources = []kubesynchronizer.ResourceUnit{}

return err
}

Expand Down

0 comments on commit dcce8c6

Please sign in to comment.