yandex-cloud / terraform-provider-yandex

Terraform Yandex provider
https://www.terraform.io/docs/providers/yandex/
Mozilla Public License 2.0
208 stars 114 forks source link

yandex_ydb_table inconsistent ttl behaviour #466

Open baznikin opened 2 months ago

baznikin commented 2 months ago

ttl { expire_interval } stored internaly in the cloud in ISO 8601 with full range of its possibilities (i.e. with M, Y fields) and provider every time try to replace notion in days with it internal stored value:

      - ttl {
          - column_name     = "_timestamp" -> null
          - expire_interval = "P1Y" -> null
            # (1 unchanged attribute hidden)
        }
      + ttl {
          + column_name     = "_timestamp"
          + expire_interval = "P365D"
          + unit            = (known after apply)
        }

However, API accept only notion in days; if you try to create new resource with value P1Y (i.e. as it is stored in the cloud), API error occurs:

│ non-retryable error occurred on attempt No.1 (idempotent=false): connError{node_id:0,address:'ru-central1-b.ydb.serverless.yandexcloud.net:2135'}: operation/GENERIC_ERROR (code = 400080, address =
│ ru-central1-b.ydb.serverless.yandexcloud.net:2135, issues = [{16:8 => 'Invalid value "P1Y" for type Interval'}]) at `github.com/ydb-platform/ydb-go-sdk/v3/internal/conn.(*conn).Invoke(conn.go:373)` at
│ `github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer.(*Balancer).wrapCall(balancer.go:358)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*session).ExecuteSchemeQuery(session.go:841)` at
│ `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.do.func1(retry.go:54)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.retryBackoff.func1(retry.go:85)` at
│ `github.com/ydb-platform/ydb-go-sdk/v3/retry.Retry(retry.go:314)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*Client).Do(client.go:658)`
nikolaymatrosov commented 1 month ago

Actually, it is stored as seconds and is converted just in the provider. https://github.com/ydb-platform/terraform-provider-ydb/blob/main/internal/resources/table/table.go#L369