@@ -30,6 +30,7 @@ import (
30
30
autov1alpha1 "github.com/pulumi/pulumi-kubernetes-operator/v2/operator/api/auto/v1alpha1"
31
31
autov1alpha1webhook "github.com/pulumi/pulumi-kubernetes-operator/v2/operator/internal/webhook/auto/v1alpha1"
32
32
"github.com/pulumi/pulumi-kubernetes-operator/v2/operator/version"
33
+ "google.golang.org/grpc/status"
33
34
appsv1 "k8s.io/api/apps/v1"
34
35
corev1 "k8s.io/api/core/v1"
35
36
"k8s.io/apimachinery/pkg/api/meta"
@@ -242,6 +243,31 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
242
243
initializedV , ok := pod .Annotations [PodAnnotationInitialized ]
243
244
initialized , _ := strconv .ParseBool (initializedV )
244
245
if ! ok || ! initialized {
246
+ l .Info ("Running whoami to ensure authentication is setup correctly with the workspace pod" )
247
+ _ , err = wc .WhoAmI (ctx , & agentpb.WhoAmIRequest {})
248
+ if err != nil {
249
+ l .Error (err , "unable to run whoami; retaining the workspace pod to retry later" )
250
+ st := status .Convert (err )
251
+
252
+ ready .Status = metav1 .ConditionFalse
253
+ ready .Reason = st .Code ().String ()
254
+ ready .Message = st .Message ()
255
+
256
+ // Override with structured error from PulumiErrorInfo if provided.
257
+ if len (st .Details ()) > 0 {
258
+ if info , ok := st .Details ()[0 ].(* agentpb.PulumiErrorInfo ); ok {
259
+ ready .Reason = info .Reason
260
+ ready .Message = info .Message
261
+ }
262
+ }
263
+
264
+ if statusErr := updateStatus (); statusErr != nil {
265
+ return ctrl.Result {}, statusErr
266
+ }
267
+
268
+ return ctrl.Result {}, err
269
+ }
270
+
245
271
l .Info ("Running pulumi install" )
246
272
ready .Status = metav1 .ConditionFalse
247
273
ready .Reason = "Installing"
0 commit comments