Skip to content

Commit

Permalink
fix(HMS-2295): add numeric rid to GCP
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap authored and adiabramovitch committed Aug 9, 2023
1 parent c73f4f4 commit 0a66644
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/clients/http/ec2/ec2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (c *ec2Client) ImportPubkey(ctx context.Context, key *models.Pubkey, tag st
ResourceType: types.ResourceTypeKeyPair,
Tags: []types.Tag{
{
Key: ptr.To("rhhc:id"),
Key: ptr.To("rh-kid"),
Value: ptr.To(tag),
},
},
Expand Down Expand Up @@ -401,7 +401,7 @@ func (c *ec2Client) RunInstances(ctx context.Context, params *clients.AWSInstanc
ResourceType: types.ResourceTypeInstance,
Tags: []types.Tag{
{
Key: ptr.To("rhhc:rid"),
Key: ptr.To("rh-rid"),
Value: ptr.To(config.EnvironmentPrefix("r", strconv.FormatInt(reservation.ID, 10))),
},
},
Expand Down
5 changes: 3 additions & 2 deletions internal/clients/http/gcp/gcp_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ func (c *gcpClient) InsertInstances(ctx context.Context, params *clients.GCPInst
MinCount: &amount,
InstanceProperties: &computepb.InstanceProperties{
Labels: map[string]string{
"rhhcc-rid": params.UUID,
"rh-rid": config.EnvironmentPrefix("r", strconv.FormatInt(params.ReservationID, 10)),
"rh-uuid": params.UUID,
},
Disks: []*computepb.AttachedDisk{
{
Expand Down Expand Up @@ -251,7 +252,7 @@ func (c *gcpClient) ListInstancesIDsByLabel(ctx context.Context, uuid string) ([

logger := logger(ctx)
ids := make([]*string, 0)
filter := fmt.Sprintf("labels.rhhcc-rid=%v", uuid)
filter := fmt.Sprintf("labels.rh-uuid=%v", uuid)
lstReq := &computepb.AggregatedListInstancesRequest{
Project: c.auth.Payload,
Filter: &filter,
Expand Down
3 changes: 3 additions & 0 deletions internal/clients/instance_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type GCPInstanceParams struct {
// InstanceType to launch
MachineType string

// ReservationID contains reservation ID that is stored in GCP label
ReservationID int64

// UUID for instance that was created in a reservation
UUID string

Expand Down
2 changes: 1 addition & 1 deletion internal/clients/stubs/ec2_stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (mock *EC2ClientStub) ImportPubkey(ctx context.Context, key *models.Pubkey,
KeyPairId: &ec2KeyID,
PublicKey: &key.Body,
Tags: []types.Tag{{
Key: ptr.To("rhhc:id"),
Key: ptr.To("rh-kid"),
Value: &tag,
}},
}
Expand Down
1 change: 1 addition & 0 deletions internal/jobs/launch_instance_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func DoLaunchInstanceGCP(ctx context.Context, args *LaunchInstanceGCPTaskArgs) e
Zone: args.Zone,
KeyBody: pk.Body,
StartupScript: string(userData),
ReservationID: args.ReservationID,
UUID: args.Detail.UUID,
LaunchTemplateID: args.LaunchTemplateID,
}
Expand Down

0 comments on commit 0a66644

Please sign in to comment.