Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 9 additions & 6 deletions controllers/classifier_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,12 @@ func (r *ClassifierReconciler) processClassifier(ctx context.Context, classifier
clusterInfo := &libsveltosv1beta1.ClusterInfo{
Cluster: *cluster,
Hash: currentHash,
FailureMessage: nil,
FailureMessage: stringPtr(""),
Status: libsveltosv1beta1.SveltosStatusProvisioning,
}

proceed, err := r.canProceed(ctx, classifierScope, cluster, logger)
var proceed bool
proceed, err = r.canProceed(ctx, classifierScope, cluster, logger)
if err != nil {
failureMessage := err.Error()
clusterInfo.FailureMessage = &failureMessage
Expand All @@ -999,8 +1000,10 @@ func (r *ClassifierReconciler) processClassifier(ctx context.Context, classifier
if r.Deployer.IsInProgress(cluster.Namespace, cluster.Name, classifier.Name, f.id,
clusterproxy.GetClusterType(cluster), true) {

logger.V(logs.LogDebug).Info("cleanup is in progress")
return nil, fmt.Errorf("cleanup of %s in cluster still in progress. Wait before redeploying", f.id)
msg := "cleanup is in progress"
clusterInfo.FailureMessage = &msg
logger.V(logs.LogDebug).Info(msg)
return clusterInfo, fmt.Errorf("cleanup of %s in cluster still in progress. Wait before redeploying", f.id)
}

// Get the Classifier hash when Classifier was last deployed in this cluster (if ever)
Expand Down Expand Up @@ -1073,7 +1076,7 @@ func (r *ClassifierReconciler) proceedProcessingClassifier(ctx context.Context,
} else if isConfigSame && currentStatus != nil && *currentStatus == libsveltosv1beta1.SveltosStatusProvisioned {
logger.V(logs.LogDebug).Info("already deployed")
clusterInfo.Status = libsveltosv1beta1.SveltosStatusProvisioned
clusterInfo.FailureMessage = nil
clusterInfo.FailureMessage = stringPtr("")
} else {
logger.V(logs.LogDebug).Info("no result is available. queue job and mark status as provisioning")
clusterInfo.Status = libsveltosv1beta1.SveltosStatusProvisioning
Expand Down Expand Up @@ -1116,7 +1119,7 @@ func (r *ClassifierReconciler) proceedDeployingClassifierInPullMode(ctx context.
clusterInfo := &libsveltosv1beta1.ClusterInfo{
Cluster: *cluster,
Hash: currentHash,
FailureMessage: nil,
FailureMessage: stringPtr(""),
Status: libsveltosv1beta1.SveltosStatusProvisioning,
}

Expand Down
20 changes: 14 additions & 6 deletions controllers/classifier_report_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func collectClassifierReports(c client.Client, shardKey, capiOnboardAnnotation,
if err != nil {
l.V(logs.LogInfo).Info(fmt.Sprintf("failed to collect ClassifierReports from cluster: %s/%s %v",
cluster.Namespace, cluster.Name, err))
continue
}
}

Expand Down Expand Up @@ -247,7 +248,6 @@ func collectClassifierReportsFromCluster(ctx context.Context, c client.Client,
if err != nil {
return err
}

if isPullMode {
return nil
}
Expand Down Expand Up @@ -292,17 +292,25 @@ func collectClassifierReportsFromCluster(ctx context.Context, c client.Client,

for i := range classifierReportList.Items {
cr := &classifierReportList.Items[i]
if !cr.DeletionTimestamp.IsZero() {
// ignore deleted ClassifierReport
continue
}

if shouldIgnore(cr, isPullMode) {
continue
}

l := logger.WithValues("classifierReport", cr.Name)

if !cr.DeletionTimestamp.IsZero() {
l.V(logs.LogDebug).Info("deleting from management cluster")
if err != nil {
logger.V(logs.LogInfo).Error(err, "failed to delete ClassifierReport in management cluster")
continue
}
}

err = updateClassifierReport(ctx, c, cluster, cr, l)
if err != nil {
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to process ClassifierReport. Err: %v", err))
l.V(logs.LogInfo).Error(err, "failed to update EventReport in management cluster")
continue
}
}

Expand Down