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

feat: Improvement over health API #143

Merged
merged 15 commits into from
Feb 19, 2025
Merged

Conversation

yashsinghcodes
Copy link
Member

No description provided.

@yashsinghcodes
Copy link
Member Author

Please make sure to define a new env variable called SHUFFLE_BACKEND_VERSION to get the records in health api logs.

health.go Outdated
@@ -893,18 +885,57 @@ func fixOpensearch() error {
return nil
}

func FixSubflow(ctx context.Context, workflowId string) error {
Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry, what is happening here? Why do we have a custom fixSubflow function in the API, which SETS the workflow in the database differently?

If you were just returning the workflow to be used in the parent it's ok, but SETTING, then GETTING it again doesn't really do that.

Please explain. This makes no sense to me

Copy link
Member Author

Choose a reason for hiding this comment

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

I had to set it this way because we use the API call to the <workflowID>/execute endpoint to run the workflow. So, if I modify any field in the workflow, I need to save the workflow. However, you're right—there is a redundant call to GetWorkflow, which I will fix.

I also just realized that instead of using the SetWorkflow function, I should use the API. While we know that SetWorkflow works, we are not actually verifying whether sending JSON to the save API functions correctly (which should test both the SetWorkflow as well as json handling). I'll update the code accordingly.

@frikky
Copy link
Member

frikky commented Feb 2, 2025

Should we merge this? Is it ready?

@frikky
Copy link
Member

frikky commented Feb 4, 2025

Please make sure to define a new env variable called SHUFFLE_BACKEND_VERSION to get the records in health api logs.

Send a PR with this updated in every single one. This NEEDS to be dynamic.

@yashsinghcodes
Copy link
Member Author

Can we track the version with the deployment time. It will be pretty easy to implement onto the deployment script, so don't have to update the version manually and we can track it with the deployment date.

@frikky

@yashsinghcodes
Copy link
Member Author

New Things Added:

  • Track execution time
  • Make use of the API rather than directly calling the function.

@yashsinghcodes
Copy link
Member Author

Next PRs will focus on using the gcloud to track logs which can be interesting.

@frikky
Copy link
Member

frikky commented Feb 4, 2025

Can we track the version with the deployment time. It will be pretty easy to implement onto the deployment script, so don't have to update the version manually and we can track it with the deployment date.

@frikky

That is literally what I said. Dynamic. Just use the revision thing Aditya already made.

Copy link
Member

@frikky frikky left a comment

Choose a reason for hiding this comment

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

More reviews yay

health.go Outdated
@@ -893,18 +885,104 @@ func fixOpensearch() error {
return nil
}

func fixSubflow(ctx context.Context, workflow *Workflow) error {
Copy link
Member

Choose a reason for hiding this comment

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

Make the name of the function more specific please. This tells me nothing 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! Changed something which make it more specific.

health.go Outdated
}
}

baseUrl := os.Getenv("SHUFFLE_CLOUDRUN_URL")
Copy link
Member

Choose a reason for hiding this comment

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

Write these opposite. Again; SANE DEFAULTS.

Set default to shuffler.io -> override with cloudrun URL

Further; does this code run onprem? Is this handled then, as to point to the right system?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Handled the on-prem case as well, tested and working.

health.go Outdated
baseUrl := os.Getenv("SHUFFLE_CLOUDRUN_URL")
if len(baseUrl) == 0 {
baseUrl := "https://shuffler.io"
if len(os.Getenv("SHUFFLE_CLOUDRUN_URL")) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Always use SHUFFLE_CLOUDRUN_URL last, as that makes it possible to use it as an onprem environment variable to override URLs in general.

Copy link
Member

@frikky frikky left a comment

Choose a reason for hiding this comment

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

Minor things. Merge time?

health.go Outdated
@@ -893,18 +885,113 @@ func fixOpensearch() error {
return nil
}

func fixSubflowParameters(ctx context.Context, workflow *Workflow, apiKey string, orgId string) error {
Copy link
Member

Choose a reason for hiding this comment

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

Is this a generic function we can pass in a workflow into and it will fix parameters at all times, or is it specifically for health?

If it's for health, please make that clear in the name, as while grepping for relevant functions, I may end up just using it (:

Copy link
Member Author

Choose a reason for hiding this comment

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

It is specifically for the health API. Let me fix the name of the functions to make them more clear :)

health.go Outdated
baseUrl = os.Getenv("SHUFFLE_CLOUDRUN_URL")
}

req, err := http.NewRequest("PUT", baseUrl+"/api/v1/workflows/"+workflow.ID+"?skip_save=true", nil)
Copy link
Member

Choose a reason for hiding this comment

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

Make this more readable. Just make a variable for the URL and newline each item. Hard to come in here and get the point without that.

Why is it a PUT request without any data? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

We are actually defining the body in the later part of the code, this is just being use to create new Request type.
https://github.com/Shuffle/shuffle-shared/pull/143/files/a9d13e1dae8f0fa3863f10e982a4191dacf46c2f#diff-46ab8d7c52533584f96ba53eaeadd8cf52839f1c5d175c059ceb909c2c3e0715R947

@yashsinghcodes
Copy link
Member Author

Hi @frikky, Please review :)

Will push other features in a different PR.

Copy link
Member

@frikky frikky left a comment

Choose a reason for hiding this comment

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

Looking good! Just minor optimizations left.

@frikky frikky merged commit 2f2ca26 into Shuffle:main Feb 19, 2025
2 of 3 checks passed
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.

2 participants