Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rollout status in app api #520

Merged
merged 2 commits into from
Dec 22, 2023

Conversation

LiZhenCheng9527
Copy link
Contributor

What type of PR is this?
/kind api-change

What this PR does / why we need it:
add rollout status in application api

Copy link

netlify bot commented Dec 18, 2023

Deploy Preview for kurator-dev ready!

Name Link
🔨 Latest commit e6c73b4
🔍 Latest deploy log https://app.netlify.com/sites/kurator-dev/deploys/65828ab0c2904500087e6856
😎 Deploy Preview https://deploy-preview-520--kurator-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -419,6 +423,21 @@ type ApplicationSyncStatus struct {
HelmReleaseStatus *helmv2beta1.HelmReleaseStatus `json:"HelmReleaseStatus,omitempty"`
}

// RolloutStatus defines the observed state of Rollout.
type RolloutStatus struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have defined the RolloutStatus structure, but you haven't specified where it is used.

You might need to declare it in

// ApplicationStatus defines the observed state of Application.
type ApplicationStatus struct {
SourceStatus *ApplicationSourceStatus `json:"sourceStatus,omitempty"`
SyncStatus []*ApplicationSyncStatus `json:"syncStatus,omitempty"`
}

@@ -417,6 +421,22 @@ type ApplicationSyncStatus struct {
Name string `json:"name,omitempty"`
KustomizationStatus *kustomizev1beta2.KustomizationStatus `json:"kustomizationStatus,omitempty"`
HelmReleaseStatus *helmv2beta1.HelmReleaseStatus `json:"HelmReleaseStatus,omitempty"`
RolloutStatus RolloutStatus `json:"rolloutStatus,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is different from fluxCD, which we create CR in management cluster,

But for rolling out we need to create CR in member clusters, i am not sure how can we watch the member cluster CR's status

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this approach differs from FluxCD.

It may not be feasible to directly monitor the status of Custom Resources (CRs) in member clusters.

Instead, we might need to continuously iterate over these CRs, checking them until they achieve the expected state.

see:

// reconcileOneTimeBackupStatus updates the status of a one-time Backup object by checking the status of corresponding Velero backup resources in each target cluster.
// It determines whether to requeue the reconciliation based on the completion status of all Velero backup resources.
func (b *BackupManager) reconcileOneTimeBackupStatus(ctx context.Context, backup *backupapi.Backup, destinationClusters map[fleetmanager.ClusterKey]*fleetmanager.FleetCluster, statusMap map[string]*backupapi.BackupDetails) (ctrl.Result, error) {
log := ctrl.LoggerFrom(ctx)
// Loop through each target cluster to retrieve the status of Velero backup resources using the client associated with the respective target cluster.
for clusterKey, clusterAccess := range destinationClusters {
name := generateVeleroResourceName(clusterKey.Name, BackupKind, backup.Namespace, backup.Name)
veleroBackup := &velerov1.Backup{}
// Use the client of the target cluster to get the status of Velero backup resources
err := getResourceFromClusterClient(ctx, name, VeleroNamespace, *clusterAccess, veleroBackup)
if err != nil {
log.Error(err, "failed to create velero backup instance for sync one time backup status")
return ctrl.Result{}, err
}
key := fmt.Sprintf("%s-%s-%s", clusterKey.Name, clusterKey.Kind, veleroBackup.Name)
if detail, exists := statusMap[key]; exists {
// If a matching entry is found, update the existing BackupDetails object with the new status.
detail.BackupStatusInCluster = &veleroBackup.Status
} else {
// If no matching entry is found, create a new BackupDetails object and append it to the backup's status details.
currentBackupDetails := &backupapi.BackupDetails{
ClusterName: clusterKey.Name,
ClusterKind: clusterKey.Kind,
BackupNameInCluster: veleroBackup.Name,
BackupStatusInCluster: &veleroBackup.Status,
}
backup.Status.Details = append(backup.Status.Details, currentBackupDetails)
}
}
// Determine whether to requeue the reconciliation based on the completion status of all Velero backup resources.
// If all backups are complete, exit directly without requeuing.
// Otherwise, requeue the reconciliation after a specified interval (StatusSyncInterval).
if allBackupsCompleted(backup.Status) {
return ctrl.Result{}, nil
} else {
return ctrl.Result{RequeueAfter: StatusSyncInterval}, nil
}
}

@@ -338,6 +352,17 @@ type Metric struct {
ThresholdRange *CanaryThresholdRange `json:"thresholdRange,omitempty"`
}

type MetricType string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my perspective this is MetricName

Signed-off-by: LiZhenCheng9527 <[email protected]>
Signed-off-by: LiZhenCheng9527 <[email protected]>
@LiZhenCheng9527
Copy link
Contributor Author

@hzxuzhonghu

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@kurator-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kurator-bot kurator-bot merged commit 61663cc into kurator-dev:main Dec 22, 2023
11 checks passed
@LiZhenCheng9527 LiZhenCheng9527 deleted the app-api-change branch January 9, 2024 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants