Open davidhiebert opened 4 years ago
Hi @davidhiebert, what is the configuration you're using?
{
"allow_personal_builds" = true
"artifact_paths" = [
"+:*.json => /config/*.json",
]
"build_counter" = 0
"build_number_format" = "%build.counter%"
"concurrent_limit" = 10
"configuration_type" = "REGULAR"
"detect_hanging" = true
"status_widget" = false
}
Is this your configuration source?
If yes, would you mind omitting build_counter
altogether to see if this flapping behaviour still persists?
There is some special treatment for that field.
Omitting build_counter attempts to reset to 0.
On Wed, Jul 15, 2020, 2:01 PM Carlos Vitor Barros notifications@github.com wrote:
Hi @davidhiebert https://github.com/davidhiebert, what is the configuration you're using?
{ "allow_personal_builds" = true "artifact_paths" = [ "+:.json => /config/.json", ] "build_counter" = 0 "build_number_format" = "%build.counter%" "concurrent_limit" = 10 "configuration_type" = "REGULAR" "detect_hanging" = true "status_widget" = false }
Is this your configuration source? If yes, would you mind omitting build_counter altogether to see if this flapping behaviour still persists? There is some special treatment for that field.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cvbarros/terraform-provider-teamcity/issues/94#issuecomment-659007783, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUBFEPST3GCWKACUAXQ42DR3YKLFANCNFSM4O2Z3PYA .
Would you mind sharing the source configuration, and if possible, inspecting the state on the affected resource?
I think terraform show teamcity_build_config.operator_station_rtc["api"]
would do the trick.
My guess here is that the build_counter
is somehow in the state and it's affecting its tracking
operator_station_rtc
was an artifact from my initial resource definition, and has been changed to build_config, as I'm not using for_each on multiple resources. Reduced to just the one element for clarity.
variable "web_artifact_builds" {
type = map
default = {
api = {
core_name = "web_core"
}
}
}
variable "web_repos" {
type = map
default = {
api = {
url = "obfuscated"
default_branch = "develop"
}
}
}
resource "teamcity_vcs_root_git" "vcsroot" {
for_each = var.web_repos
name = each.key
project_id = teamcity_project.projects["web_artifacts"].id
fetch_url = each.value["url"]
default_branch = lookup(each.value, "default_branch", "develop")
branches = [
"+:refs/tags/*",
"+:refs/heads/*",
]
enable_branch_spec_tags = true
username_style = "userid"
submodule_checkout = "ignore"
# Auth block configures the authentication to Git VCS
auth {
type = "ssh"
ssh_type = "uploadedKey"
key_spec = lookup(each.value, "key_name", "Default Key")
}
# Configure agent settings
agent {
git_path = "/usr/bin/git"
clean_policy = "branch_change"
clean_files_policy = "untracked"
use_mirrors = true
}
}
resource "teamcity_build_config" "build_config" {
for_each = var.web_artifact_builds
name = each.key
description = "Configuration to showcase build configuration settings"
project_id = teamcity_project.projects["web_artifacts"].id
settings {
# Type of build configuration: "regular" (default), "composite" or "deployment"
configuration_type = "REGULAR"
build_number_format = "%build.counter%"
# build_counter = 1
allow_personal_builds = true
artifact_paths = ["+:*.ecr"]
detect_hanging = true
status_widget = false
concurrent_limit = 10
}
vcs_root {
id = teamcity_vcs_root_git.vcsroot[each.key].id
}
env_params = {
vcs_core_version = "develop"
vcs_version = "develop"
}
step {
...
}
}
$ terraform state show 'teamcity_build_config.build_config["api"]'
# teamcity_build_config.build_config["api"]:
resource "teamcity_build_config" "build_config" {
description = "Configuration to showcase build configuration settings"
env_params = {
"vcs_core_version" = "develop"
"vcs_version" = "develop"
}
id = "WebArtifacts_Api"
is_template = false
name = "api"
project_id = "WebArtifacts"
settings = [
{
allow_personal_builds = true
artifact_paths = [
"+:*.ecr",
]
build_counter = 0
build_number_format = "%build.counter%"
concurrent_limit = 10
configuration_type = "REGULAR"
detect_hanging = true
status_widget = false
},
]
templates = []
step {
...
}
step {
...
}
step {
...
}
step {
...
}
}
Another resource in the for_each loop after a single build produces this abbreviated output during a terraform apply
(following a TeamCity build of that build_config):
# teamcity_build_config.build_config["dash"] will be updated in-place
~ resource "teamcity_build_config" "build_config" {
description = "Configuration to showcase build configuration settings"
env_params = {
"vcs_core_version" = "develop"
"vcs_version" = "develop"
}
id = "WebArtifacts_Dash"
is_template = false
name = "dash"
project_id = "WebArtifacts"
~ settings = [
- {
- allow_personal_builds = true
- artifact_paths = [
- "+:*.ecr",
]
- build_counter = 1
- build_number_format = "%build.counter%"
- concurrent_limit = 10
- configuration_type = "REGULAR"
- detect_hanging = true
- status_widget = false
},
{
allow_personal_builds = true
artifact_paths = [
"+:*.ecr",
]
build_counter = (known after apply)
build_number_format = "%build.counter%"
concurrent_limit = 10
configuration_type = "REGULAR"
detect_hanging = true
status_widget = false
},
]
templates = []
@davidhiebert I still wasn't able to reproduce the problem. Due to the special treatment for build_counter
, indeed there may be a nasty bug there.
Would be great if you could put together some minimal configuration in isolated state that could hint me on how to reproduce it locally so I can start working on a test case to pin it down.
Expected behavior
Terraform is applied, creating build configs. Builds occur periodically in TeamCity, incrementing build_counter. Consecutive
terraform apply
executions should not reset the build counter.Actual behavior
Consecutive
terraform apply
executions attempt to reset the resource.Attempted workaround
Tried to add the following to the resource...
however
settings
does not have any indexes, despite the output: