Skip to content

Commit

Permalink
Correctly checking if previous NS not in Terminating state
Browse files Browse the repository at this point in the history
  • Loading branch information
devdattakulkarni committed Jul 26, 2024
1 parent 15f457c commit 71d7f6d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mutating-webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,17 +586,17 @@ func getReleaseName(ar *v1.AdmissionReview) string {
}

func saveResource(ar *v1.AdmissionReview) {
fmt.Printf("Inside saveResource")
fmt.Printf("Inside saveResource\n")
kind, resName, _ := getObjectDetails(ar)
//key := kind + "/" + namespace + "/" + resName
key := kind + "-" + resName
fmt.Printf("Res Key:%s\n", key)
val, ok := resourceNameObjMap[key]
//fmt.Printf("Res Key:%s\n", key)
_, ok := resourceNameObjMap[key]
if !ok {
resourceNameObjMap[key] = ar
} else {
fmt.Printf("Key %s already present in resourceNameObjMap\n", key)
fmt.Printf("%v\n", val)
//fmt.Printf("%v\n", val)
}
}

Expand Down Expand Up @@ -1423,7 +1423,9 @@ func handleCustomAPIs(ar *v1.AdmissionReview) *v1.AdmissionResponse {
}

nsObj, nsGetErr := kubeClient.CoreV1().Namespaces().Get(context.Background(), crname, metav1.GetOptions{})
if nsGetErr != nil {
//fmt.Printf("nsObj:%v\n", nsObj)
//fmt.Printf("nsGetErr:%v\n", nsGetErr)
if nsGetErr == nil {
nsPhase := nsObj.Status.Phase
fmt.Printf("Namespace for %s exists. Current status is: %s\n", crname, nsPhase)
if nsPhase == "Terminating" {
Expand Down

0 comments on commit 71d7f6d

Please sign in to comment.