diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index df35bbb7..531f5cd9 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -6,7 +6,7 @@ on: - 'main' - 'dev' pull_request: - types: opened + types: [opened, edited, reopened] jobs: diff --git a/Makefile b/Makefile index f4c74b37..43a3946f 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ ARCH ?= amd64 OS ?= $(shell uname -s | tr A-Z a-z) K8S_LATEST_VER ?= $(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) export CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME) -TAG ?= v0.9.0 +TAG ?= v0.9.1 # Get cluster-api version and build ldflags clusterapi := $(shell go list -m sigs.k8s.io/cluster-api) diff --git a/config/default/manager_image_patch.yaml b/config/default/manager_image_patch.yaml index 23d81c7b..44753c0b 100644 --- a/config/default/manager_image_patch.yaml +++ b/config/default/manager_image_patch.yaml @@ -8,5 +8,5 @@ spec: spec: containers: # Change the value of image field below to your controller image URL - - image: projectsveltos/addon-manager-amd64:v0.9.0 + - image: projectsveltos/addon-manager-amd64:v0.9.1 name: manager diff --git a/controllers/clustersummary_controller.go b/controllers/clustersummary_controller.go index fdc147ac..e6a91a62 100644 --- a/controllers/clustersummary_controller.go +++ b/controllers/clustersummary_controller.go @@ -211,7 +211,7 @@ func (r *ClusterSummaryReconciler) reconcileDelete( err = r.removeResourceSummary(ctx, clusterSummaryScope, logger) if err != nil { - logger.V(logs.LogInfo).Info("failed to remove ResourceSummary.") + logger.V(logs.LogInfo).Error(err, "failed to remove ResourceSummary.") return reconcile.Result{Requeue: true, RequeueAfter: deleteRequeueAfter}, nil } diff --git a/controllers/handlers_resources.go b/controllers/handlers_resources.go index 9427341a..0ab4a870 100644 --- a/controllers/handlers_resources.go +++ b/controllers/handlers_resources.go @@ -72,16 +72,17 @@ func deployResources(ctx context.Context, c client.Client, var remoteResourceReports []configv1alpha1.ResourceReport localResourceReports, remoteResourceReports, err = deployReferencedObjects(ctx, c, remoteRestConfig, clusterSummary, featureHandler, logger) - if err != nil { - return err - } - clusterProfileOwnerRef, err := configv1alpha1.GetClusterProfileOwnerReference(clusterSummary) + // Irrespective of error, update deployed gvks. Otherwise cleanup won't happen in case + gvkErr := updateDeployedGroupVersionKind(ctx, clusterSummary, localResourceReports, remoteResourceReports, logger) if err != nil { return err } + if gvkErr != nil { + return gvkErr + } - err = updateDeployedGroupVersionKind(ctx, clusterSummary, localResourceReports, remoteResourceReports, logger) + clusterProfileOwnerRef, err := configv1alpha1.GetClusterProfileOwnerReference(clusterSummary) if err != nil { return err } diff --git a/controllers/handlers_utils.go b/controllers/handlers_utils.go index 1ff92d95..21a91ef0 100644 --- a/controllers/handlers_utils.go +++ b/controllers/handlers_utils.go @@ -478,22 +478,21 @@ func deployReferencedObjects(ctx context.Context, c client.Client, remoteConfig localConfig.Impersonate = rest.ImpersonationConfig{ UserName: fmt.Sprintf("system:serviceaccount:%s:%s", adminNamespace, adminName), } - logger.Info("MGIANLUC") } tmpResourceReports, err = deployObjects(ctx, c, localConfig, objectsToDeployLocally, clusterSummary, mgtmResources, logger) + localReports = append(localReports, tmpResourceReports...) if err != nil { - return nil, nil, err + return localReports, nil, err } - localReports = append(localReports, tmpResourceReports...) // Deploy all resources that need to be deployed in the managed cluster tmpResourceReports, err = deployObjects(ctx, remoteClient, remoteConfig, objectsToDeployRemotely, clusterSummary, mgtmResources, logger) + remoteReports = append(remoteReports, tmpResourceReports...) if err != nil { - return nil, nil, err + return localReports, remoteReports, err } - remoteReports = append(remoteReports, tmpResourceReports...) return localReports, remoteReports, nil } diff --git a/controllers/template_instantiation.go b/controllers/template_instantiation.go index c70dd32e..315d1506 100644 --- a/controllers/template_instantiation.go +++ b/controllers/template_instantiation.go @@ -173,7 +173,7 @@ func instantiateTemplateValues(ctx context.Context, config *rest.Config, c clien } templateName := getTemplateName(clusterNamespace, clusterName, requestorName) - tmpl, err := template.New(templateName).Funcs(sprig.FuncMap()).Parse(values) + tmpl, err := template.New(templateName).Option("missingkey=error").Funcs(sprig.FuncMap()).Parse(values) if err != nil { return "", err } diff --git a/go.mod b/go.mod index 04259f37..492c1428 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/onsi/ginkgo/v2 v2.9.2 github.com/onsi/gomega v1.27.5 github.com/pkg/errors v0.9.1 - github.com/projectsveltos/libsveltos v0.9.0 + github.com/projectsveltos/libsveltos v0.9.1 github.com/prometheus/client_golang v1.14.0 github.com/spf13/pflag v1.0.5 golang.org/x/text v0.8.0 diff --git a/go.sum b/go.sum index cddffe5a..4c1586ca 100644 --- a/go.sum +++ b/go.sum @@ -529,8 +529,8 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg github.com/poy/onpar v0.0.0-20200406201722-06f95a1c68e8/go.mod h1:nSbFQvMj97ZyhFRSJYtut+msi4sOY6zJDGCdSc+/rZU= github.com/poy/onpar v1.1.2 h1:QaNrNiZx0+Nar5dLgTVp5mXkyoVFIbepjyEoGSnhbAY= github.com/poy/onpar v1.1.2/go.mod h1:6X8FLNoxyr9kkmnlqpK6LSoiOtrO6MICtWwEuWkLjzg= -github.com/projectsveltos/libsveltos v0.9.0 h1:JYOlEtnFTDqmozNTz7hmuRAW1+VrFlu++ZPZwPv39Rk= -github.com/projectsveltos/libsveltos v0.9.0/go.mod h1:10UR0S+rA8NdP/X8IPWKv1tb0CL4gOOguT2JCXyL/18= +github.com/projectsveltos/libsveltos v0.9.1 h1:6y6oq2FGlDlQ9/6vyA7tzWC6lq0B3X74kDbpSsV8Y5E= +github.com/projectsveltos/libsveltos v0.9.1/go.mod h1:10UR0S+rA8NdP/X8IPWKv1tb0CL4gOOguT2JCXyL/18= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= diff --git a/manifest/manifest.yaml b/manifest/manifest.yaml index 1051694d..c1c50d47 100644 --- a/manifest/manifest.yaml +++ b/manifest/manifest.yaml @@ -1561,7 +1561,7 @@ spec: - --v=5 command: - /manager - image: projectsveltos/addon-manager-amd64:v0.9.0 + image: projectsveltos/addon-manager-amd64:v0.9.1 livenessProbe: httpGet: path: /healthz diff --git a/pkg/drift-detection/drift-detection-manager.go b/pkg/drift-detection/drift-detection-manager.go index 09193ca2..8097bd9a 100644 --- a/pkg/drift-detection/drift-detection-manager.go +++ b/pkg/drift-detection/drift-detection-manager.go @@ -260,7 +260,7 @@ spec: - --run-mode=do-not-send-updates command: - /manager - image: projectsveltos/drift-detection-manager-amd64:v0.9.0 + image: projectsveltos/drift-detection-manager-amd64:v0.9.1 livenessProbe: httpGet: path: /healthz diff --git a/pkg/drift-detection/drift-detection-manager.yaml b/pkg/drift-detection/drift-detection-manager.yaml index cafa6547..904e49e0 100644 --- a/pkg/drift-detection/drift-detection-manager.yaml +++ b/pkg/drift-detection/drift-detection-manager.yaml @@ -242,7 +242,7 @@ spec: - --run-mode=do-not-send-updates command: - /manager - image: projectsveltos/drift-detection-manager-amd64:v0.9.0 + image: projectsveltos/drift-detection-manager-amd64:v0.9.1 livenessProbe: httpGet: path: /healthz