Skip to content

Commit

Permalink
gcp do not require zone for expiry setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Glonek committed Aug 30, 2024
1 parent da66033 commit 12f7e3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG/7.6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ _Release Date: Month Day, Year_
* GCP: add option to specify minimum CPU platform during cluster and client creation.
* GCP: expiry system updated to use `go122` runtime.
* GCP: support using a single static key for all clusters and clients (must be located in `${AEROLAB_HOME}/sshkey(.pub)`; if it exists, will automatically be used).
* GCP: Do not require zone for instances when setting labels.
* Inventory List: expose gcp/aws/docker tags/labels and metadata in json output.
* Partitioner: when configuring index on device, parse partition tree sprig configs and fix if required.
* Upgrade: added `aerolab upgrade --bugfix` - will upgrade to latest fix version, not bleeding edge version.
Expand Down
13 changes: 7 additions & 6 deletions src/backendGcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ type gcpInstancePricing struct {
type gcpClusterExpiryInstances struct {
labelFingerprint string
labels map[string]string
zone string
}

func (d *backendGcp) GetAZName(subnetId string) (string, error) {
Expand Down Expand Up @@ -440,7 +441,7 @@ func (d *backendGcp) SetLabel(clusterName string, key string, value string, gcpZ
}
for _, jj := range j.Clusters {
if jj.ClusterName == clusterName {
instances[jj.InstanceId] = gcpClusterExpiryInstances{jj.GcpMetadataFingerprint, jj.GcpMeta}
instances[jj.InstanceId] = gcpClusterExpiryInstances{jj.GcpMetadataFingerprint, jj.GcpMeta, jj.Zone}
}
}
} else {
Expand All @@ -451,7 +452,7 @@ func (d *backendGcp) SetLabel(clusterName string, key string, value string, gcpZ
}
for _, jj := range j.Clients {
if jj.ClientName == clusterName {
instances[jj.InstanceId] = gcpClusterExpiryInstances{jj.GcpMetadataFingerprint, jj.GcpMeta}
instances[jj.InstanceId] = gcpClusterExpiryInstances{jj.GcpMetadataFingerprint, jj.GcpMeta, jj.Zone}
}
}
}
Expand All @@ -473,7 +474,7 @@ func (d *backendGcp) SetLabel(clusterName string, key string, value string, gcpZ
_, err = instancesClient.SetMetadata(ctx, &computepb.SetMetadataInstanceRequest{
Instance: iName,
Project: a.opts.Config.Backend.Project,
Zone: gcpZone,
Zone: iMeta.zone,
MetadataResource: &computepb.Metadata{
Fingerprint: proto.String(iMeta.labelFingerprint),
Items: items,
Expand All @@ -497,7 +498,7 @@ func (d *backendGcp) ClusterExpiry(zone string, clusterName string, expiry time.
for _, jj := range j.Clusters {
nodeNo, _ := strconv.Atoi(jj.NodeNo)
if jj.ClusterName == clusterName && (len(nodes) == 0 || inslice.HasInt(nodes, nodeNo)) {
instances[jj.InstanceId] = gcpClusterExpiryInstances{jj.GcpLabelFingerprint, jj.GcpLabels}
instances[jj.InstanceId] = gcpClusterExpiryInstances{jj.GcpLabelFingerprint, jj.GcpLabels, jj.Zone}
}
}
} else {
Expand All @@ -509,7 +510,7 @@ func (d *backendGcp) ClusterExpiry(zone string, clusterName string, expiry time.
for _, jj := range j.Clients {
nodeNo, _ := strconv.Atoi(jj.NodeNo)
if jj.ClientName == clusterName && (len(nodes) == 0 || inslice.HasInt(nodes, nodeNo)) {
instances[jj.InstanceId] = gcpClusterExpiryInstances{jj.GcpLabelFingerprint, jj.GcpLabels}
instances[jj.InstanceId] = gcpClusterExpiryInstances{jj.GcpLabelFingerprint, jj.GcpLabels, jj.Zone}
}
}
}
Expand All @@ -532,7 +533,7 @@ func (d *backendGcp) ClusterExpiry(zone string, clusterName string, expiry time.
newLabels["aerolab4expires"] = newExpiry
_, err = instancesClient.SetLabels(ctx, &computepb.SetLabelsInstanceRequest{
Project: a.opts.Config.Backend.Project,
Zone: zone,
Zone: labelData.zone,
Instance: instanceName,
InstancesSetLabelsRequestResource: &computepb.InstancesSetLabelsRequest{
LabelFingerprint: proto.String(labelData.labelFingerprint),
Expand Down

0 comments on commit 12f7e3a

Please sign in to comment.