Below is a simple for loop that reproduces the errors. What's baffling is that lines 5 & 7 sometimes fail, and sometimes are successful, seemingly randomly. The stack traces sometimes reference a 400/Bad Request status code, and sometimes 403/Forbidden status code. For brevity, I didn't include the rest of the lengthy code, and since it sometimes works, this seems to be a serious bug and/or poor error responses with the GCE Java API (com.google.cloud.compute.v1) - Anyone ever experience this or have any ideas why GCE Java API sometimes/randomly fails?
for(int i = 0; i < 10; i++) {
GameServer gs = null;
if((gs = GCPTools.getActiveGameServer(40, 5)) != null) {
System.out.println("Found an active game server:" + gs);
} else if((gs = GCPTools.startAGameServer()) != null) {//no running server available so try to start an existing one
System.out.println("Started an available game server:" + gs);
} else if((gs = GCPTools.createANewGameServer("projects/myProject/global/machineImages/i5-game-server-mi-015")) != null) {//no available game servers so create and start a new one
System.out.println("Created a game server:" + gs);
}
}
Hello tazelee,
Welcome to GCC!
Since this is happening randomly, it would be best to be in touch with the Cloud Platform Support so they can further inspect your project.