@@ -38,17 +38,17 @@ import (
38
38
)
39
39
40
40
const (
41
- defaultMachine = "n1-standard-1"
42
41
defaultFirewallRule = "default-allow-ssh"
43
42
44
43
// timestampFormat is the timestamp format used in the e2e directory name.
45
44
timestampFormat = "20060102T150405"
46
45
)
47
46
48
47
type InstanceInfo struct {
49
- project string
50
- zone string
51
- name string
48
+ project string
49
+ zone string
50
+ name string
51
+ machineType string
52
52
53
53
// External IP is filled in after instance creation
54
54
externalIP string
@@ -68,18 +68,19 @@ func (i *InstanceInfo) GetNodeID() string {
68
68
return common .CreateNodeID (i .project , i .zone , i .name )
69
69
}
70
70
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 ) {
72
72
return & InstanceInfo {
73
- project : project ,
74
- zone : instanceZone ,
75
- name : name ,
73
+ project : project ,
74
+ zone : instanceZone ,
75
+ name : name ,
76
+ machineType : machineType ,
76
77
77
78
computeService : cs ,
78
79
}, nil
79
80
}
80
81
81
82
// Provision a gce instance using image
82
- func (i * InstanceInfo ) CreateOrGetInstance (serviceAccount string ) error {
83
+ func (i * InstanceInfo ) CreateOrGetInstance (imageURL , serviceAccount string ) error {
83
84
var err error
84
85
var instance * compute.Instance
85
86
klog .V (4 ).Infof ("Creating instance: %v" , i .name )
@@ -91,10 +92,9 @@ func (i *InstanceInfo) CreateOrGetInstance(serviceAccount string) error {
91
92
return fmt .Errorf ("Failed to create firewall rule: %v" , err )
92
93
}
93
94
94
- imageURL := "projects/debian-cloud/global/images/family/debian-11"
95
95
inst := & compute.Instance {
96
96
Name : i .name ,
97
- MachineType : machineType ( i .zone , "" ),
97
+ MachineType : fmt . Sprintf ( "zones/%s/machineTypes/%s" , i .zone , i . machineType ),
98
98
NetworkInterfaces : []* compute.NetworkInterface {
99
99
{
100
100
AccessConfigs : []* compute.AccessConfig {
@@ -215,13 +215,6 @@ func getTimestamp() string {
215
215
return fmt .Sprintf (time .Now ().Format (timestampFormat ))
216
216
}
217
217
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
-
225
218
// Create default SSH filewall rule if it does not exist
226
219
func (i * InstanceInfo ) createDefaultFirewallRule () error {
227
220
var err error
0 commit comments