-
Notifications
You must be signed in to change notification settings - Fork 828
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
Update client-go to support Kubernetes 1.18.0 #1998
Merged
markmandel
merged 5 commits into
googleforgames:main
from
markmandel:upgrade/client-go-1.18.x
Feb 25, 2021
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
94fcd5b
Update vendored client-go to support Kubernets 1.18.0
markmandel 68ad15b
Updated CRD clients to support Kubernetes 1.18.0
markmandel 82b545d
Updates to e2e tests to comply with client-go changes
markmandel 919e46a
Context handling to align with client-go 0.18.x
markmandel 6f2aa50
CI failure fixes:
markmandel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net" | ||
"net/http" | ||
|
@@ -37,7 +38,6 @@ import ( | |
"github.com/spf13/pflag" | ||
"github.com/spf13/viper" | ||
"github.com/tmc/grpc-websocket-proxy/wsproxy" | ||
"golang.org/x/net/context" | ||
"google.golang.org/grpc" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
|
@@ -77,8 +77,7 @@ func main() { | |
time.Sleep(time.Duration(ctlConf.Delay) * time.Second) | ||
} | ||
|
||
stop := signals.NewStopChannel() | ||
timedStop := make(chan struct{}) | ||
ctx := signals.NewSigKillContext() | ||
grpcServer := grpc.NewServer() | ||
// don't graceful stop, because if we get a kill signal | ||
// then the gameserver is being shut down, and we no longer | ||
|
@@ -91,8 +90,6 @@ func main() { | |
Handler: wsproxy.WebsocketProxy(mux), | ||
} | ||
defer httpServer.Close() // nolint: errcheck | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
defer cancel() | ||
|
||
switch { | ||
case ctlConf.IsLocal: | ||
|
@@ -103,10 +100,8 @@ func main() { | |
defer cancel() | ||
|
||
if ctlConf.Timeout != 0 { | ||
go func() { | ||
time.Sleep(time.Duration(ctlConf.Timeout) * time.Second) | ||
close(timedStop) | ||
}() | ||
ctx, cancel = context.WithTimeout(ctx, time.Duration(ctlConf.Timeout)*time.Second) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I liked this one too 😄 |
||
defer cancel() | ||
} | ||
case ctlConf.Test != "": | ||
cancel, err := registerTestSdkServer(grpcServer, ctlConf) | ||
|
@@ -116,10 +111,8 @@ func main() { | |
defer cancel() | ||
|
||
if ctlConf.Timeout != 0 { | ||
go func() { | ||
time.Sleep(time.Duration(ctlConf.Timeout) * time.Second) | ||
close(timedStop) | ||
}() | ||
ctx, cancel = context.WithTimeout(ctx, time.Duration(ctlConf.Timeout)*time.Second) | ||
defer cancel() | ||
} | ||
default: | ||
var config *rest.Config | ||
|
@@ -148,7 +141,7 @@ func main() { | |
} | ||
|
||
go func() { | ||
err := s.Run(ctx.Done()) | ||
err := s.Run(ctx) | ||
if err != nil { | ||
logger.WithError(err).Fatalf("Could not run sidecar") | ||
} | ||
|
@@ -162,11 +155,7 @@ func main() { | |
go runGrpc(grpcServer, grpcEndpoint) | ||
go runGateway(ctx, grpcEndpoint, mux, httpServer) | ||
|
||
select { | ||
case <-stop: | ||
case <-timedStop: | ||
} | ||
|
||
<-ctx.Done() | ||
logger.Info("shutting down sdk server") | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
ctx.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.
Because the allocator has to go all the way down to client-go to allocate a GameServer, we have to pass the ctx all the way through.
And it also means the API for all systems is the same all the way through.
It's also possible that
allocation.Start(...)
should be changed toallocation.Run(...)
to match all the other modules in Agones, hence the weirdness in the API surface, so I totally get the comment.