Skip to content

Commit

Permalink
Use better namespace upsert in agent too (#147)
Browse files Browse the repository at this point in the history
Use the same fix as w/ the cli, need to be smarter about checking namespace existence to handle admission controllers firing first.
  • Loading branch information
michaeljguarino authored Mar 21, 2024
1 parent 8f9e335 commit a9ab427
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/utils/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ func CheckNamespace(clientset kubernetes.Clientset, namespace string) error {
if namespace == "" {
return nil
}
_, err := clientset.CoreV1().Namespaces().Create(context.Background(), &v1.Namespace{

ctx := context.Background()
nsClient := clientset.CoreV1().Namespaces()
_, err := nsClient.Get(ctx, namespace, metav1.GetOptions{})
if err == nil {
return nil
}

_, err = nsClient.Create(ctx, &v1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
},
Expand Down

0 comments on commit a9ab427

Please sign in to comment.