Skip to content

Commit f628be0

Browse files
authored
Merge pull request kubernetes-sigs#4818 from vincepri/log-clusterctl-move-improve
🌱 Provide more information in clusterctl move logs
2 parents 5177a47 + 4e05fb7 commit f628be0

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

cmd/clusterctl/client/alpha/machinedeployment.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ func getMachineDeployment(proxy cluster.Proxy, name, namespace string) (*cluster
3939
Name: name,
4040
}
4141
if err := c.Get(ctx, mdObjKey, mdObj); err != nil {
42-
return nil, errors.Wrapf(err, "error reading %q %s/%s",
43-
mdObj.GroupVersionKind(), mdObjKey.Namespace, mdObjKey.Name)
42+
return nil, errors.Wrapf(err, "error reading MachineDeployment %s/%s",
43+
mdObjKey.Namespace, mdObjKey.Name)
4444
}
4545
return mdObj, nil
4646
}
@@ -57,11 +57,11 @@ func patchMachineDeployemt(proxy cluster.Proxy, name, namespace string, patch cl
5757
Name: name,
5858
}
5959
if err := cFrom.Get(ctx, mdObjKey, mdObj); err != nil {
60-
return errors.Wrapf(err, "error reading %s/%s", mdObj.GetNamespace(), mdObj.GetName())
60+
return errors.Wrapf(err, "error reading MachineDeployment %s/%s", mdObj.GetNamespace(), mdObj.GetName())
6161
}
6262

6363
if err := cFrom.Patch(ctx, mdObj, patch); err != nil {
64-
return errors.Wrapf(err, "error while patching %s/%s", mdObj.GetNamespace(), mdObj.GetName())
64+
return errors.Wrapf(err, "error while patching MachineDeployment %s/%s", mdObj.GetNamespace(), mdObj.GetName())
6565
}
6666
return nil
6767
}
@@ -95,11 +95,11 @@ func findMachineDeploymentRevision(toRevision int64, allMSs []*clusterv1.Machine
9595
}
9696

9797
if toRevision > 0 {
98-
return nil, errors.Errorf("unable to find specified revision: %v", toRevision)
98+
return nil, errors.Errorf("unable to find specified MachineDeployment revision: %v", toRevision)
9999
}
100100

101101
if previousMachineSet == nil {
102-
return nil, errors.Errorf("no rollout history found")
102+
return nil, errors.Errorf("no rollout history found for MachineDeployment")
103103
}
104104
return previousMachineSet, nil
105105
}

cmd/clusterctl/client/cluster/mover.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,29 @@ func (o *objectMover) Move(namespace string, toCluster Client, dryRun bool) erro
6565
// checks that all the required providers in place in the target cluster.
6666
if !o.dryRun {
6767
if err := o.checkTargetProviders(toCluster.ProviderInventory()); err != nil {
68-
return err
68+
return errors.Wrap(err, "failed to check providers in target cluster")
6969
}
7070
}
7171

7272
// Gets all the types defines by the CRDs installed by clusterctl plus the ConfigMap/Secret core types.
7373
err := objectGraph.getDiscoveryTypes()
7474
if err != nil {
75-
return err
75+
return errors.Wrap(err, "failed to retrieve discovery types")
7676
}
7777

7878
// Discovery the object graph for the selected types:
7979
// - Nodes are defined the Kubernetes objects (Clusters, Machines etc.) identified during the discovery process.
8080
// - Edges are derived by the OwnerReferences between nodes.
8181
if err := objectGraph.Discovery(namespace); err != nil {
82-
return err
82+
return errors.Wrap(err, "failed to discover the object graph")
8383
}
8484

8585
// Checks if Cluster API has already completed the provisioning of the infrastructure for the objects involved in the move operation.
8686
// This is required because if the infrastructure is provisioned, then we can reasonably assume that the objects we are moving are
8787
// not currently waiting for long-running reconciliation loops, and so we can safely rely on the pause field on the Cluster object
8888
// for blocking any further object reconciliation on the source objects.
8989
if err := o.checkProvisioningCompleted(objectGraph); err != nil {
90-
return err
90+
return errors.Wrap(err, "failed to check for provisioned infrastructure")
9191
}
9292

9393
// Check whether nodes are not included in GVK considered for move
@@ -178,8 +178,8 @@ func getClusterObj(proxy Proxy, cluster *node, clusterObj *clusterv1.Cluster) er
178178
}
179179

180180
if err := c.Get(ctx, clusterObjKey, clusterObj); err != nil {
181-
return errors.Wrapf(err, "error reading %q %s/%s",
182-
clusterObj.GroupVersionKind(), clusterObj.GetNamespace(), clusterObj.GetName())
181+
return errors.Wrapf(err, "error reading Cluster %s/%s",
182+
clusterObj.GetNamespace(), clusterObj.GetName())
183183
}
184184
return nil
185185
}
@@ -196,8 +196,8 @@ func getMachineObj(proxy Proxy, machine *node, machineObj *clusterv1.Machine) er
196196
}
197197

198198
if err := c.Get(ctx, machineObjKey, machineObj); err != nil {
199-
return errors.Wrapf(err, "error reading %q %s/%s",
200-
machineObj.GroupVersionKind(), machineObj.GetNamespace(), machineObj.GetName())
199+
return errors.Wrapf(err, "error reading Machine %s/%s",
200+
machineObj.GetNamespace(), machineObj.GetName())
201201
}
202202
return nil
203203
}
@@ -362,13 +362,13 @@ func patchCluster(proxy Proxy, cluster *node, patch client.Patch) error {
362362
}
363363

364364
if err := cFrom.Get(ctx, clusterObjKey, clusterObj); err != nil {
365-
return errors.Wrapf(err, "error reading %q %s/%s",
366-
clusterObj.GroupVersionKind(), clusterObj.GetNamespace(), clusterObj.GetName())
365+
return errors.Wrapf(err, "error reading Cluster %s/%s",
366+
clusterObj.GetNamespace(), clusterObj.GetName())
367367
}
368368

369369
if err := cFrom.Patch(ctx, clusterObj, patch); err != nil {
370-
return errors.Wrapf(err, "error patching %q %s/%s",
371-
clusterObj.GroupVersionKind(), clusterObj.GetNamespace(), clusterObj.GetName())
370+
return errors.Wrapf(err, "error patching Cluster %s/%s",
371+
clusterObj.GetNamespace(), clusterObj.GetName())
372372
}
373373

374374
return nil

0 commit comments

Comments
 (0)