-
Notifications
You must be signed in to change notification settings - Fork 706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1496 asset sync namespaces #1519
Conversation
@@ -367,26 +385,40 @@ func (c *Controller) handleObject(obj interface{}) { | |||
return | |||
} | |||
|
|||
if apprepo.ObjectMeta.DeletionTimestamp != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required so that we don't re-process (ie. re-create cronjobs etc.) for an app repo that is being deleted.
// cronjob for an app repo in another namespace, then we should | ||
// log a warning to the event recorder and return it. | ||
if !metav1.IsControlledBy(cronjob, apprepo) && !objectBelongsTo(cronjob, apprepo) { | ||
log.Errorf("Cronjob: %+v\nAppRepo: %+v", cronjob.ObjectMeta, apprepo.ObjectMeta) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this for debugging purposes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - thanks :)
@@ -17,6 +17,7 @@ func Test_newCronJob(t *testing.T) { | |||
dbName = "assets" | |||
dbUser = "admin" | |||
dbSecretName = "mongodb" | |||
const kubeappsNamespace = "kubeapps" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes? Not sure what you mean here. I could either create a var with:
kubeappsNamespace := "kubeapps"
or set a constant string, as I have, which given I'm not modifying it... Let me know if I missed your meaning.
return &batchv1.Job{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
GenerateName: cronJobName(apprepo) + "-", | ||
Namespace: apprepo.Namespace, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove the namespace? (to avoid duplication?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because we choose which namespace to write these resources in the actual client call, so if we also write it here, we have to duplicate the logic/args to ensure it is the same (otherwise, the k8s api server rejects it as it should).
I QA'd this and had to do a small change in 8181081 so that when the feature flag is not set, we request apprepos for the kubeapps namespace after deleting one. |
Ref : #1496
With this change, the controller spawns cronjobs/jobs in the kubeapps namespace and successfully sync's public app repositories across all namespaces.
I also noticed that I was initially unable to delete app repositories in the kubeapps namespace, they'd stay in a deleting state with a finalizer. Turned out to be because the app repo controller was recreating cronjobs as soon as k8s was deleting them (as they were owned by the app repo).
The main changes are:
TODO: