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
21 changes: 21 additions & 0 deletions api/v1beta1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,24 @@ package v1beta1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// FailedCluster describes an error encountered while trying to
// manage resources for a specific matching cluster.
type FailedCluster struct {
// ClusterRef is a reference to the cluster where the failure occurred.
ClusterRef corev1.ObjectReference `json:"clusterRef"`

// FailureMessage is a human-readable explanation of why the
// ClusterSummary creation/update failed.
FailureMessage string `json:"failureMessage"`

// LastFailureTime is the time the error occurred.
// +optional
LastFailureTime *metav1.Time `json:"lastFailureTime,omitempty"`
}

// Status defines the observed state of ClusterProfile/Profile
type Status struct {
// MatchingClusterRefs reference all the clusters currently matching
Expand All @@ -38,6 +54,11 @@ type Status struct {
// +optional
UpdatedClusters Clusters `json:"updatedClusters,omitempty"`

// FailedClusters contains information about clusters for which
// a ClusterSummary could not be created or updated.
// +optional
FailedClusters []FailedCluster `json:"failedClusters,omitempty"`

// DependenciesHash is a hash representing the set of clusters where this ClusterProfile
// must be deployed, based on the combined configuration of its dependencies.
DependenciesHash []byte `json:"dependenciesHash,omitempty"`
Expand Down
27 changes: 27 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,73 @@ spec:
must be deployed, based on the combined configuration of its dependencies.
format: byte
type: string
failedClusters:
description: |-
FailedClusters contains information about clusters for which
a ClusterSummary could not be created or updated.
items:
description: |-
FailedCluster describes an error encountered while trying to
manage resources for a specific matching cluster.
properties:
clusterRef:
description: ClusterRef is a reference to the cluster where
the failure occurred.
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
type: string
kind:
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
namespace:
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
type: string
resourceVersion:
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
type: string
uid:
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
type: string
type: object
x-kubernetes-map-type: atomic
failureMessage:
description: |-
FailureMessage is a human-readable explanation of why the
ClusterSummary creation/update failed.
type: string
lastFailureTime:
description: LastFailureTime is the time the error occurred.
format: date-time
type: string
required:
- clusterRef
- failureMessage
type: object
type: array
matchingClusters:
description: |-
MatchingClusterRefs reference all the clusters currently matching
Expand Down
67 changes: 67 additions & 0 deletions config/crd/bases/config.projectsveltos.io_profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,73 @@ spec:
must be deployed, based on the combined configuration of its dependencies.
format: byte
type: string
failedClusters:
description: |-
FailedClusters contains information about clusters for which
a ClusterSummary could not be created or updated.
items:
description: |-
FailedCluster describes an error encountered while trying to
manage resources for a specific matching cluster.
properties:
clusterRef:
description: ClusterRef is a reference to the cluster where
the failure occurred.
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
type: string
kind:
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
namespace:
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
type: string
resourceVersion:
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
type: string
uid:
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
type: string
type: object
x-kubernetes-map-type: atomic
failureMessage:
description: |-
FailureMessage is a human-readable explanation of why the
ClusterSummary creation/update failed.
type: string
lastFailureTime:
description: LastFailureTime is the time the error occurred.
format: date-time
type: string
required:
- clusterRef
- failureMessage
type: object
type: array
matchingClusters:
description: |-
MatchingClusterRefs reference all the clusters currently matching
Expand Down
21 changes: 11 additions & 10 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ resources:
# default, aiding admins in cluster management. Those roles are
# not used by the Project itself. You can comment the following lines
# if you do not want those helpers be installed with your Project.
- profile_editor_role.yaml
- profile_viewer_role.yaml
- clusterconfiguration_editor_role.yaml
- clusterconfiguration_viewer_role.yaml
- clustersummary_editor_role.yaml
- clustersummary_viewer_role.yaml
- clusterreport_editor_role.yaml
- clusterreport_viewer_role.yaml
- clusterprofile_editor_role.yaml
- clusterprofile_viewer_role.yaml
# - profile_editor_role.yaml
# - profile_viewer_role.yaml
# - clusterconfiguration_editor_role.yaml
# - clusterconfiguration_viewer_role.yaml
# - clustersummary_editor_role.yaml
# - clustersummary_viewer_role.yaml
# - clustersummary_viewer_role.yaml
# - clusterreport_editor_role.yaml
# - clusterreport_viewer_role.yaml
# - clusterprofile_editor_role.yaml
# - clusterprofile_viewer_role.yaml
9 changes: 8 additions & 1 deletion controllers/profile_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,13 @@ func updateClusterSummaryInstanceForCluster(ctx context.Context, c client.Client
// If a Cluster exists and it is a match, ClusterSummary is created (and ClusterSummary.Spec kept in sync if mode is
// continuous).
// ClusterSummary won't program cluster in paused state.
return false, patchClusterSummary(ctx, c, profileScope, cluster, logger)
err = patchClusterSummary(ctx, c, profileScope, cluster, logger)
if err != nil {
profileScope.SetFailedClusters(cluster, err)
} else {
profileScope.ClearFailedClusters(cluster)
}
return false, err
}

func patchClusterSummary(ctx context.Context, c client.Client, profileScope *scope.ProfileScope,
Expand All @@ -769,6 +775,7 @@ func patchClusterSummary(ctx context.Context, c client.Client, profileScope *sco
err = createClusterSummary(ctx, c, profileScope, cluster)
if err != nil {
logger.Error(err, "failed to create ClusterSummary")
return err
}
} else {
logger.Error(err, "failed to get ClusterSummary")
Expand Down
Loading