func()

in pkg/barrier/barrier.go [226:288]


func (b *FrameworkBarrier) Run() {
	klog.Infof("Running %v", ComponentName)

	var f *ci.Framework
	var err error
	var isPassed bool
	var isPermanentErr bool
	wait.PollImmediate(
		common.SecToDuration(&b.bConfig.BarrierCheckIntervalSec),
		common.SecToDuration(&b.bConfig.BarrierCheckTimeoutSec),
		func() (bool, error) {
			f, err = b.fClient.FrameworkcontrollerV1().
				Frameworks(b.bConfig.FrameworkNamespace).
				Get(b.bConfig.FrameworkName, meta.GetOptions{})

			if err == nil {
				err = f.Decompress()
				if err == nil {
					isPassed = isBarrierPassed(f)
					return isPassed, nil
				} else {
					klog.Warningf("Failed to decompress Framework object: %v", err)
					// Unknown Error: Poll Until Timeout
					isPermanentErr = false
					return false, nil
				}
			} else {
				klog.Warningf("Failed to get Framework object from ApiServer: %v", err)
				if apiErrors.IsNotFound(err) {
					// Permanent Error: Early Stop
					isPermanentErr = true
					return false, err
				} else {
					// Unknown Error: Poll Until Timeout
					isPermanentErr = false
					return false, nil
				}
			}
		})

	if isPassed {
		klog.Infof("BarrierSucceeded: " +
			"All Tasks are ready with not nil PodIP.")
		dumpFramework(f)
		generateInjector(f)
		exit(ci.CompletionCodeSucceeded)
	} else {
		if err == nil {
			klog.Errorf("BarrierTransientConflictFailed: " +
				"Timeout to wait all Tasks are ready with not nil PodIP.")
			exit(ci.CompletionCodeContainerTransientConflictFailed)
		} else {
			if isPermanentErr {
				klog.Errorf("BarrierPermanentFailed: %v", err)
				exit(ci.CompletionCodeContainerPermanentFailed)
			} else {
				// May also timeout, but still treat as Unknown Error
				klog.Errorf("BarrierUnknownFailed: %v", err)
				exit(ci.CompletionCode(1))
			}
		}
	}
}