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

Log successful cluster deletions #3934

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 11 additions & 4 deletions pkg/backend/openshiftcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ func (ocb *openShiftClusterBackend) handle(ctx context.Context, log *logrus.Entr
// and stop monitoring the cluster.
// TODO: Provide better communication between RP and Monitor
time.Sleep(time.Until(t.Add(time.Second * time.Duration(monitorDeleteWaitTimeSec))))
return ocb.dbOpenShiftClusters.Delete(ctx, doc)
err := ocb.dbOpenShiftClusters.Delete(ctx, doc)
ocb.emitTerminalMetrics(log, doc, api.ProvisioningStateDeleting, api.ProvisioningStateFailed, err)
return err
}

return fmt.Errorf("unexpected provisioningState %q", doc.OpenShiftCluster.Properties.ProvisioningState)
Expand Down Expand Up @@ -310,9 +312,7 @@ func (ocb *openShiftClusterBackend) endLease(ctx context.Context, log *logrus.En
if err != nil {
return err
}
ocb.asyncOperationResultLog(log, initialProvisioningState, backendErr)
ocb.emitMetrics(log, doc, operationType, provisioningState, nil)
ocb.emitProvisioningMetrics(doc, provisioningState)
ocb.emitTerminalMetrics(log, doc, operationType, provisioningState, backendErr)
}

if initialProvisioningState == api.ProvisioningStateAdminUpdating {
Expand All @@ -334,6 +334,13 @@ func (ocb *openShiftClusterBackend) endLease(ctx context.Context, log *logrus.En
return err
}

func (ocb *openShiftClusterBackend) emitTerminalMetrics(log *logrus.Entry, doc *api.OpenShiftClusterDocument, operationType, provisioningState api.ProvisioningState, backendErr error) {
initialProvisioningState := doc.OpenShiftCluster.Properties.ProvisioningState
ocb.asyncOperationResultLog(log, initialProvisioningState, backendErr)
ocb.emitMetrics(log, doc, operationType, provisioningState, nil)
ocb.emitProvisioningMetrics(doc, provisioningState)
}

func (ocb *openShiftClusterBackend) asyncOperationResultLog(log *logrus.Entry, initialProvisioningState api.ProvisioningState, backendErr error) {
log = log.WithFields(logrus.Fields{
"LOGKIND": "asyncqos",
Expand Down
Loading