Skip to content

Commit

Permalink
refactor(RHTAPREL-830): remove deployment code from service
Browse files Browse the repository at this point in the history
* For decouple environment provisioning from deployment
  deployment pipeline and related code needs to be
  removed from service

Signed-off-by: Happy Bhati <[email protected]>
  • Loading branch information
happybhati committed Mar 7, 2024
1 parent 2518642 commit 5708596
Show file tree
Hide file tree
Showing 26 changed files with 7 additions and 2,288 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ COPY main.go main.go
COPY api/ api/
COPY cache/ cache/
COPY controllers/ controllers/
COPY gitops/ gitops/
COPY loader/ loader/
COPY metadata/ metadata/
COPY metrics/ metrics/
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ by default, this operator exports the following custom metrics:
| Metric name | Type | Description |
|--------------------------------------------------|-----------|---------------------------------------------------------------------|
| release_concurrent_total | Gauge | Total number of concurrent release attempts. |
| release_concurrent_deployments_total | Gauge | Total number of concurrent release deployment attempts. |
| release_concurrent_post_actions_executions_total | Gauge | Total number of concurrent release post actions executions attempts |
| release_concurrent_processings_total | Gauge | Total number of concurrent release processing attempts. |
| release_deployment_duration_seconds | Histogram | How long in seconds a Release deployment takes to complete. |
| release_duration_seconds | Histogram | How long in seconds a Release takes to complete. |
| release_post_actions_execution_duration_seconds | Histogram | How long in seconds Release post-actions take to complete. |
| release_processing_duration_seconds | Histogram | How long in seconds a Release processing takes to complete. |
Expand Down
93 changes: 0 additions & 93 deletions api/v1alpha1/release_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ type ReleaseStatus struct {
// +optional
Conditions []metav1.Condition `json:"conditions"`

// Deployment contains information about the deployment
// +optional
Deployment DeploymentInfo `json:"deployment,omitempty"`

// PostActionsExecution contains information about the post-actions execution
// +optional
PostActionsExecution PostActionsExecutionInfo `json:"postActionsExecution,omitempty"`
Expand Down Expand Up @@ -110,27 +106,6 @@ type AttributionInfo struct {
StandingAuthorization bool `json:"standingAuthorization,omitempty"`
}

// DeploymentInfo defines the observed state of the deployment.
type DeploymentInfo struct {
// CompletionTime is the time when the Release deployment was completed
// +optional
CompletionTime *metav1.Time `json:"completionTime,omitempty"`

// Environment is the environment where the Release will be deployed to
// +optional
Environment string `json:"environment,omitempty"`

// SnapshotEnvironmentBinding contains the namespaced name of the SnapshotEnvironmentBinding created as part of
// this release
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?\/[a-z0-9]([-a-z0-9]*[a-z0-9])?$
// +optional
SnapshotEnvironmentBinding string `json:"snapshotEnvironmentBinding,omitempty"`

// StartTime is the time when the Release deployment started
// +optional
StartTime *metav1.Time `json:"startTime,omitempty"`
}

// PostActionsExecutionInfo defines the observed state of the post-actions execution.
type PostActionsExecutionInfo struct {
// CompletionTime is the time when the Release post-actions execution was completed
Expand Down Expand Up @@ -191,11 +166,6 @@ type Release struct {
Status ReleaseStatus `json:"status,omitempty"`
}

// HasDeploymentFinished checks whether the Release deployment has finished, regardless of the result.
func (r *Release) HasDeploymentFinished() bool {
return r.hasPhaseFinished(deployedConditionType)
}

// HasEveryPostActionExecutionFinished checks whether the Release post-actions execution has finished,
// regardless of the result.
func (r *Release) HasEveryPostActionExecutionFinished() bool {
Expand All @@ -222,16 +192,6 @@ func (r *Release) IsAutomated() bool {
return r.Status.Automated
}

// IsDeployed checks whether the Release was successfully deployed.
func (r *Release) IsDeployed() bool {
return meta.IsStatusConditionTrue(r.Status.Conditions, deployedConditionType.String())
}

// IsDeploying checks whether the Release deployment is in progress.
func (r *Release) IsDeploying() bool {
return r.isPhaseProgressing(deployedConditionType)
}

// IsEveryPostActionExecuted checks whether the Release post-actions were successfully executed.
func (r *Release) IsEveryPostActionExecuted() bool {
return meta.IsStatusConditionTrue(r.Status.Conditions, postActionsExecutedConditionType.String())
Expand Down Expand Up @@ -267,57 +227,6 @@ func (r *Release) IsValid() bool {
return meta.IsStatusConditionTrue(r.Status.Conditions, validatedConditionType.String())
}

// MarkDeployed marks the Release as deployed.
func (r *Release) MarkDeployed() {
if !r.IsDeploying() || r.HasDeploymentFinished() {
return
}

r.Status.Deployment.CompletionTime = &metav1.Time{Time: time.Now()}
conditions.SetCondition(&r.Status.Conditions, deployedConditionType, metav1.ConditionTrue, SucceededReason)

go metrics.RegisterCompletedReleaseDeployment(
r.Status.Deployment.StartTime,
r.Status.Deployment.CompletionTime,
r.Status.Deployment.Environment,
SucceededReason.String(),
r.Status.Target,
)
}

// MarkDeploying marks the Release as deploying.
func (r *Release) MarkDeploying(message string) {
if r.HasDeploymentFinished() {
return
}

if !r.IsDeploying() {
r.Status.Deployment.StartTime = &metav1.Time{Time: time.Now()}
}

conditions.SetConditionWithMessage(&r.Status.Conditions, deployedConditionType, metav1.ConditionFalse, ProgressingReason, message)

go metrics.RegisterNewReleaseDeployment()
}

// MarkDeploymentFailed marks the Release deployment as failed.
func (r *Release) MarkDeploymentFailed(message string) {
if !r.IsDeploying() || r.HasDeploymentFinished() {
return
}

r.Status.Deployment.CompletionTime = &metav1.Time{Time: time.Now()}
conditions.SetConditionWithMessage(&r.Status.Conditions, deployedConditionType, metav1.ConditionFalse, FailedReason, message)

go metrics.RegisterCompletedReleaseDeployment(
r.Status.Deployment.StartTime,
r.Status.Deployment.CompletionTime,
r.Status.Deployment.Environment,
FailedReason.String(),
r.Status.Target,
)
}

// MarkProcessed marks the Release as processed.
func (r *Release) MarkProcessed() {
if !r.IsProcessing() || r.HasProcessingFinished() {
Expand Down Expand Up @@ -431,7 +340,6 @@ func (r *Release) MarkReleased() {
go metrics.RegisterCompletedRelease(
r.Status.StartTime,
r.Status.CompletionTime,
r.getPhaseReason(deployedConditionType),
r.getPhaseReason(postActionsExecutedConditionType),
r.getPhaseReason(processedConditionType),
SucceededReason.String(),
Expand Down Expand Up @@ -467,7 +375,6 @@ func (r *Release) MarkReleaseFailed(message string) {
go metrics.RegisterCompletedRelease(
r.Status.StartTime,
r.Status.CompletionTime,
r.getPhaseReason(deployedConditionType),
r.getPhaseReason(postActionsExecutedConditionType),
r.getPhaseReason(processedConditionType),
FailedReason.String(),
Expand Down
Loading

0 comments on commit 5708596

Please sign in to comment.