Skip to content

Commit

Permalink
Improve error messages for object creation error.
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Gwosdz <jgwosdz@redhat.com>
  • Loading branch information
erdii committed Aug 31, 2023
1 parent 2d6ccd1 commit f821823
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dev/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (c *Cluster) CreateAndWaitFromHttp(

for i := range objects {
if err := c.CreateAndWaitForReadiness(ctx, &objects[i], opts...); err != nil {
return fmt.Errorf("creating object: %w", err)
return fmt.Errorf("creating from http: %w", err)
}
}
return nil
Expand All @@ -207,7 +207,7 @@ func (c *Cluster) CreateAndWaitFromFiles(

for i := range objects {
if err := c.CreateAndWaitForReadiness(ctx, &objects[i], opts...); err != nil {
return fmt.Errorf("creating object: %w", err)
return fmt.Errorf("creating from files: %w", err)
}
}
return nil
Expand All @@ -231,7 +231,7 @@ func (c *Cluster) CreateAndWaitFromFolders(

for i := range objects {
if err := c.CreateAndWaitForReadiness(ctx, &objects[i], opts...); err != nil {
return fmt.Errorf("creating object: %w", err)
return fmt.Errorf("creating from folders: %w", err)
}
}
return nil
Expand All @@ -244,7 +244,12 @@ func (c *Cluster) CreateAndWaitForReadiness(
) error {
if err := c.CtrlClient.Create(ctx, object); err != nil &&
!errors.IsAlreadyExists(err) {
return fmt.Errorf("creating object: %w", err)
gvk := object.GetObjectKind().GroupVersionKind()
return fmt.Errorf("creating object: %s/%s/%s %s/%s: %w",
gvk.Group,
gvk.Version,
gvk.Kind,
object.GetNamespace(), object.GetName(), err)
}

if err := c.Waiter.WaitForReadiness(ctx, object); err != nil {
Expand Down

0 comments on commit f821823

Please sign in to comment.