Browse code

Fix jobs-related bug in task conversion

While working on some other code, noticed a bug in the jobs code. We're
adding job version after we're checking if there are port configs.
Before, if there were no port configs, the job version would be missing,
because we would return before trying to convert.

This moves the jobs version conversion above that code, so we don't
accidentally return before it.

Signed-off-by: Drew Erny <derny@mirantis.com>

Drew Erny authored on 2020/12/03 03:27:23
Showing 1 changed files
... ...
@@ -51,6 +51,12 @@ func TaskFromGRPC(t swarmapi.Task) (types.Task, error) {
51 51
 		task.NetworksAttachments = append(task.NetworksAttachments, networkAttachmentFromGRPC(na))
52 52
 	}
53 53
 
54
+	if t.JobIteration != nil {
55
+		task.JobIteration = &types.Version{
56
+			Index: t.JobIteration.Index,
57
+		}
58
+	}
59
+
54 60
 	if t.Status.PortStatus == nil {
55 61
 		return task, nil
56 62
 	}
... ...
@@ -65,11 +71,5 @@ func TaskFromGRPC(t swarmapi.Task) (types.Task, error) {
65 65
 		})
66 66
 	}
67 67
 
68
-	if t.JobIteration != nil {
69
-		task.JobIteration = &types.Version{
70
-			Index: t.JobIteration.Index,
71
-		}
72
-	}
73
-
74 68
 	return task, nil
75 69
 }