Skip to content

Commit ad0cf83

Browse files
committed
DONOTMERGE: additional debugging
Signed-off-by: timflannagan <[email protected]>
1 parent df1a538 commit ad0cf83

File tree

3 files changed

+165
-143
lines changed

3 files changed

+165
-143
lines changed

pkg/controller/operators/adoption_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ func (r *AdoptionReconciler) adopt(ctx context.Context, operator *decorators.Ope
281281
}
282282
candidate := cObj.DeepCopyObject()
283283

284+
r.log.Info("adopt - attempting to adopt component", "gvk", cObj.GetObjectKind(), "name", cObj.GetName(), "namespace", cObj.GetNamespace())
285+
284286
adopted, err := operator.AdoptComponent(candidate)
285287
if err != nil {
286288
return err
@@ -292,6 +294,8 @@ func (r *AdoptionReconciler) adopt(ctx context.Context, operator *decorators.Ope
292294
if !ok {
293295
return fmt.Errorf("Unable to typecast runtime.Object to client.Object")
294296
}
297+
r.log.Info("adopt - successfully adopted component (pre-patch)", "gvk", cObj.GetObjectKind(), "name", cObj.GetName(), "namespace", cObj.GetNamespace())
298+
295299
return r.Patch(ctx, pCObj, client.MergeFrom(cObj))
296300
}
297301

test/e2e/ctx/ctx.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,27 +129,29 @@ func (ctx TestContext) DumpNamespaceArtifacts(namespace string) error {
129129
}
130130

131131
func (ctx TestContext) DescribeResource(command string) error {
132+
ctx.Logf("Running command %s", command)
132133
stdout, stderr, err := ctx.ExecCommand(command)
133134
if err != nil {
134-
ctx.Logf("failed to describe resource: %v", stderr.String())
135-
return err
135+
return fmt.Errorf("failed to run command: %s", strings.TrimSpace(stderr+err.Error()))
136136
}
137-
ctx.Logf("%s", stdout.String())
137+
ctx.Logf("%s", strings.TrimSpace(stdout))
138138
return nil
139139
}
140140

141-
func (ctx TestContext) ExecCommand(command string) (bytes.Buffer, bytes.Buffer, error) {
141+
func (ctx TestContext) ExecCommand(command string) (string, string, error) {
142142
var (
143143
stdoutBuf bytes.Buffer
144144
stderrBuf bytes.Buffer
145145
)
146146
cmd := exec.Command("bash", "-c", command)
147147
cmd.Stdout = &stdoutBuf
148148
cmd.Stderr = &stderrBuf
149+
cmd.Env = []string{"KUBECONFIG=" + ctx.kubeconfigPath}
150+
149151
if err := cmd.Run(); err != nil {
150-
return bytes.Buffer{}, bytes.Buffer{}, err
152+
return stdoutBuf.String(), stderrBuf.String(), err
151153
}
152-
return stdoutBuf, stderrBuf, nil
154+
return stdoutBuf.String(), stderrBuf.String(), nil
153155
}
154156

155157
func setDerivedFields(ctx *TestContext) error {

0 commit comments

Comments
 (0)