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

Add TeamCity metadata to that of an Instance Template #29

Merged

Conversation

mohsenrezaeithe
Copy link
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
Contributor Author

@mohsenrezaeithe mohsenrezaeithe commented Sep 19, 2019

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
Contributor Author

@mohsenrezaeithe mohsenrezaeithe commented Sep 30, 2019

@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
Contributor

@dimyriy dimyriy left a comment

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

@mohsenrezaeithe
Copy link
Contributor Author

@mohsenrezaeithe mohsenrezaeithe commented Oct 9, 2019

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

@mohsenrezaeithe mohsenrezaeithe requested a review from dimyriy Oct 9, 2019
@dimyriy dimyriy merged commit 7afebf0 into JetBrains:master Oct 15, 2019
@dimyriy
Copy link
Contributor

@dimyriy dimyriy commented Oct 15, 2019

Thank you for contributing!

@mohsenrezaeithe mohsenrezaeithe deleted the concat_instance_template_metadata branch Oct 15, 2019
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.

None yet

2 participants