Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
containers:
- name: kubeflow-operator
# Replace this with the built image name
image: aipipeline/kubeflow-operator:v1.1.0
image: aipipeline/kubeflow-operator:latest
command:
- kfctl
imagePullPolicy: Always
Expand Down
15 changes: 14 additions & 1 deletion pkg/controller/kfdef/kfdef_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,20 @@ var kfdefPredicates = predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
object, _ := meta.Accessor(e.ObjectOld)
log.Infof("Got update event for %v.%v.", object.GetName(), object.GetNamespace())
return true

upd, _ := meta.Accessor(e.ObjectNew)
// these cases will result in a reconcile request
// 1. the finalizer is added 2. the deletiontimestamp is added 3. generation is increased
if len(object.GetFinalizers()) == 0 && len(upd.GetFinalizers()) > 0 {
return true
}
if object.GetDeletionTimestamp() == nil && upd.GetDeletionTimestamp() != nil {
return true
}
if upd.GetGeneration() > object.GetGeneration() {
return true
}
return false
},
}

Expand Down
15 changes: 10 additions & 5 deletions pkg/kfapp/kustomize/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,6 @@ func CreateKustomizationMaps() map[MapType]map[string]bool {
// GenerateYamlWithOperatorAnnotation adds operator info to the annotation to every resource
// some code copied from ResMap.AsYaml() func
func GenerateYamlWithOperatorAnnotation(resMap resmap.ResMap, instance *unstructured.Unstructured) ([]byte, error) {
addAnnotation := true
firstObj := true
var b []byte
buf := bytes.NewBuffer(b)
Expand All @@ -1413,6 +1412,7 @@ func GenerateYamlWithOperatorAnnotation(resMap resmap.ResMap, instance *unstruct
kfdefAnn := strings.Join([]string{utils.KfDefAnnotation, utils.KfDefInstance}, "/")
kfdefCr := strings.Join([]string{instance.GetName(), instance.GetNamespace()}, ".")

addAnnotation := true
if m.GetKind() == "Namespace" {
config, _ := rest.InClusterConfig()
corev1client, err := corev1.NewForConfig(config)
Expand All @@ -1422,14 +1422,19 @@ func GenerateYamlWithOperatorAnnotation(resMap resmap.ResMap, instance *unstruct
Message: fmt.Sprintf("failed to create corev1 client: %v", err),
}
}
_, err = corev1client.Namespaces().Get(m.GetName(), metav1.GetOptions{})
ns, err := corev1client.Namespaces().Get(m.GetName(), metav1.GetOptions{})
if err == nil {
log.Infof("Namespace %v already exists.", m.GetName())

_, found := anns[kfdefAnn]
if !found || anns[kfdefAnn] != kfdefCr {
// if the namespace is not created by this operator, should not append the annotation
nsAnns := ns.GetAnnotations()
Comment thread
adrian555 marked this conversation as resolved.
if nsAnns == nil {
addAnnotation = false
} else {
_, found := nsAnns[kfdefAnn]
if !found || nsAnns[kfdefAnn] != kfdefCr {
// if the namespace is not created by this operator, should not append the annotation
addAnnotation = false
}
}
}
} else if m.GetKind() == "CustomResourceDefinition" && m.GetName() == "profiles.kubeflow.org" {
Expand Down