fix: annotate pod instead of label on UnregistrationFailureMessage (#1615)
The error message should go to annotation instead of pod label, since we only check annotations on autoscale: https://github.com/actions-runner-controller/actions-runner-controller/blob/master/controllers/autoscaling.go#L338-L342 Then there is no need to truncate or normalize the error message.
This commit is contained in:
		
							parent
							
								
									473295e3fc
								
							
						
					
					
						commit
						fea1457f12
					
				|  | @ -67,25 +67,6 @@ func annotatePodOnce(ctx context.Context, c client.Client, log logr.Logger, pod | ||||||
| 
 | 
 | ||||||
| 	return updated, nil | 	return updated, nil | ||||||
| } | } | ||||||
| func labelPod(ctx context.Context, c client.Client, log logr.Logger, pod *corev1.Pod, k, v string) (*corev1.Pod, error) { |  | ||||||
| 	if pod == nil { |  | ||||||
| 		return nil, nil |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	updated := pod.DeepCopy() |  | ||||||
| 	if updated.Labels == nil { |  | ||||||
| 		updated.Labels = map[string]string{} |  | ||||||
| 	} |  | ||||||
| 	updated.Labels[k] = v |  | ||||||
| 	if err := c.Patch(ctx, updated, client.MergeFrom(pod)); err != nil { |  | ||||||
| 		log.Error(err, fmt.Sprintf("Failed to patch pod to have %s annotation", k)) |  | ||||||
| 		return nil, err |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	log.V(2).Info("Labeled pod", "key", k, "value", v) |  | ||||||
| 
 |  | ||||||
| 	return updated, nil |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| // If the first return value is nil, it's safe to delete the runner pod.
 | // If the first return value is nil, it's safe to delete the runner pod.
 | ||||||
| func ensureRunnerUnregistration(ctx context.Context, retryDelay time.Duration, log logr.Logger, ghClient *github.Client, c client.Client, enterprise, organization, repository, runner string, pod *corev1.Pod) (*ctrl.Result, error) { | func ensureRunnerUnregistration(ctx context.Context, retryDelay time.Duration, log logr.Logger, ghClient *github.Client, c client.Client, enterprise, organization, repository, runner string, pod *corev1.Pod) (*ctrl.Result, error) { | ||||||
|  | @ -210,7 +191,7 @@ func ensureRunnerUnregistration(ctx context.Context, retryDelay time.Duration, l | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if runnerBusy { | 		if runnerBusy { | ||||||
| 			_, err := labelPod(ctx, c, log, pod, AnnotationKeyUnregistrationFailureMessage, runnerUnregistrationFailureMessage) | 			_, err := annotatePodOnce(ctx, c, log, pod, AnnotationKeyUnregistrationFailureMessage, runnerUnregistrationFailureMessage) | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return &ctrl.Result{}, err | 				return &ctrl.Result{}, err | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue