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

[Bug]: <Root object was present, but now absent.> #2345

Closed
2 tasks done
priyanshur-curefit opened this issue Jun 14, 2024 · 5 comments
Closed
2 tasks done

[Bug]: <Root object was present, but now absent.> #2345

priyanshur-curefit opened this issue Jun 14, 2024 · 5 comments
Labels

Comments

@priyanshur-curefit
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Provider Version

v1.17.0

Terraform Version

v1.8.4

Terraform Edition

Terraform Open Source (OSS)

Current Behavior

I am getting the following error while running mongodbatlas_cloud_backup_snapshot_restore_job:

│ 
│ When applying changes to
│ mongodbatlas_cloud_backup_snapshot_restore_job.restore_job["prod-digital-hyd"], provider
│ "provider[\"registry.terraform.io/mongodb/mongodbatlas\"]" produced an unexpected new value: Root
│ object was present, but now absent.
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.```




### Terraform configuration to reproduce the issue

```hcl
resource "mongodbatlas_cloud_backup_snapshot_restore_job" "restore_job" {
  for_each = var.clusters

  project_id          = each.value.project_id
  cluster_name        = each.key
  snapshot_id         = data.external.fetch_snapshot_id[each.key].result["snapshot_id"]
  depends_on = [
    mongodbatlas_cluster.hyd_mongo_cluster
  ]
  delivery_type_config {
    automated = true
    target_cluster_name = each.key
    target_project_id     = each.value.project_id
  }
}

Steps To Reproduce

  1. Create a cluster using mongodbatlas_cluster
  2. Try to run mongodbatlas_cloud_backup_snapshot_restore_job using the snapshot_id from another cluster

Logs

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
Copy link
Contributor

Thanks for opening this issue! Please make sure you've followed our guidelines when opening the issue. In short, to help us reproduce the issue we need:

  • Terraform configuration file used to reproduce the issue
  • Terraform log files from the run where the issue occurred
  • Terraform Atlas provider version used to reproduce the issue
  • Terraform version used to reproduce the issue
  • Confirmation if Terraform OSS, Terraform Cloud, or Terraform Enterprise deployment

The ticket CLOUDP-254199 was created for internal tracking.

Copy link
Contributor

This issue has gone 7 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 7 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

@github-actions github-actions bot added the stale label Jun 20, 2024
@maastha
Copy link
Collaborator

maastha commented Jun 20, 2024

Hi @priyanshur-curefit
Thanks a lot for creating this issue:)

Unfortunately I was not able to reproduce this issue. I used below configuration and I was able to successfully deploy everything.

resource "mongodbatlas_cluster" "my_cluster" {
  project_id = mongodbatlas_project.atlas-project.id
  name       = "test"

  provider_name               = "AWS"
  provider_region_name        = "US_WEST_2"
  provider_instance_size_name = "M10"
  cloud_backup                = true // enable cloud provider snapshots
}

resource "mongodbatlas_cloud_backup_snapshot" "test" {
  project_id        = mongodbatlas_cluster.my_cluster.project_id
  cluster_name      = mongodbatlas_cluster.my_cluster.name
  description       = "tmp"
  retention_in_days = 1
}

resource "mongodbatlas_cloud_backup_snapshot_restore_job" "test" {
  project_id   = mongodbatlas_cloud_backup_snapshot.test.project_id
  cluster_name = mongodbatlas_cloud_backup_snapshot.test.cluster_name
  snapshot_id  = mongodbatlas_cloud_backup_snapshot.test.id

  depends_on = [
    mongodbatlas_cluster.my_cluster
  ]
  delivery_type_config {
    automated           = true
    target_cluster_name = mongodbatlas_cluster.my_cluster.name
    target_project_id   = mongodbatlas_project.atlas-project.id
  }
}

If you are still running into this issue, I'd request you to please share complete configuration and ensure following one-click reproducible issues principle.

Thank you!

@priyanshur-curefit
Copy link
Author

priyanshur-curefit commented Jun 20, 2024

resource "mongodbatlas_cluster" "hyd_mongo_cluster" {
  for_each = var.clusters

  project_id              = each.value.project_id
  name                    = each.key
  provider_name           = each.value.provider_name  
  cluster_type            = each.value.cluster_type
  cloud_backup            = each.value.cloud_backup

  provider_instance_size_name = each.value.provider_instance_size_name

replication_specs {
  num_shards = 1
  
  dynamic "regions_config" {
    for_each = each.value.replication_specs
    content {
      region_name     = regions_config.key
      electable_nodes = regions_config.value.electable_nodes
      analytics_nodes = regions_config.value.analytics_nodes
      priority        = regions_config.value.priority
    }
  }
}

  auto_scaling_disk_gb_enabled = each.value.auto_scaling_disk_gb_enabled

  disk_size_gb = each.value.disk_size_gb

  mongo_db_major_version = each.value.mongo_db_major_version

  dynamic "tags" {
    for_each = each.value.tags
    content {
      key   = tags.key
      value = tags.value
    }
  }
}

resource "mongodbatlas_cloud_backup_snapshot_restore_job" "restore_job" {
  for_each = var.clusters

  project_id          = each.value.project_id
  cluster_name        = each.key
  snapshot_id         = data.external.fetch_snapshot_id[each.key].result["snapshot_id"]
  depends_on = [
    mongodbatlas_cluster.hyd_mongo_cluster
  ]
  delivery_type_config {
    automated = true
    target_cluster_name = each.key
    target_project_id     = each.value.project_id
  }
}

data "external" "fetch_snapshot_id" {
  for_each = var.clusters

  program = ["bash", "${path.module}/mongo-snapshots-fetcher.sh", replace(each.key, "-hyd", "")]  
}

here u can see i am trying to restore an already available snapshot of another cluster to a new cluster. I am not using mongodbatlas_cloud_backup_snapshot to create a snapshot. I am using a custom script mongo-snapshots-fetcher.sh which is returning the snaphsot id and i am using that

@github-actions github-actions bot removed the stale label Jun 21, 2024
@maastha
Copy link
Collaborator

maastha commented Jun 21, 2024

I see, in that case are you sure snapshot_id has a valid value from your script?
Could you please share your state file for the concerned resources and the logs? This could be an issue from the backend but it's hard to say just looking at the config.

@lantoli lantoli added the stale label Jun 24, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants