@@ -38,17 +38,17 @@ import (
3838)
3939
4040const (
41- defaultMachine = "n1-standard-1"
4241 defaultFirewallRule = "default-allow-ssh"
4342
4443 // timestampFormat is the timestamp format used in the e2e directory name.
4544 timestampFormat = "20060102T150405"
4645)
4746
4847type InstanceInfo struct {
49- project string
50- zone string
51- name string
48+ project string
49+ zone string
50+ name string
51+ machineType string
5252
5353 // External IP is filled in after instance creation
5454 externalIP string
@@ -68,18 +68,19 @@ func (i *InstanceInfo) GetNodeID() string {
6868 return common .CreateNodeID (i .project , i .zone , i .name )
6969}
7070
71- func CreateInstanceInfo (project , instanceZone , name string , cs * compute.Service ) (* InstanceInfo , error ) {
71+ func CreateInstanceInfo (project , instanceZone , name , machineType string , cs * compute.Service ) (* InstanceInfo , error ) {
7272 return & InstanceInfo {
73- project : project ,
74- zone : instanceZone ,
75- name : name ,
73+ project : project ,
74+ zone : instanceZone ,
75+ name : name ,
76+ machineType : machineType ,
7677
7778 computeService : cs ,
7879 }, nil
7980}
8081
8182// Provision a gce instance using image
82- func (i * InstanceInfo ) CreateOrGetInstance (serviceAccount string ) error {
83+ func (i * InstanceInfo ) CreateOrGetInstance (imageURL , serviceAccount string ) error {
8384 var err error
8485 var instance * compute.Instance
8586 klog .V (4 ).Infof ("Creating instance: %v" , i .name )
@@ -91,10 +92,9 @@ func (i *InstanceInfo) CreateOrGetInstance(serviceAccount string) error {
9192 return fmt .Errorf ("Failed to create firewall rule: %v" , err )
9293 }
9394
94- imageURL := "projects/debian-cloud/global/images/family/debian-11"
9595 inst := & compute.Instance {
9696 Name : i .name ,
97- MachineType : machineType ( i .zone , "" ),
97+ MachineType : fmt . Sprintf ( "zones/%s/machineTypes/%s" , i .zone , i . machineType ),
9898 NetworkInterfaces : []* compute.NetworkInterface {
9999 {
100100 AccessConfigs : []* compute.AccessConfig {
@@ -215,13 +215,6 @@ func getTimestamp() string {
215215 return fmt .Sprintf (time .Now ().Format (timestampFormat ))
216216}
217217
218- func machineType (zone , machine string ) string {
219- if machine == "" {
220- machine = defaultMachine
221- }
222- return fmt .Sprintf ("zones/%s/machineTypes/%s" , zone , machine )
223- }
224-
225218// Create default SSH filewall rule if it does not exist
226219func (i * InstanceInfo ) createDefaultFirewallRule () error {
227220 var err error
0 commit comments