Ejemplo n.º 1
0
 private static bool AddToPodList(string Item)
 {
     return(Locker.LockedAction(POD_LIST_KEY, MemoryService,
                                () =>
     {
         List <string> PodList = GetPodList();
         if (!PodList.Contains(Item))
         {
             PodList.Add(Item);
         }
         return SetPodList(PodList);
     }));
 }
Ejemplo n.º 2
0
        private static void GeneralStatusCheck_Internal(Action <string> _ErrorMessageAction = null)
        {
            //Keep on trying and don't stop.
            while (true)
            {
                try
                {
                    if (!Locker.LockedAction("POD_STATUS_CHECK", MemoryService, () =>
                    {
                        List <string> PodList = GetPodList();

                        for (int i = 0; i < PodList.Count; ++i)
                        {
                            GetLastPodUpdate(PodList[i], out long LastUpdateLong, out string LastStatus, out EPodType _PodType);

                            if (LastStatus == null)
                            {
                                //try again on next pass
                                continue;
                            }

                            DateTime LastUpdate = DateTime.FromBinary(LastUpdateLong);

                            TimeSpan ElapsedTime = DateTime.Now - LastUpdate;

                            //Requeue if unattended for more than a minute and delete if succeeded for more than an hour
                            if (ElapsedTime.TotalSeconds >= 60)
                            {
                                //Succeeded items are left for an hour for now in-case we need this status afterwards
                                //Change if necessary
                                if ((LastStatus == SUCCESS_STATE || LastStatus == COMPLETED_STATE) && ElapsedTime.Hours > 1)
                                {
                                    //If any one fails here it will try again on next pass
                                    DeleteStatus(PodList[i]);
                                    RemoveFromPodList(PodList[i]);

                                    continue;
                                }

                                if (LastStatus != SUCCESS_STATE && LastStatus != COMPLETED_STATE)
                                {
                                    V1Pod CurrentState = PodManager.GetPodByNameAndNamespace(PodList[i], BATCH_NAMESPACE);
                                    GetPodBucketAndFile(PodList[i], out string BucketName, out string Filename, out string ZipMainAssemblyTypeFile);

                                    if (CurrentState != null && BucketName != null && Filename != null)
                                    {
                                        //If pod is still running but polling has somehow died then reregister it for polling
                                        if (CurrentState.Status.Phase == RUNNING_STATE || CurrentState.Status.Phase == PENDING_STATE)
                                        {
                                            if (!Instance.RegisterNewPod(CurrentState, _PodType, BucketName, Filename, ZipMainAssemblyTypeFile))
                                            {
                                                //Will try again on next pass
                                                continue;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        return(true);
                    }))