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

added app upload health checks #153

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

yashsinghcodes
Copy link
Member

No description provided.

@yashsinghcodes
Copy link
Member Author

Please don't merge yet. I'm testing the openAPI app creation will push in the same PR.

@yashsinghcodes
Copy link
Member Author

This PR is complete and tested and ready to for a review.

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.

(:

// replace edaa73d40238ee60874a853dc3ccaa6f
// with id from above and bunch of other data to
// not get same app id when verified
newOpenapiString := strings.Replace(openapiString, `"edaa73d40238ee60874a853dc3ccaa6f"`, `"`+id+`"`, 1)
Copy link
Member

Choose a reason for hiding this comment

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

What are we doing here? 😆

Can't we instead just change the actual struct? and marshal/unmarshal?

This will somehow break - I just don't know how lol


// TODO: More testing for onprem health checks
if project.Environment == "cloud" {
appHealthChannel := make(chan AppHealth)
Copy link
Member

Choose a reason for hiding this comment

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

If you call the other one "pythonAppHealth", please call this "openapiAppHealth" or something to make it clear. I wasn't able to differ them until I read deeper into them.

ExecutionID: "",
}

appZipUrl := "https://github.com/yashsinghcodes/python-apps/raw/refs/heads/master/shuffle-tools-copy.zip"
Copy link
Member

Choose a reason for hiding this comment

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

If this is going to prod, we need it in a shuffle repo (:

}()

baseUrl := "https://shuffler.io"
if 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.

Again, same as the other place:

BASE_URL > CLOUDRUN_URL. Cloudrun is used to OVERRIDE the BASE_URL. That is it's whole purpose.

baseUrl = os.Getenv("SHUFFLE_CLOUDRUN_URL")
}

if project.Environment == "onprem" {
Copy link
Member

Choose a reason for hiding this comment

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

Check for not cloud instead of for onprem.

}

if res.StatusCode != 200{
log.Printf("[ERROR] Failed to upload an ops app. Response: %s", string(response))
Copy link
Member

Choose a reason for hiding this comment

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

There may be data here that is useful such as logs. How do you handle those cases so that you know what to do?

appHealth.AppId = appData.Id

// wait 5 second before execution
time.Sleep(5 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

Why?


appExecuteData, err := io.ReadAll(resp.Body)
if err != nil {
log.Printf("[ERROR] Failed to read app execution data")
Copy link
Member

Choose a reason for hiding this comment

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

Handle error?


appHealth.Run = true
appHealth.ExecutionID = executionData.Id
for executionData.Result == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Avoid infinite loops. Add indexing with a max limit if you are gonna do it this way.

While loops can go die in a fire.


defer resp.Body.Close()

if resp.StatusCode != 200 {
Copy link
Member

Choose a reason for hiding this comment

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

Same here; maybe resp body could be useful?

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