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

What's up with get-404-delete? #597

Open
fdr opened this issue Sep 13, 2023 · 8 comments
Open

What's up with get-404-delete? #597

fdr opened this issue Sep 13, 2023 · 8 comments
Assignees

Comments

@fdr
Copy link
Collaborator

fdr commented Sep 13, 2023

# Waiting 404 Not Found response for get runner request
begin
github_client.get("/repos/#{github_runner.repository_name}/actions/runners/#{github_runner.runner_id}")
github_client.delete("/repos/#{github_runner.repository_name}/actions/runners/#{github_runner.runner_id}")
nap 5
rescue Octokit::NotFound
end

This code is strange: why call GET before DELETE? Why not cut to the chase and use DELETE?

Doing that would simplify the tests, and remove one long network access.

@enescakir
Copy link
Member

GitHub API returns 204 even runner doesn't exists. We can't be sure runner is deleted or not with just DELETE request.

https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-a-repository

[36] clover-development(main)> client.delete("/repos/enescakir/astrobee/actions/runners/123")
=> ""
[37] clover-development(main)> client.last_response
=> #<Sawyer::Response: 204 @rels={} @data="">

@fdr
Copy link
Collaborator Author

fdr commented Sep 13, 2023

wait, so it always returns 204? like, when it doesn't exist either, instead of 404?

@enescakir
Copy link
Member

enescakir commented Sep 13, 2023

Random runner ids. It just returns 204

[40] clover-development(main)> client.delete("/repos/enescakir/astrobee/actions/runners/1111111111")
=> ""
[41] clover-development(main)> client.last_response
=> #<Sawyer::Response: 204 @rels={} @data="">

[42] clover-development(main)> client.delete("/repos/enescakir/astrobee/actions/runners/2222222222")
=> ""
[43] clover-development(main)> client.last_response
=> #<Sawyer::Response: 204 @rels={} @data="">

@enescakir
Copy link
Member

enescakir commented Sep 13, 2023

For get request it raises 404 error

[48] clover-development(main)> client.get("/repos/enescakir/astrobee/actions/runners/2222222222")
Octokit::NotFound: GET https://api.github.com/repos/enescakir/astrobee/actions/runners/2222222222: 404 - Not Found // See: https://docs.github.com/rest/actions/self-hosted-runners#get-a-self-hosted-runner-for-a-repository

@fdr
Copy link
Collaborator Author

fdr commented Sep 13, 2023

Well that's silly. I'll add a comment.

@fdr fdr closed this as completed Sep 13, 2023
@fdr
Copy link
Collaborator Author

fdr commented Sep 13, 2023

Well, thinking it over, this this doesn't 100% answer my question...why is 204 so bad? Why not check for it and say this is the success condition?

Random runner_ids produce 404s, this is not unlike random runner_ids producing 204 for DELETE

@fdr fdr reopened this Sep 13, 2023
@fdr
Copy link
Collaborator Author

fdr commented Sep 13, 2023

Normally, the way this works is:

DELETE returns 200-class codes when it does something, and 404 when it doesn't/can't find the resource. Because we are liable to not store the success of DELETE (no 2PC), the implementation ends up being begin; rescue 404 (it's okay); end;.

So, GitHub doesn't pester us with a 404/exception when DELETE is run on a deleted resource. I see no problem with this, in fact...it seems superior. Basically they avoid us having to implement the rescue.

The only reason to subsequently use GET if we don't trust DELETE, that I can see. Which can happen, but I don't think it's evident why we would have this distrust.

It makes me wonder if we should implement it that way.

@fdr fdr self-assigned this Oct 9, 2023
fdr added a commit that referenced this issue Dec 15, 2023
If it is gone, there's no need to halt execution.  This can cause CI
runs to fail, in the case where a key was deleted but, for one reason
or another, the deletion success was not recorded.

Perhaps our API should not inflict a similar damage on the consumer,
see
#597 (comment)
fdr added a commit that referenced this issue Dec 15, 2023
If it is gone, there's no need to halt execution.  This can cause CI
runs to fail, in the case where a key was deleted but, for one reason
or another, the deletion success was not recorded.

Perhaps our API should not inflict a similar damage on the consumer,
see
#597 (comment)
fdr added a commit that referenced this issue Dec 15, 2023
If it is gone, there's no need to halt execution.  This can cause CI
runs to fail, in the case where a key was deleted but, for one reason
or another, the deletion success was not recorded.

Perhaps our API should not inflict a similar damage on the consumer,
see
#597 (comment)
@fdr
Copy link
Collaborator Author

fdr commented Jan 24, 2024

@velioglu the most recent word (from a while ago) on the deletion topic.

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

No branches or pull requests

2 participants