Skip to content

Commit

Permalink
Prioritize resource deletion over accessing connection info, add the …
Browse files Browse the repository at this point in the history
…missing fmt.Sprintf inside the logger
  • Loading branch information
etesami committed Sep 4, 2024
1 parent ad0af54 commit 69d00eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/client/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func NewSSHClient(ctx context.Context, data []byte) (*ssh.Client, error) { // no

if err != nil {
// Final failure after all attempts
logger.Info("All %d attempts to connect to %s failed.\n", maxAttempts, remoteHost)
logger.Info(fmt.Sprintf("All %d attempts to connect to %s failed.", maxAttempts, remoteHost))
return nil, err
}

Expand Down
7 changes: 7 additions & 0 deletions internal/controller/script/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ func (c *connector) Connect(ctx context.Context, mg resource.Managed) (managed.E
return nil, errors.Wrap(err, errGetPC)
}

// if the resource is being deleted, we just return
cond := cr.GetCondition(xpv1.Deleting().Type)
if cond.Type == xpv1.TypeReady && cond.Status == "False" && cond.Reason == xpv1.ReasonDeleting {
logger.Info(fmt.Sprintf("[%s] Resource is being deleted. Skip the connection.", mg.GetName()))
return &external{}, nil
}

cd := pc.Spec.Credentials
data, err := resource.CommonCredentialExtractor(ctx, cd.Source, c.kube, cd.CommonCredentialSelectors)
if err != nil {
Expand Down

0 comments on commit 69d00eb

Please sign in to comment.