Skip to content

Commit a903a0e

Browse files
authored
Merge pull request #1666 from gianlucam76/promotion
(feat) Unify Readiness Logic for Auto and Manual Promotion
2 parents e130c92 + fc2778b commit a903a0e

6 files changed

Lines changed: 490 additions & 29 deletions

File tree

api/v1beta1/clusterpromotion_types.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,23 @@ type TimeWindow struct {
240240

241241
// ManualTrigger is a placeholder to represent a manual trigger.
242242
type ManualTrigger struct {
243+
// Delay is an optional time duration to wait after the WaitForStatus condition
244+
// is met before proceeding with the promotion.
245+
// +optional
246+
Delay *metav1.Duration `json:"delay,omitempty"`
247+
248+
// PreHealthCheckDeployment is a slice of resources Sveltos will deploy after the Delay
249+
// period has elapsed and before running PostDelayHealthChecks.
250+
// This can be used, for example, to deploy a Job that performs validation tasks.
251+
// The PostDelayHealthChecks can then validate the successful completion of these resources (e.g., a Job).
252+
// +optional
253+
PreHealthCheckDeployment []PolicyRef `json:"preHealthCheckDeployment,omitempty"`
254+
255+
// PostDelayHealthChecks is a slice of health checks Sveltos will run after the delay
256+
// period has elapsed.
257+
// +optional
258+
PostDelayHealthChecks []libsveltosv1beta1.ValidateHealth `json:"postDelayHealthChecks,omitempty"`
259+
243260
// Approved, when set to true, signals to the controller that
244261
// promotion to the next stage is approved.
245262
// +optional

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/config.projectsveltos.io_clusterpromotions.yaml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,6 +1675,193 @@ spec:
16751675
to the next stage. This prevents unintended immediate advancement
16761676
past the next manual stage. Defaults to true.
16771677
type: boolean
1678+
delay:
1679+
description: |-
1680+
Delay is an optional time duration to wait after the WaitForStatus condition
1681+
is met before proceeding with the promotion.
1682+
type: string
1683+
postDelayHealthChecks:
1684+
description: |-
1685+
PostDelayHealthChecks is a slice of health checks Sveltos will run after the delay
1686+
period has elapsed.
1687+
items:
1688+
properties:
1689+
evaluateCEL:
1690+
description: |-
1691+
EvaluateCEL contains a list of named CEL (Common Expression Language) rules.
1692+
Each rule will be evaluated in order against each object selected based on
1693+
the criteria defined above. Each rule's expression must return a boolean value
1694+
indicating whether the object is a match.
1695+
1696+
Evaluation stops at the first rule that returns true; subsequent
1697+
rules will not be evaluated.
1698+
items:
1699+
description: CELRule defines a named CEL rule
1700+
used in EvaluateCEL.
1701+
properties:
1702+
name:
1703+
description: Name is a human-readable identifier
1704+
for the rule.
1705+
type: string
1706+
rule:
1707+
description: |-
1708+
Rule is the CEL (Common Expression Language) expression to evaluate.
1709+
It must return a bool
1710+
type: string
1711+
required:
1712+
- name
1713+
- rule
1714+
type: object
1715+
type: array
1716+
featureID:
1717+
description: |-
1718+
FeatureID is an indentifier of the feature (Helm/Kustomize/Resources)
1719+
This field indicates when to run this check.
1720+
For instance:
1721+
- if set to Helm this check will be run after all helm
1722+
charts specified in the ClusterProfile are deployed.
1723+
- if set to Resources this check will be run after the content
1724+
of all the ConfigMaps/Secrets referenced by ClusterProfile in the
1725+
PolicyRef sections is deployed
1726+
enum:
1727+
- Resources
1728+
- Helm
1729+
- Kustomize
1730+
type: string
1731+
group:
1732+
description: Group of the resource to fetch in
1733+
the managed Cluster.
1734+
type: string
1735+
kind:
1736+
description: Kind of the resource to fetch in
1737+
the managed Cluster.
1738+
minLength: 1
1739+
type: string
1740+
labelFilters:
1741+
description: LabelFilters allows to filter resources
1742+
based on current labels.
1743+
items:
1744+
properties:
1745+
key:
1746+
description: Key is the label key
1747+
type: string
1748+
operation:
1749+
description: Operation is the comparison
1750+
operation
1751+
enum:
1752+
- Equal
1753+
- Different
1754+
- Has
1755+
- DoesNotHave
1756+
type: string
1757+
value:
1758+
description: Value is the label value
1759+
type: string
1760+
required:
1761+
- key
1762+
- operation
1763+
type: object
1764+
type: array
1765+
name:
1766+
description: Name is the name of this check
1767+
type: string
1768+
namespace:
1769+
description: |-
1770+
Namespace of the resource to fetch in the managed Cluster.
1771+
Empty for resources scoped at cluster level.
1772+
type: string
1773+
script:
1774+
description: |-
1775+
Script is a text containing a lua script.
1776+
Must return struct with field "health"
1777+
representing whether object is a match (true or false)
1778+
type: string
1779+
version:
1780+
description: Version of the resource to fetch
1781+
in the managed Cluster.
1782+
type: string
1783+
required:
1784+
- featureID
1785+
- group
1786+
- kind
1787+
- name
1788+
- version
1789+
type: object
1790+
type: array
1791+
preHealthCheckDeployment:
1792+
description: |-
1793+
PreHealthCheckDeployment is a slice of resources Sveltos will deploy after the Delay
1794+
period has elapsed and before running PostDelayHealthChecks.
1795+
This can be used, for example, to deploy a Job that performs validation tasks.
1796+
The PostDelayHealthChecks can then validate the successful completion of these resources (e.g., a Job).
1797+
items:
1798+
properties:
1799+
deploymentType:
1800+
default: Remote
1801+
description: |-
1802+
DeploymentType indicates whether resources need to be deployed
1803+
into the management cluster (local) or the managed cluster (remote)
1804+
enum:
1805+
- Local
1806+
- Remote
1807+
type: string
1808+
kind:
1809+
description: |-
1810+
Kind of the resource. Supported kinds are:
1811+
- ConfigMap/Secret
1812+
- flux GitRepository;OCIRepository;Bucket
1813+
enum:
1814+
- GitRepository
1815+
- OCIRepository
1816+
- Bucket
1817+
- ConfigMap
1818+
- Secret
1819+
type: string
1820+
name:
1821+
description: |-
1822+
Name of the referenced resource.
1823+
Name can be expressed as a template and instantiate using any cluster field.
1824+
minLength: 1
1825+
type: string
1826+
namespace:
1827+
description: |-
1828+
Namespace of the referenced resource.
1829+
For ClusterProfile namespace can be left empty. In such a case, namespace will
1830+
be implicit set to cluster's namespace.
1831+
For Profile namespace must be left empty. Profile namespace will be used.
1832+
Namespace can be expressed as a template and instantiate using any cluster field.
1833+
type: string
1834+
optional:
1835+
default: false
1836+
description: |-
1837+
Optional indicates that the referenced resource is not mandatory.
1838+
If set to true and the resource is not found, the error will be ignored,
1839+
and Sveltos will continue processing other PolicyRefs.
1840+
type: boolean
1841+
path:
1842+
description: |-
1843+
Path to the directory containing the YAML files.
1844+
Defaults to 'None', which translates to the root path of the SourceRef.
1845+
Used only for GitRepository;OCIRepository;Bucket
1846+
type: string
1847+
tier:
1848+
default: 100
1849+
description: |-
1850+
Tier controls the order of deployment for resources coming from different PolicyRefs
1851+
within the same ClusterProfile or Profile.
1852+
When two PolicyRefs attempt to deploy the same resource, the PolicyRef with the lowest
1853+
Tier value takes priority and deploys/updates the resource.
1854+
This priority mechanism is only checked after the parent ClusterProfile has won
1855+
the primary conflict resolution against other ClusterProfiles.
1856+
Higher Tier values represent lower priority. The default Tier value is 100.
1857+
format: int32
1858+
minimum: 1
1859+
type: integer
1860+
required:
1861+
- kind
1862+
- name
1863+
type: object
1864+
type: array
16781865
type: object
16791866
type: object
16801867
x-kubernetes-validations:

0 commit comments

Comments
 (0)