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

fix: check if serverId is set before making requests #103

Merged
merged 1 commit into from
Feb 22, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/usage/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Available Options for the IONOS Cloud Docker Machine Driver:
| `--ionoscloud-template` | Ionos Cloud Template name (CUBES XS, CUBES S, etc.) |
| `--ionoscloud-server-availability-zone` | Ionos Cloud Server Availability Zone \(AUTO, ZONE\_1, ZONE\_2, ZONE\_3\) |
| `--ionoscloud-cores` | Ionos Cloud Server Cores \(2, 3, 4, 5, 6, etc.\) |
| `--ionoscloud-cpu-family` | Ionos Cloud Server CPU families \(AMD\_OPTERON,INTEL\_XEON, INTEL\_SKYLAKE\) |
| `--ionoscloud-cpu-family` | Ionos Cloud Server CPU families \(AMD\_OPTERON,INTEL\_XEON, INTEL\_SKYLAKE\,INTEL\_ICELAKE,AMD\_EPYC) |
| `--ionoscloud-ram` | Ionos Cloud Server Ram in MB \(1024, 2048, 3072, 4096, etc.\) |
| `--ionoscloud-volume-availability-zone` | Ionos Cloud Volume Availability Zone \(AUTO, ZONE\_1, ZONE\_2, ZONE\_3\) |
| `--ionoscloud-cloud-init` | The cloud-init configuration for the volume as multiline text |
Expand Down
4 changes: 2 additions & 2 deletions internal/utils/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,12 @@ func (c *Client) WaitForNicIpChange(datacenterId, serverId, nicId string, timeou
initialIp = (*nicIps)[0]
}

ticker := time.NewTicker(2 * time.Second)
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
start := time.Now()

for range ticker.C {
if time.Since(start) > time.Second*time.Duration(timeout+5) {
if time.Since(start) > time.Second*time.Duration(timeout+15) {
break
}
nic, err = c.GetNic(datacenterId, serverId, nicId)
Expand Down
11 changes: 9 additions & 2 deletions ionoscloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
Name: flagServerCpuFamily,
EnvVar: extflag.KebabCaseToEnvVarCase(flagServerCpuFamily),
Value: defaultCpuFamily,
Usage: "Ionos Cloud Server CPU families (AMD_OPTERON, INTEL_XEON, INTEL_SKYLAKE)",
Usage: "Ionos Cloud Server CPU families (AMD_OPTERON, INTEL_XEON, INTEL_SKYLAKE, INTEL_ICELAKE, AMD_EPYC)",
},
mcnflag.StringFlag{
Name: flagDatacenterId,
Expand Down Expand Up @@ -802,7 +802,11 @@ func (d *Driver) Create() (err error) {
if err != nil {
return fmt.Errorf("error getting server by id: %w", err)
}
d.VolumeId = *(*server.Entities.GetVolumes().Items)[0].GetId()
volumes, ok := server.Entities.GetVolumesOk()
if ok != true {
return fmt.Errorf("error getting server: d.ServerId is empty")
}
d.VolumeId = *(*volumes.Items)[0].GetId()
log.Debugf("Volume ID: %v", d.VolumeId)

// Reserve IP if needed
Expand Down Expand Up @@ -1084,6 +1088,9 @@ func (d *Driver) GetIP() (string, error) {

// GetState returns the state of the machine role instance.
func (d *Driver) GetState() (state.State, error) {
if d.ServerId == "" {
return state.None, fmt.Errorf("error getting server: d.ServerID is empty")
}
server, err := d.client().GetServer(d.DatacenterId, d.ServerId)
if err != nil {
return state.None, fmt.Errorf("error getting server: %w", err)
Expand Down
Loading