Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Minor refactor for cronjobtrigger. Add some tests #640

Merged
merged 5 commits into from Mar 26, 2018

Conversation

andresmgot
Copy link
Contributor

Issue Ref: None

Description:

Minor refactor of the CronjobTrigger. It removes the groupVersion discovery that we were doing for supporting Kubernetes 1.7 and 1.9 which means that this PR will fail until the version 1.7 is deprecated.

Now when deleting a function, if it has a cronjobtrigger associated it will be deleted instead of just deleting the cronjob object.

It also includes unit/integration tests for checking that the trigger is removed when the function is deleted and that it properly detect changes in the cronjobtrigger.

TODOs:

  • Ready to review
  • Automated Tests
    - [ ] Docs

c.logger.Errorf("Failed to delete cronjob %s created for the function %s in namespace %s, Error: %s", cronJobName, functionObj.ObjectMeta.Name, functionObj.ObjectMeta.Namespace, err)
}
c.logger.Infof("Function %s deleted. Removing associated cronjob trigger", functionObj.Name)
err := c.kubelessclient.KubelessV1beta1().CronJobTriggers(functionObj.Namespace).Delete(functionObj.Name, &metav1.DeleteOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes assumption that cronjob trigger name is same as function name. Can we loop through the cron job triggers in the namespace and find the one with associated function name set to the function getting deleted?

@@ -349,12 +320,12 @@ func cronJobTriggerObjChanged(oldObj, newObj *kubelessApi.CronJobTrigger) bool {
}
// If the new and old CronJob trigger object's resource version is same
if oldObj.ResourceVersion != newObj.ResourceVersion {
return true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why false. this should be true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, debug I forgot to restore

@andresmgot andresmgot merged commit fab33b7 into vmware-archive:master Mar 26, 2018
andresmgot added a commit to andresmgot/kubeless that referenced this pull request Mar 26, 2018
* Minor refactor for cronjobtrigger. Add some tests

* Fix tests

* Add debug info

* Allow trigger deletion with RBAC

* Review
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants