jfrog / terraform-provider-artifactory

Terraform provider to manage JFrog Artifactory
https://jfrog.com/artifactory
Apache License 2.0
279 stars 106 forks source link

Repository provider retruning `HTTP response status 404` error when resources exist #1140

Open Osazz opened 5 days ago

Osazz commented 5 days ago

Describe the bug I have a docker remote and virtual repository been managed by Terraform. (resource has been created).

Time to modify something as easy as the description and Terraform is retuning a HTTP response status 404:Failed to execute add project resource with error Could not find project error.

This behaviour is confirmed for both remote and virtual docker repository and Conan remote repository

Even though terraform failed, modification was still applied in the artifactory

Version Information

Artifactory: 7.101.2 Terraform : 1.9.8 Terraform provider Version: 12.5.1

terraform {
  # Restrict this module to require Terraform 1.5 or higher
  required_version = ">= 1.5"

  required_providers {
    artifactory = {
      source  = "jfrog/artifactory"
      version = "~> 12.0"
    }
  }
}

resource "artifactory_remote_docker_repository" "repository" {
  description                       = "Amazon ECR Public Gallery test"
  key                 = "aws-ecr-registry-delete-me"
  url                      = "https://gallery.ecr.aws"
  assumed_offline_period_secs     = 300
  metadata_retrieval_timeout_secs = 60
  missed_cache_period_seconds     = 1800
  retrieval_cache_period_seconds  = 7200
  property_sets                   = ["artifactory"]
}

Terraform Error

artifactory_remote_conan_repository.repository[0]: Modifying... [id=deleteme-conan-remote]
╷
│ Error: {
│   "errors" : [ {
│     "status" : 400,
│     "message" : "HTTP response status 404:Failed to execute add project resource with error Could not find project ``"
│   } ]
│ }
│
│   with artifactory_remote_conan_repository.repository[0],
│   on main.tf line 45, in resource "artifactory_remote_conan_repository" "repository":
│   45: resource "artifactory_remote_conan_repository" "repository" {
│
╵

More Debug log maybe this will be helpful

More Debug Log ```log 2024-11-28T11:40:10.968-0400 [WARN] Provider "registry.terraform.io/jfrog/artifactory" produced an invalid plan for artifactory_remote_docker_repository.repository[0], but we are tolerating it because it is using the legacy plugin SDK. The following problems may be the cause of any confusing errors from downstream operations: - .cdn_redirect: planned value cty.False for a non-computed attribute - .priority_resolution: planned value cty.False for a non-computed attribute - .download_direct: planned value cty.False for a non-computed attribute - .query_params: planned value cty.StringVal("") for a non-computed attribute - .notes: planned value cty.StringVal("") for a non-computed attribute - .bypass_head_requests: planned value cty.False for a non-computed attribute - .curated: planned value cty.False for a non-computed attribute - .local_address: planned value cty.StringVal("") for a non-computed attribute - .disable_proxy: planned value cty.False for a non-computed attribute - .disable_url_normalization: planned value cty.False for a non-computed attribute - .enable_cookie_management: planned value cty.False for a non-computed attribute - .store_artifacts_locally: planned value cty.True for a non-computed attribute - .hard_fail: planned value cty.False for a non-computed attribute - .project_id: planned value cty.StringVal("") for a non-computed attribute - .username: planned value cty.StringVal("") for a non-computed attribute - .allow_any_host_auth: planned value cty.False for a non-computed attribute - .archive_browsing_enabled: planned value cty.False for a non-computed attribute - .proxy: planned value cty.StringVal("") for a non-computed attribute - .socket_timeout_millis: planned value cty.NumberIntVal(15000) for a non-computed attribute - .blacked_out: planned value cty.False for a non-computed attribute - .includes_pattern: planned value cty.StringVal("**/*") for a non-computed attribute - .mismatching_mime_types_override_list: planned value cty.StringVal("") for a non-computed attribute - .project_key: planned value cty.StringVal("") for a non-computed attribute - .remote_repo_layout_ref: planned value cty.StringVal("") for a non-computed attribute - .content_synchronisation: block count in plan (1) disagrees with count in config (0) artifactory_remote_docker_repository.repository[0]: Modifying... [id=aws-ecr-registry-delete-me] 2024-11-28T11:40:10.968-0400 [INFO] Starting apply for artifactory_remote_docker_repository.repository[0] 2024-11-28T11:40:10.968-0400 [DEBUG] artifactory_remote_docker_repository.repository[0]: applying the planned Update change 2024-11-28T11:40:10.996-0400 [WARN] unexpected data: registry.terraform.io/jfrog/artifactory:stderr= | 2024/11/28 11:40:10.996637 DEBUG RESTY | ============================================================================== | ~~~ REQUEST ~~~ | POST /artifactory/api/system/usage HTTP/1.1 | HOST : priv.jfrog.io | HEADERS: | \tAccept: */* | \tAuthorization: | \tContent-Type: application/json | \tUser-Agent: jfrog/terraform-provider-artifactory/12.5.1 | BODY : | { | "productId": "terraform-provider-artifactory/12.5.1", | "features": [ | { | "featureId": "Partner/ACC-007450" | }, | { | "featureId": "Terraform/1.9.8" | } | ] | } | | ------------------------------------------------------------------------------ | ~~~ RESPONSE ~~~ | STATUS : 200 | PROTO : HTTP/1.1 | RECEIVED AT : 2024-11-28T11:40:10.996623-04:00 | TIME DURATION: 42.382208ms | HEADERS : | \tConnection: keep-alive | \tContent-Length: 0 | \tDate: Thu, 28 Nov 2024 15:40:11 GMT | \tStrict-Transport-Security: max-age=31536000; includeSubDomains | \tX-Artifactory-Id: eccbaac55cf86c6eafbb2f82e5782725ac7d6dab | \tX-Artifactory-Node-Id: privtr 2024-11-28T11:40:10.996-0400 [WARN] unexpected data: registry.terraform.io/jfrog/artifactory:stderr= | ust-artifactory-primary-0 | \tX-Jfrog-Version: Artifactory/7.101.2 710102900 | \tX-Request-Id: 5fa072a20ea3fcd8bdd1de366a6d84c0 | BODY : | ***** NO CONTENT ***** | ============================================================================== 2024-11-28T11:40:11.038-0400 [WARN] unexpected data: registry.terraform.io/jfrog/artifactory:stderr= | 2024/11/28 11:40:11.038518 DEBUG RESTY | ============================================================================== | ~~~ REQUEST ~~~ | POST /artifactory/api/system/usage HTTP/1.1 | HOST : priv.jfrog.io | HEADERS: | \tAccept: */* | \tAuthorization: | \tContent-Type: application/json | \tUser-Agent: jfrog/terraform-provider-artifactory/12.5.1 | BODY : | { | "productId": "terraform-provider-artifactory/12.5.1", | "features": [ | { | "featureId": "Partner/ACC-007450" | }, | { | "featureId": "Resource/artifactory_remote_docker_repository/UPDATE" | } | ] | } | | ------------------------------------------------------------------------------ | ~~~ RESPONSE ~~~ | STATUS : 200 | PROTO : HTTP/1.1 | RECEIVED AT : 2024-11-28T11:40:11.038489-04:00 | TIME DURATION: 68.776083ms | HEADERS : | \tConnection: keep-alive | \tContent-Length: 0 | \tDate: Thu, 28 Nov 2024 15:40:11 GMT | \tStrict-Transport-Security: max-age=31536000; includeSubDomains | \tX-Artifactory-Id: eccbaac55cf86c6eafbb2f82e5782725ac7d 2024-11-28T11:40:11.038-0400 [WARN] unexpected data: registry.terraform.io/jfrog/artifactory:stderr= | 6dab | \tX-Artifactory-Node-Id: priv-artifactory-primary-0 | \tX-Jfrog-Version: Artifactory/7.101.2 710102900 | \tX-Request-Id: 2f7217ce1d00e28c171a790c46765acc | BODY : | ***** NO CONTENT ***** | ============================================================================== 2024-11-28T11:40:11.706-0400 [WARN] unexpected data: registry.terraform.io/jfrog/artifactory:stderr= | 2024/11/28 11:40:11.706415 DEBUG RESTY | ============================================================================== | ~~~ REQUEST ~~~ | POST /artifactory/api/repositories/aws-ecr-registry-delete-me HTTP/1.1 | HOST : priv.jfrog.io | HEADERS: | \tAccept: */* | \tAuthorization: | \tContent-Type: application/json | \tUser-Agent: jfrog/terraform-provider-artifactory/12.5.1 | BODY : | { | "key": "aws-ecr-registry-delete-me", | "projectKey": "", | "environments": [], | "rclass": "remote", | "packageType": "docker", | "url": "https://gallery.ecr.aws", | "username": "", | "proxy": "", | "disableProxy": false, | "description": "Amazon ECR Public Gallery test again", | "notes": "", | "includesPattern": "**/*", | "excludesPattern": "", | "repoLayoutRef": "simple-default", | "remoteRepoLayoutRef": "", | "hardFail": false, | "offline": false, | "blackedOut": false, | "xrayIndex": false, | "priorityResolution": false, | "storeArtifactsLocally": true, | "socketTimeoutMillis": 15000, | "localAddress" 2024-11-28T11:40:11.706-0400 [WARN] unexpected data: registry.terraform.io/jfrog/artifactory:stderr= | : "", | "retrievalCachePeriodSecs": 7200, | "missedRetrievalCachePeriodSecs": 1800, | "metadataRetrievalTimeoutSecs": 60, | "unusedArtifactsCleanupPeriodHours": 0, | "assumedOfflinePeriodSecs": 300, | "shareConfiguration": false, | "synchronizeProperties": false, | "blockMismatchingMimeTypes": true, | "propertySets": [ | "artifactory" | ], | "allowAnyHostAuth": false, | "enableCookieManagement": false, | "bypassHeadRequests": false, | "contentSynchronisation": { | "enabled": false, | "statistics": { | "enabled": false | }, | "properties": { | "enabled": false | }, | "source": { | "originAbsenceDetection": false | } | }, | "mismatchingMimeTypesOverrideList": "", | "listRemoteFolderItems": false, | "cdnRedirect": false, | "disableUrlNormalization": false, | "archiveBrowsingEnabled": false, | "curated": false, | "externalDependenciesEnabled": false, | "externalDependenciesPatterns": [ | "**" | ], | "enableTokenAuthentication": fals 2024-11-28T11:40:11.706-0400 [WARN] unexpected data: registry.terraform.io/jfrog/artifactory:stderr= | e, | "blockPushingSchema1": false, | "dockerProjectId": "" | } | | ------------------------------------------------------------------------------ | ~~~ RESPONSE ~~~ | STATUS : 400 | PROTO : HTTP/1.1 | RECEIVED AT : 2024-11-28T11:40:11.706326-04:00 | TIME DURATION: 736.457625ms | HEADERS : | \tConnection: keep-alive | \tContent-Type: application/json | \tDate: Thu, 28 Nov 2024 15:40:11 GMT | \tStrict-Transport-Security: max-age=31536000; includeSubDomains | \tX-Artifactory-Id: eccbaac55cf86c6eafbb2f82e5782725ac7d6dab | \tX-Artifactory-Node-Id: priv-artifactory-primary-0 | \tX-Jfrog-Version: Artifactory/7.101.2 710102900 | BODY : | { | "errors": [ | { | "status": 400, | "message": "HTTP response status 404:Failed to execute add project resource with error Could not find project ``" | } | ] | } | ============================================================================== 2024-11-28T11:40:11.707-0400 [ERROR] provider.terraform-provider-artifactory_v12.5.1: Response contains error diagnostic: diagnostic_summary= | { | "errors" : [ { | "status" : 400, | "message" : "HTTP response status 404:Failed to execute add project resource with error Could not find project ``" | } ] | } tf_provider_addr=jfrog/artifactory tf_rpc=ApplyResourceChange @module=sdk.proto diagnostic_detail="" tf_req_id=2c715812-0bf9-f4c1-029c-e64560d5813a tf_resource_type=artifactory_remote_docker_repository @caller=github.com/hashicorp/terraform-plugin-go@v0.25.0/tfprotov6/internal/diag/diagnostics.go:58 diagnostic_severity=ERROR tf_proto_version=6.7 timestamp=2024-11-28T11:40:11.707-0400 2024-11-28T11:40:11.710-0400 [DEBUG] State storage *remote.State declined to persist a state snapshot 2024-11-28T11:40:11.710-0400 [ERROR] vertex "artifactory_remote_docker_repository.repository[0]" error: { "errors" : [ { "status" : 400, "message" : "HTTP response status 404:Failed to execute add project resource with error Could not find project ``" } ] } ```
Junkern commented 1 day ago

We also encounter this issue. For us it happens with two artifactory_remote_terraform_repository resources. We also have many other remote/virtuals repos (also docker) which are not affected.

We are running on terraform provider version 11.6.0 - to me it looks like this is not a problem of the provider, but a problem of Artifactory itself?

alexhung commented 23 hours ago

@Osazz @Junkern Thanks for the report. This issue is introduced by RTDEV-49236 in Artifactory v7.101.2. See release note.

The Artifactory engineering team is working on a fix/patch. I don't have a ETA or release version yet. Once I know, I'll pass it on here.

zamanh commented 1 minute ago

I am also seeing this issue on Artifactory version 7.77.5. Specifically when trying to use the platform_permission resource https://registry.terraform.io/providers/jfrog/platform/latest/docs/resources/permission. Using the same TF version and providers as the OP. Alongside the latest platform provider.