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

Change webserver binary to be usable in large clusters. #27125

Merged
merged 1 commit into from
Jun 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/images/network-tester/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

TAG = 1.8
TAG = 1.9
PREFIX = gcr.io/google_containers

all: push
Expand Down
27 changes: 23 additions & 4 deletions test/images/network-tester/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"syscall"
"time"

"k8s.io/kubernetes/pkg/client/restclient"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/util/sets"
)
Expand Down Expand Up @@ -214,9 +215,27 @@ func main() {

// Find all sibling pods in the service and post to their /write handler.
func contactOthers(state *State) {
const waitTimeout = 5 * time.Minute
sleepTime := 5 * time.Second
// In large cluster getting all endpoints is pretty expensive.
// Thus, we will limit ourselves to send on average at most 10 such
// requests per second
if sleepTime < time.Duration(*peerCount/10)*time.Second {
sleepTime = time.Duration(*peerCount/10) * time.Second
}
timeout := 5 * time.Minute
// Similarly we need to bump timeout so that it is reasonable in large
// clusters.
if timeout < time.Duration(*peerCount)*time.Second {
timeout = time.Duration(*peerCount) * time.Second
}
defer state.doneContactingPeers()
client, err := client.NewInCluster()

config, err := restclient.InClusterConfig()
if err != nil {
log.Fatalf("Unable to create config; error: %v\n", err)
}
config.ContentType = "application/vnd.kubernetes.protobuf"
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to always test protobufs? Can't we just depend on the test flag (for which we can change the default at some point)?

Copy link
Member Author

Choose a reason for hiding this comment

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

We already switched on protobuf by default in k8s components. We can simply switch it on here too.

client, err := client.New(config)
if err != nil {
log.Fatalf("Unable to create client; error: %v\n", err)
}
Expand All @@ -227,7 +246,7 @@ func contactOthers(state *State) {
log.Printf("Server version: %#v\n", v)
}

for start := time.Now(); time.Since(start) < waitTimeout; time.Sleep(5 * time.Second) {
for start := time.Now(); time.Since(start) < timeout; time.Sleep(sleepTime) {
eps := getWebserverEndpoints(client)
if eps.Len() >= *peerCount {
break
Expand All @@ -243,7 +262,7 @@ func contactOthers(state *State) {
state.Logf("Attempting to contact %s", ep)
contactSingle(ep, state)
}
time.Sleep(5 * time.Second)
time.Sleep(sleepTime)
}
}

Expand Down