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 artifact URL as soon as reconciling starts #169

Merged
merged 5 commits into from
Aug 6, 2023

Conversation

samos123
Copy link
Contributor

@samos123 samos123 commented Aug 5, 2023

Fixes #144

Copy link
Contributor

@nstogner nstogner left a comment

Choose a reason for hiding this comment

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

Agree we should set URL earlier, but I don't think we want to include a new call to update status. I would just set the field and allow the next update status call to do what you are intending here.

@@ -68,10 +68,23 @@ func (r *ModelReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
func (r *ModelReconciler) reconcileModel(ctx context.Context, model *apiv1.Model) (result, error) {
log := log.FromContext(ctx)

if model.Status.Artifacts.URL != "" {
if model.Status.Ready {
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep this change to the conditional

Copy link
Contributor Author

@samos123 samos123 Aug 6, 2023

Choose a reason for hiding this comment

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

you mean change to model.Status.Ready == true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think what I have currently is preferred over having

if model.Status.Ready == true {

Source: https://stackoverflow.com/questions/3685002/check-if-boolean-is-true

Copy link
Contributor

@nstogner nstogner Aug 6, 2023

Choose a reason for hiding this comment

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

Was just commenting on checking ready instead of the url

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure why I misunderstood your comment. I read it as change to the conditional format or smth like that.

return result{success: true}, nil
}

if model.Status.Artifacts.URL == "" {
model.Status.Artifacts.URL = r.Cloud.ObjectArtifactURL(model).String()
Copy link
Contributor

Choose a reason for hiding this comment

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

Always set this URL.

Reason: apiv1.ReasonJobComplete,
ObservedGeneration: model.Generation,
})
if err := r.Status().Update(ctx, model); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this status update... This will be too fleeting, not worth the API request.

Copy link
Contributor

Choose a reason for hiding this comment

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

This update request will be sent very soon after this and the URL will be set then.

ConditionLoaded = "Loaded"
ConditionModelled = "Modelled"
ConditionDeployed = "Deployed"
ConditionReconciling = "Reconciling"
Copy link
Contributor

Choose a reason for hiding this comment

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

Conditions here should be end-states not transition states. IMO, I would remove this and go with the suggested changes below which make this unnecessary.

@samos123
Copy link
Contributor Author

samos123 commented Aug 6, 2023

I verified the new approach of not using an additional update works perfectly as well. Thanks for the great suggestion

@samos123 samos123 requested a review from nstogner August 6, 2023 04:17
Copy link
Contributor

@nstogner nstogner left a comment

Choose a reason for hiding this comment

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

Looks good!

@samos123 samos123 merged commit 22062a1 into main Aug 6, 2023
4 checks passed
@samos123 samos123 deleted the fix-144-provide-gcs-url-earlier branch August 6, 2023 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide GCS URL once model is created instead of once ready
3 participants