Merge pull request #3090 from kshlm/delete-active-job-if-requested

ceph: Delete and recreate rook-ceph-detect-version job
This commit is contained in:
Travis Nielsen authored and GitHub committed 2019-05-01 10:16:18 -06:00
commit 221560bf24
4 files changed
+7 -6

No files matched your search

+1 -1
View File
@@ -119,7 +119,7 @@ func (c *cluster) detectCephVersion(image string, timeout time.Duration) (*cephv
k8sutil.SetOwnerRef(c.context.Clientset, c.Namespace, &job.ObjectMeta, &c.ownerRef)
// run the job to detect the version
if err := k8sutil.RunReplaceableJob(c.context.Clientset, job); err != nil {
if err := k8sutil.RunReplaceableJob(c.context.Clientset, job, true); err != nil {
return nil, fmt.Errorf("failed to start version job. %+v", err)
}
+1 -1
View File
@@ -242,7 +242,7 @@ func (c *Cluster) startProvisioning(config *provisionConfig) {
}
func (c *Cluster) runJob(job *batch.Job, nodeName string, config *provisionConfig, action string) bool {
if err := k8sutil.RunReplaceableJob(c.context.Clientset, job); err != nil {
if err := k8sutil.RunReplaceableJob(c.context.Clientset, job, false); err != nil {
if !errors.IsAlreadyExists(err) {
// we failed to create job, update the orchestration status for this node
message := fmt.Sprintf("failed to create %s job for node %s. %+v", action, nodeName, err)
+1 -1
View File
@@ -173,7 +173,7 @@ func (c *CephNFSController) runGaneshaRadosGraceJob(n cephv1.CephNFS, name, acti
k8sutil.SetOwnerRef(c.context.Clientset, n.Namespace, &job.ObjectMeta, &c.ownerRef)
// run the job to detect the version
if err := k8sutil.RunReplaceableJob(c.context.Clientset, job); err != nil {
if err := k8sutil.RunReplaceableJob(c.context.Clientset, job, false); err != nil {
return fmt.Errorf("failed to start job %s. %+v", job.Name, err)
}
+4 -3
View File
@@ -29,14 +29,15 @@ import (
"k8s.io/client-go/kubernetes"
)
func RunReplaceableJob(clientset kubernetes.Interface, job *batch.Job) error {
func RunReplaceableJob(clientset kubernetes.Interface, job *batch.Job, deleteIfFound bool) error {
// check if the job was already created and what its status is
existingJob, err := clientset.BatchV1().Jobs(job.Namespace).Get(job.Name, metav1.GetOptions{})
if err != nil && !errors.IsNotFound(err) {
logger.Warningf("failed to detect job %s. %+v", job.Name, err)
} else if err == nil {
// if the job is still running, allow it to continue to completion
if existingJob.Status.Active > 0 {
// if the job is still running, and the caller has not asked for deletion,
// allow it to continue to completion
if existingJob.Status.Active > 0 && !deleteIfFound {
logger.Infof("Found previous job %s. Status=%+v", job.Name, existingJob.Status)
return nil
}