diff --git a/pkg/adapter/nimbus-k8tls/main.go b/pkg/adapter/nimbus-k8tls/main.go index 0574162b..ba7d46c7 100644 --- a/pkg/adapter/nimbus-k8tls/main.go +++ b/pkg/adapter/nimbus-k8tls/main.go @@ -16,7 +16,7 @@ import ( ) func main() { - ctrl.SetLogger(zap.New(zap.UseDevMode(true))) + ctrl.SetLogger(zap.New()) logger := ctrl.Log ctx, cancelFunc := context.WithCancel(context.Background()) diff --git a/pkg/adapter/nimbus-k8tls/manager/cronjob.go b/pkg/adapter/nimbus-k8tls/manager/cronjob.go index 88413ee6..4b8ccc13 100644 --- a/pkg/adapter/nimbus-k8tls/manager/cronjob.go +++ b/pkg/adapter/nimbus-k8tls/manager/cronjob.go @@ -54,7 +54,7 @@ func createOrUpdateCj(ctx context.Context, logger logr.Logger, cwnp v1alpha1.Clu logger.Info("configured Kubernetes CronJob", "CronJob.Name", cronJob.Name, "CronJob.Namespace", cronJob.Namespace) } - if err = adapterutil.UpdateCwnpStatus(ctx, k8sClient, "CronJob/"+cronJob.Name, cwnp.Name, false); err != nil { + if err = adapterutil.UpdateCwnpStatus(ctx, k8sClient, cronJob.Namespace+"/CronJob/"+cronJob.Name, cwnp.Name, false); err != nil { logger.Error(err, "failed to update ClusterNimbusPolicy status") } } @@ -67,7 +67,7 @@ func deleteCronJobs(ctx context.Context, logger logr.Logger, cwnpName string, cr continue } - if err := adapterutil.UpdateCwnpStatus(ctx, k8sClient, "CronJob/"+cronJob.Name, cwnpName, true); err != nil { + if err := adapterutil.UpdateCwnpStatus(ctx, k8sClient, cronJob.Namespace+"/CronJob/"+cronJob.Name, cwnpName, true); err != nil { logger.Error(err, "failed to update ClusterNimbusPolicy status") } logger.Info("Dangling Kubernetes CronJob deleted", "CronJobJob.Name", cronJob.Name, "CronJob.Namespace", cronJob.Namespace) diff --git a/pkg/adapter/nimbus-k8tls/manager/k8tls.go b/pkg/adapter/nimbus-k8tls/manager/k8tls.go index 225b960a..15e332ab 100644 --- a/pkg/adapter/nimbus-k8tls/manager/k8tls.go +++ b/pkg/adapter/nimbus-k8tls/manager/k8tls.go @@ -202,8 +202,12 @@ func setupK8tlsEnv(ctx context.Context, cwnp v1alpha1.ClusterNimbusPolicy, schem objs := []client.Object{ns, cm, sa, clusterRole, clusterRoleBinding} for idx := range objs { objToCreate := objs[idx] - if err := ctrl.SetControllerReference(&cwnp, objToCreate, scheme); err != nil { - return err + + // Don't set owner ref on namespace. + if idx != 0 { + if err := ctrl.SetControllerReference(&cwnp, objToCreate, scheme); err != nil { + return err + } } var existingObj client.Object