Skip to content

Commit

Permalink
Fix amphora image conditions
Browse files Browse the repository at this point in the history
- fixed dereferencing nul pointer
- added new error conditions during the deployment of the image
- added 'in progress' condition
  • Loading branch information
gthiemonge committed Jun 17, 2024
1 parent 7e66f41 commit 6e5dd0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ const (
// OctaviaAmphoraImagesReadyInitMessage
OctaviaAmphoraImagesReadyInitMessage = "Octavia Amphora Images setup is not initialized"

// OctaviaAmphoraImagesReadyRunningMessage
OctaviaAmphoraImagesReadyRunningMessage = "Octavia Amphora Images setup in progress"

// OctaviaAmphoraImagesReadyErrorMessage
OctaviaAmphoraImagesReadyErrorMessage = "Octavia Amphora Images setup error occured %s"

Expand Down
26 changes: 21 additions & 5 deletions controllers/octavia_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,10 +1176,9 @@ func (r *OctaviaReconciler) reconcileAmphoraImages(
} else if (ctrlResult != ctrl.Result{}) {
instance.Status.Conditions.Set(condition.FalseCondition(
octaviav1.OctaviaAmphoraImagesReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
octaviav1.OctaviaAmphoraImagesReadyErrorMessage,
err.Error()))
condition.RequestedReason,
condition.SeverityInfo,
octaviav1.OctaviaAmphoraImagesReadyRunningMessage))
return ctrlResult, nil
}
readyCount := depl.GetDeployment().Status.ReadyReplicas
Expand All @@ -1190,13 +1189,25 @@ func (r *OctaviaReconciler) reconcileAmphoraImages(
}
endpoint, err := svc.GetAPIEndpoint(nil, nil, "")
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
octaviav1.OctaviaAmphoraImagesReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
octaviav1.OctaviaAmphoraImagesReadyErrorMessage,
err.Error()))
return ctrl.Result{}, err
}

urlMap, err := r.getLocalImageURLs(endpoint)
if err != nil {
Log.Info(fmt.Sprintf("Cannot get amphora image list: %s", err))
return ctrl.Result{Requeue: true, RequeueAfter: 1 * time.Second}, err
instance.Status.Conditions.Set(condition.FalseCondition(
octaviav1.OctaviaAmphoraImagesReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
octaviav1.OctaviaAmphoraImagesReadyErrorMessage,
err.Error()))
return ctrl.Result{}, err
}

ok, err := octavia.EnsureAmphoraImages(ctx, instance, &r.Log, helper, urlMap)
Expand All @@ -1206,6 +1217,11 @@ func (r *OctaviaReconciler) reconcileAmphoraImages(
if !ok {
// Images are not ready
Log.Info("Waiting for amphora images to be ready")
instance.Status.Conditions.Set(condition.FalseCondition(
octaviav1.OctaviaAmphoraImagesReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
octaviav1.OctaviaAmphoraImagesReadyRunningMessage))
return ctrl.Result{Requeue: true, RequeueAfter: 5 * time.Second}, nil
}
Log.Info(fmt.Sprintf("Setting image upload hash - %s", hash))
Expand Down

0 comments on commit 6e5dd0d

Please sign in to comment.