-
Notifications
You must be signed in to change notification settings - Fork 4
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
[WIP] Integrate Fleetlock client with Locksmith #14
base: flatcar-master
Are you sure you want to change the base?
[WIP] Integrate Fleetlock client with Locksmith #14
Conversation
c0219aa
to
f712b04
Compare
@tormath1 need little code review 😄 |
@aniruddha2000 hi ! Thanks for your contribution - I see the CI is still failling with the following error:
|
f712b04
to
38395fe
Compare
@tormath1 yes that's true. We have to inspect where is the problem. I think something is not syncing between the |
Seems like i fixed the interface definition :) |
Deamon.go - The set_max.go - semaphore.go - |
@aniruddha2000 thanks for this investigation, this is an awesome job 💪 This commit:
This is a hack introduced in #11 to mitigate side effects from For the Since the FleetLock client needs an ID, we need to port this logic into the |
84bdfce
to
c003348
Compare
@tormath1 we can lock.go#L55 change the |
|
@aniruddha2000 for your information, in the commit Regarding the build error:
Basically, |
ad84eb8
to
a5299d4
Compare
a5299d4
to
ee1ed57
Compare
Transport: transport, | ||
Username: globalFlags.EtcdUsername, | ||
Password: globalFlags.EtcdPassword, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are failing because I can't see any Config
struct implementation in the client package. Do we will be dealing with username and password? If not we can remove or if we want to keep the logic then we need other modification way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see any Config struct implementation in the client package.
It's almost this - actually, to create the fleetlock.Client
, we need four things:
- one URL (the FleetLock service)
- one group
- one ID
- one
net/http.Client
The idea of passing net/http.Client
to the FleetLock client constructor is that we give freedom, in the implementation, to use custom Transport (SSL, etc.) but also any authentication required.
For Fleetlock, there is no dedicated authorization - so for now, we can just keep the transport
to build our net/http.Client
.
Do we will be dealing with username and password? If not we can remove or if we want to keep the logic then we need other modification way
We can keep them but it requires some modification on the fleetlock.Client
to support basic authentication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Then let's implement the basic auth in the fleetlock project side by side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just did: https://github.com/flatcar-linux/fleetlock/compare/tormath1/basic-auth I'll open a PR then let you know when it's done. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR is opened and under review: flatcar/fleetlock#1 - expect some changes in the fleetlock/client.New
:)
locksmithctl/locksmithctl.go
Outdated
return lc, nil | ||
lc, err := lock.NewEtcdLockClient(kapi, globalFlags.Group) | ||
if err != nil { | ||
return nil, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lock package is not here and I think we can remove the NewEtcdLockClient
and implement the https://pkg.go.dev/github.com/flatcar-linux/[email protected]/pkg/client#New instead.
What do you think @tormath1 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the changes I commented, I succeed to compile locksmith
💪 so great work, we will soon be able to make some tests. :)
locksmithctl/locksmithctl.go
Outdated
@@ -183,7 +179,7 @@ func main() { | |||
|
|||
// getLockClient returns an initialized EtcdLockClient, using an etcd | |||
// client configured from the global etcd flags | |||
func getClient() (*lock.EtcdLockClient, error) { | |||
func getClient() (*client.Client, error) { | |||
// copy of github.com/coreos/etcd/client.DefaultTransport so that | |||
// TLSClientConfig can be overridden. | |||
transport := &http.Transport{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be replaced with http.DefaultClient
which was not introduced yet when this lines have been wrote.
This is an example with a copy of the default http client in case the transport
must be overwrittent: https://github.com/flatcar-linux/fleetlock/blob/05e572675abd65352cd200040cb2fe2bf68c37fd/cmd/lock.go#L16-L21
ec3c1cc
to
1ab32ac
Compare
3ffb93e
to
226abd6
Compare
getClient use the global flags and use the http DefaultClient to build the fleetlock client and returns it
hey @aniruddha2000, IIRC the PoC was working fine as we did a demo during a Flatcar Community Call (https://www.youtube.com/watch?v=X_nqgXLOmLk). I could have another round of review but IIRC tests were requiring some work - would you be interested to resume this PR ? Or I can take over if you don't have time to contribute on this :) You already did a great breakthrough, Just let us know ! |
- Remove semaphore.go & semaphore_test.go - Move holder error[ErrExist & ErrNotExist] from semaphore.go to lock.go Signed-off-by: Aniruddha Basak <[email protected]>
@aniruddha2000 overall it looks good. While writing a test for this (flatcar/mantle#336) - I realized we should get this feature smoothly lands into the OS to not break workloads.
With this approach, we could slowly integrate the new feature while preserving the current behavior. What do you think ? |
I don't think introducing something as "experimental" is a good way because it would itself become a standard and people rely on it this way - let's find a good final solution instead from day one. |
Yeah I really like this approach ( |
Does the fleetlock endpoint use HTTP? If so, I'm not sure about using the EDIT: https://coreos.github.io/zincati/development/fleetlock/protocol/ says it uses HTTP. I guess it can also use HTTPS as well then? How would you configure HTTPS when using |
@invidian thanks for jumping in ! The idea behind |
Yeah, I get that and I see how re-using |
One could also use |
Good idea @pothos. So it can be: Do you have some other examples of |
I think there is |
yeah I seen that too in some libvirt documentation: https://libvirt.org/uri.html#remote-uris |
Integrate Fleetlock client with Locksmith
In this PR we are refactoring the Locksmith code base and integrating the Fleetlock client. We are using Go FleetLock HTTP client instead of the etcd lock client.