Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Add new endpoint for joining a cluster#61

Closed
mbarnes wants to merge 1 commit intoprojectatomic:masterfrom
mbarnes:cluster-join
Closed

Add new endpoint for joining a cluster#61
mbarnes wants to merge 1 commit intoprojectatomic:masterfrom
mbarnes:cluster-join

Conversation

@mbarnes
Copy link
Contributor

@mbarnes mbarnes commented Mar 15, 2016

This was an idea I had to help with the host auto-join feature.

Programmatically determining a host's own IP address to send to the Commissaire server can be non-trivial given the possibility of multiple network devices. And even if you know the right device name, parsing it out from ip address or ifconfig is still a pain.

This helps alleviate the problem by offering a convenient endpoint for hosts to add themselves directly to a cluster.

_Update:_ After further discussion the endpoint was changed to /api/v0/host.

Endpoint: /api/v0/cluster/{NAME}/join

Accepts a PUT request from the host wishing to join cluster {NAME}.

This is equivalent to:

   PUT /api/v0/host/{ADDRESS}

   {
      cluster: {NAME}
      ...
   }

except the host's {ADDRESS} is derived from the request itself.

@mbarnes
Copy link
Contributor Author

mbarnes commented Mar 15, 2016

@cgwalters-bot r+ e5edbdb

@cgwalters-bot
Copy link

🙀 e5edbdb is not a valid commit SHA. Please try again with da7a878.

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

The idea of using the requesting address makes a lot of sense. Though why not update the current host endpoint instead of creating a new one?

@cgwalters
Copy link
Member

@cgwalters-bot retry

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

@cgwalters-bot r+ da7a878

@cgwalters-bot
Copy link

⌛ Trying commit da7a878 with merge dfdc590...

cgwalters-bot pushed a commit that referenced this pull request Mar 16, 2016
Captures most of the host PUT handler logic for host creation.

Pull request: #61
Approved by: <try>
cgwalters-bot pushed a commit that referenced this pull request Mar 16, 2016
Endpoint: /api/v0/cluster/{NAME}/join

Accepts a PUT request from the host wishing to join cluster {NAME}.

This is equivalent to:

    PUT /api/v0/host/{ADDRESS}

    {
        cluster: {NAME}
        ...
    }

except the host's {ADDRESS} is derived from the request itself.

This is intended to aid host initialization, since determining one's
own IP address programmatically can be non-trivial.

The PUT response body will include the host's IP address.

Pull request: #61
Approved by: <try>
@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

@cgwalters-bot
Copy link

💡 This pull request was already approved, no need to approve it again.

  • This pull request is currently being tested. If there's no response from the continuous integration service, you may use retry to trigger a build again.

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

Messing with the bot a bit here to see what happens 😄

@cgwalters-bot clean

@mbarnes
Copy link
Contributor Author

mbarnes commented Mar 16, 2016

The idea of using the requesting address makes a lot of sense. Though why not update the current host endpoint instead of creating a new one?

Maybe I misunderstand what you mean, but the host endpoint URL embeds the host's IP address, which defeats the purpose here. I'm trying to avoid forcing the host to know its own IP address before automatically registering itself to Commissaire.

Using the endpoint of the cluster it wants to join seemed the most straight-forward.

I'm open to other ideas though.

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

@mbarnes I see what you mean. Since the GET will always required a name it would be awkward.

What about having a PUT/POST /api/v0/host/ endpoint that takes the current data /api/v0/host/{IP} takes sans the IP in the URL. The resulting instance would be available at /api/v0/host/{IP} and we can change /api/v0/host/{IP} to be GET/`DELETE`` only.

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

@cgwalters-bot clean

@ashcrow ashcrow closed this Mar 16, 2016
@ashcrow ashcrow reopened this Mar 16, 2016
@cgwalters
Copy link
Member

Hmm...I'd have expected "clean" to work. Let me debug.

@cgwalters
Copy link
Member

Oh although, I bet this needs to be rebased on master so we have the webhook in the PR series.

@mbarnes
Copy link
Contributor Author

mbarnes commented Mar 16, 2016

@ashcrow: I was with you until that last bit:

and we can change /api/v0/host/{IP} to be GET/DELETE only

Wouldn't that impose a new requirement that a host creation request has to come from the host itself? Unless that was always the intention, I think we'd want to keep both ways for the sake of administrators.

If you still prefer a PUT on /api/v0/host I can rework it.

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

@mbarnes good point. Scratch the last bit. Yeah throw it on /api/v0/host/ and I think this will be nice and clean.

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

@mbarnes mind rebasing to see if that makes homu happier?

@cgwalters
Copy link
Member

@ashcrow You'll need to re-r+ with new commit ID of d3fa8b5

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 16, 2016

@cgwalters-bot r+ d3fa8b5

cgwalters-bot pushed a commit that referenced this pull request Mar 16, 2016
Captures most of the host PUT handler logic for host creation.

Pull request: #61
Approved by: ashcrow
cgwalters-bot pushed a commit that referenced this pull request Mar 16, 2016
Endpoint: /api/v0/cluster/{NAME}/join

Accepts a PUT request from the host wishing to join cluster {NAME}.

This is equivalent to:

    PUT /api/v0/host/{ADDRESS}

    {
        cluster: {NAME}
        ...
    }

except the host's {ADDRESS} is derived from the request itself.

This is intended to aid host initialization, since determining one's
own IP address programmatically can be non-trivial.

The PUT response body will include the host's IP address.

Pull request: #61
Approved by: ashcrow
@cgwalters-bot
Copy link

⌛ Testing commit d3fa8b5 with merge b657aa6...

@cgwalters-bot
Copy link

☀️ Test successful - travis

@mbarnes
Copy link
Contributor Author

mbarnes commented Mar 16, 2016

Why was this PR closed?

@mbarnes mbarnes reopened this Mar 16, 2016
@cgwalters
Copy link
Member

It was closed because it was merged...sorry I know it's a bit confusing right now. See barosl/homu#139

Endpoint: /api/v0/host

Accepts a PUT request from the host wishing to add itself. The host
IP address is inferred from the request itself, but otherwise works
exactly like "PUT /api/v0/host/{ADDRESS}".

This is intended to aid host initialization, since determining one's
own IP address programmatically can be non-trivial.
@mbarnes
Copy link
Contributor Author

mbarnes commented Mar 16, 2016

This accidentally got merged to master prematurely, so here's what I did for the rework.

  • Left the 1st commit (projectatomic/commissaire@4969962) merged since it was just a util function and didn't need changed. If there's corrections to be made there I'll do so in a new commit.
  • Reverted the 2nd commit on master and rebased this branch on it.
  • Added ⬆️ for the /api/v0/host endpoint as discussed.

For the endpoint docs I just added a note to the host creation part. This is kind of a special case so it didn't seem worth a whole new section to me.

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 17, 2016

@cgwalters-bot try

@cgwalters
Copy link
Member

@ashcrow I think that may currently not do anything because the PR already passed? Ah yes, look at:

def process_queue(...):
    for repo_label, repo in repos.items():
        for state in repo_states:
            if state.status == '' and state.try_:
                if start_build(state, repo_cfgs, buildbot_slots, logger, db, git_cfg):
                    return

Since status != '' we don't try the merge build. I'd say that's a conceptual bug - Homu should support it.

@ashcrow
Copy link
Collaborator

ashcrow commented Mar 17, 2016

@cgwalters ah ok.

@cgwalters-bot r+ 71d9049

@cgwalters-bot
Copy link

💡 This pull request was already approved, no need to approve it again.

@cgwalters-bot
Copy link

⌛ Testing commit 71d9049 with merge 8bb60d0...

cgwalters-bot pushed a commit that referenced this pull request Mar 17, 2016
Endpoint: /api/v0/host

Accepts a PUT request from the host wishing to add itself. The host
IP address is inferred from the request itself, but otherwise works
exactly like "PUT /api/v0/host/{ADDRESS}".

This is intended to aid host initialization, since determining one's
own IP address programmatically can be non-trivial.

Pull request: #61
Approved by: ashcrow
@cgwalters-bot
Copy link

☀️ Test successful - travis

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants