crossplane / terrajet

Generate Crossplane Providers from any Terraform Provider
https://crossplane.io
Apache License 2.0
289 stars 38 forks source link

Let the user know that there is an ongoing operation during async operations #110

Closed muvaf closed 2 years ago

muvaf commented 2 years ago

What problem are you facing?

If we encounter a problem during an async operation, we report it in the AsyncOperation condition. However, this informs user about only the last operation error like the following:

  conditions:
  - lastTransitionTime: "2021-10-12T16:01:21Z"
    reason: ReconcileSuccess
    status: "True"
    type: Synced
  - lastTransitionTime: "2021-10-12T16:04:34Z"
    message: '{"@level":"error","@message":"Error: Error creating DB Instance: DBParameterGroupNotFound:
      DBParameterGroup not found: example-dbparametergroup\n\tstatus code: 404, request
      id: 7cbae0b0-6d1d-4b21-859e-e103fd9bd01f","@module":"terraform.ui","@timestamp":"2021-10-12T19:03:38.109151+03:00","diagnostic":{"severity":"error","summary":"Error
      creating DB Instance: DBParameterGroupNotFound: DBParameterGroup not found:
      example-dbparametergroup\n\tstatus code: 404, request id: 7cbae0b0-6d1d-4b21-859e-e103fd9bd01f","detail":"","address":"aws_db_instance.example-dbinstance","range":{"filename":"main.tf.json","start":{"line":1,"column":734,"byte":733},"end":{"line":1,"column":735,"byte":734}},"snippet":{"context":"resource.aws_db_instance.example-dbinstance","code":"{\"provider\":{\"tf-provider\":{\"access_key\":\"REDACTED\",\"region\":\"us-east-1\",\"secret_key\":\"REDACTED\",\"token\":\"\"}},\"resource\":{\"aws_db_instance\":{\"example-dbinstance\":{\"allocated_storage\":20,\"auto_minor_version_upgrade\":true,\"backup_retention_period\":14,\"backup_window\":\"09:46-10:16\",\"engine\":\"postgres\",\"engine_version\":\"12.4\",\"identifier\":\"example-dbinstance\",\"instance_class\":\"db.t2.micro\",\"lifecycle\":{\"prevent_destroy\":true},\"maintenance_window\":\"Mon:00:00-Mon:03:00\",\"name\":\"example\",\"parameter_group_name\":\"example-dbparametergroup\",\"password\":\"testPassword!123\",\"publicly_accessible\":false,\"skip_final_snapshot\":true,\"storage_encrypted\":false,\"storage_type\":\"gp2\",\"username\":\"adminuser\"}}},\"terraform\":{\"required_providers\":{\"tf-provider\":{\"source\":\"hashicorp/aws\",\"version\":\"3.56.0\"}}}}","start_line":1,"highlight_start_offset":733,"highlight_end_offset":734,"values":[]}},"type":"diagnostic"}'
    reason: ApplyFailure
    status: "False"
    type: AsyncOperation
  - lastTransitionTime: "2021-10-12T16:01:21Z"
    reason: Creating
    status: "False"
    type: Ready

If user fixes the error and then the apply operation for example continues successfully, the error is still there until that operation finishes and users don't have a clear way of knowing that they fixed the problem.

How could Terrajet help solve your problem?

We cannot re-use the same condition to notify about the new operation because that would mean deleting the error in every reconcile and writing a new one. So, we need a way to let the user know that there is a new operation begun since the last error we show.

muvaf commented 2 years ago

A separate condition & an event that marks the beginning of the current operation would probably help here.