Skip to content

Commit

Permalink
Merge pull request #309 from sergenyalcin/set-timeouts-instancestate
Browse files Browse the repository at this point in the history
Put default and configured timeouts to InstanceState for using the timeouts while Observe calls
  • Loading branch information
sergenyalcin authored Dec 5, 2023
2 parents ca2cfe6 + f99dee3 commit a978820
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/controller/external_nofork.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (c *NoForkConnector) applyStateFuncToParam(sc *schema.Schema, param any) an
return param
}

func (c *NoForkConnector) Connect(ctx context.Context, mg xpresource.Managed) (managed.ExternalClient, error) {
func (c *NoForkConnector) Connect(ctx context.Context, mg xpresource.Managed) (managed.ExternalClient, error) { //nolint:gocyclo
c.metricRecorder.ObserveReconcileDelay(mg.GetObjectKind().GroupVersionKind(), mg.GetName())
logger := c.logger.WithValues("uid", mg.GetUID(), "name", mg.GetName(), "gvk", mg.GetObjectKind().GroupVersionKind().String())
logger.Debug("Connecting to the service provider")
Expand Down Expand Up @@ -279,6 +279,17 @@ func (c *NoForkConnector) Connect(ctx context.Context, mg xpresource.Managed) (m
}
s.RawPlan = tfStateCtyValue
s.RawConfig = rawConfig

timeouts := getTimeoutParameters(c.config)
if len(timeouts) > 0 {
if s == nil {
s = &tf.InstanceState{}
}
if s.Meta == nil {
s.Meta = make(map[string]interface{})
}
s.Meta[schema.TimeoutKey] = timeouts
}
opTracker.SetTfState(s)
}

Expand Down

0 comments on commit a978820

Please sign in to comment.