Skip to content

Add TeamCity metadata to that of an Instance Template#29

Merged
undimmable merged 3 commits into
JetBrains:masterfrom
mohsenrezaeithe:concat_instance_template_metadata
Oct 15, 2019
Merged

Add TeamCity metadata to that of an Instance Template#29
undimmable merged 3 commits into
JetBrains:masterfrom
mohsenrezaeithe:concat_instance_template_metadata

Conversation

@mohsenrezaeithe
Copy link
Copy Markdown
Contributor

@mohsenrezaeithe mohsenrezaeithe commented Sep 14, 2019

This fixes https://youtrack.jetbrains.com/issue/TW-61898

Prior to the change the getInstanceBuilder was overwriting the Instance Template's Custom metadata with the setMetadata action.

This change pulls the configured Instance Template's information from GCP and adds the existing metadata to the custom TeamCity server ones before setting it for the new instance. In addition, a new method, getInstanceBuilder, also avoids overwriting the Availability policies in the newly created instance as well (values are inherited from the Instance Template).

All changes are tested in a staging environment with simulated workload.

updated properties log to use the base class for using toString()
removed metadata details from log in case of sensitive info
@mohsenrezaeithe mohsenrezaeithe changed the title Add TeamCity metadata to existing ones in a Instance Template Add TeamCity metadata to that of an Instance Template Sep 17, 2019
@mohsenrezaeithe
Copy link
Copy Markdown
Contributor Author

Here are some testing logs from the metadata capture:

[2019-09-16 21:45:04,607]   INFO [atcher-worker-1] - nnector.GoogleApiConnectorImpl - GCP get Instance Template: mythic-crane-708/global/instanceTemplates/teamcity-agent-poc-stg2-1567103841
[2019-09-16 21:45:04,740]   INFO [atcher-worker-1] - nnector.GoogleApiConnectorImpl - GCP Instance Template: com.google.cloud.compute.v1.InstanceTemplate$Builder@40ff690
[2019-09-16 21:45:04,740]   INFO [atcher-worker-1] - nnector.GoogleApiConnectorImpl - Instance Template properties captured from GCP: InstanceProperties{canIpForward=false, description=null, disks=[AttachedDisk{autoDelete=true, boot=true, deviceName=teamcity-agent-poc-stg2-1567103841, diskEncryptionKey=..., guestOsFeatures=null, index=0, initializeParams=AttachedDiskInitializeParams{description=null, diskName=null, diskSizeGb=300, diskType=pd-standard, labels=null, sourceImage=projects/..., sourceImageEncryptionKey=...}, interface2=null, kind=compute#attachedDisk, licenses=null, mode=READ_WRITE, source=null, type=PERSISTENT}], guestAccelerators=null, labels=null, machineType=n1-standard-4, metadata=Metadata{fingerprint=..., items=[Items{key=ENVIRONMENT_NAME, value=poc}, ...}, Items{key=startup-script, value=...}], kind=compute#metadata}, minCpuPlatform=null, networkInterfaces=[NetworkInterface{accessConfigs=null, aliasIpRanges=null, fingerprint=..., kind=compute#networkInterface, name=null, network=https://www.googleapis.com/compute/v1/projects/..., networkIP=null, subnetwork=https://www.googleapis.com/compute/v1/...}], scheduling=Scheduling{automaticRestart=true, nodeAffinities=null, onHostMaintenance=MIGRATE, preemptible=false}, serviceAccounts=[ServiceAccount{email=..., scopes=[...]}], tags=Tags{..., items=[...teamcity-agent]}}
[2019-09-16 21:45:04,745]   INFO [atcher-worker-1] - nnector.GoogleApiConnectorImpl - Creating an instance builder from merged metadata
[2019-09-16 21:45:04,747]   INFO [atcher-worker-1] - nnector.GoogleApiConnectorImpl - Creating instance from Instance Template: teamcity-agent-poc-stg2-1567103841

@mohsenrezaeithe
Copy link
Copy Markdown
Contributor Author

@dimyriy @dmitry-treskunov have you had a chance to take a look at the changes? I've been running this live for a couple of weeks now with no issues, and I'd like to weigh the possibility of pulling this to the master.

Copy link
Copy Markdown
Contributor

@undimmable undimmable left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mohsenrezaeithe, thank you for contributing! The pull request looks good to be merged into master overall except the comment about logging.

@mohsenrezaeithe
Copy link
Copy Markdown
Contributor Author

@dimyriy thanks for reviewing! Good feedback, log details are removed.

@undimmable undimmable merged commit 7afebf0 into JetBrains:master Oct 15, 2019
@undimmable
Copy link
Copy Markdown
Contributor

Thank you for contributing!

@mohsenrezaeithe mohsenrezaeithe deleted the concat_instance_template_metadata branch October 15, 2019 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants