skypilot-nightly 1.0.0.dev20251002__py3-none-any.whl → 1.0.0.dev20251004__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of skypilot-nightly might be problematic. Click here for more details.
- sky/__init__.py +2 -2
- sky/authentication.py +19 -109
- sky/backends/cloud_vm_ray_backend.py +42 -27
- sky/client/cli/command.py +1 -11
- sky/clouds/cudo.py +1 -1
- sky/clouds/kubernetes.py +7 -19
- sky/dashboard/out/404.html +1 -1
- sky/dashboard/out/_next/static/{16g0-hgEgk6Db72hpE8MY → KL03GEega4QqDqTOMtA_w}/_buildManifest.js +1 -1
- sky/dashboard/out/_next/static/chunks/3015-8d748834fcc60b46.js +1 -0
- sky/dashboard/out/_next/static/chunks/8969-66237729cdf9749e.js +1 -0
- sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/{[job]-ad77b12fc736dca3.js → [job]-72794fc3fcdd517a.js} +1 -1
- sky/dashboard/out/_next/static/chunks/{webpack-7340bc0f0dd8ae74.js → webpack-3286453d56f3c0a0.js} +1 -1
- sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
- sky/dashboard/out/clusters/[cluster].html +1 -1
- sky/dashboard/out/clusters.html +1 -1
- sky/dashboard/out/config.html +1 -1
- sky/dashboard/out/index.html +1 -1
- sky/dashboard/out/infra/[context].html +1 -1
- sky/dashboard/out/infra.html +1 -1
- sky/dashboard/out/jobs/[job].html +1 -1
- sky/dashboard/out/jobs/pools/[pool].html +1 -1
- sky/dashboard/out/jobs.html +1 -1
- sky/dashboard/out/users.html +1 -1
- sky/dashboard/out/volumes.html +1 -1
- sky/dashboard/out/workspace/new.html +1 -1
- sky/dashboard/out/workspaces/[name].html +1 -1
- sky/dashboard/out/workspaces.html +1 -1
- sky/data/storage_utils.py +9 -0
- sky/execution.py +24 -2
- sky/global_user_state.py +16 -0
- sky/jobs/recovery_strategy.py +45 -0
- sky/jobs/server/core.py +60 -53
- sky/jobs/state.py +21 -1
- sky/jobs/utils.py +29 -11
- sky/provision/kubernetes/config.py +0 -42
- sky/provision/kubernetes/instance.py +1 -33
- sky/provision/kubernetes/manifests/fusermount-server-daemonset.yaml +1 -2
- sky/provision/kubernetes/network_utils.py +0 -21
- sky/provision/kubernetes/utils.py +136 -300
- sky/server/auth/loopback.py +38 -0
- sky/server/auth/oauth2_proxy.py +6 -0
- sky/server/server.py +6 -0
- sky/setup_files/dependencies.py +1 -0
- sky/templates/kubernetes-ray.yml.j2 +4 -13
- sky/utils/context.py +12 -7
- sky/utils/env_options.py +4 -0
- sky/utils/kubernetes_enums.py +2 -15
- sky/utils/schemas.py +17 -6
- {skypilot_nightly-1.0.0.dev20251002.dist-info → skypilot_nightly-1.0.0.dev20251004.dist-info}/METADATA +38 -37
- {skypilot_nightly-1.0.0.dev20251002.dist-info → skypilot_nightly-1.0.0.dev20251004.dist-info}/RECORD +55 -56
- sky/dashboard/out/_next/static/chunks/3015-88c7c8d69b0b6dba.js +0 -1
- sky/dashboard/out/_next/static/chunks/8969-d8bc3a2b9cf839a9.js +0 -1
- sky/templates/kubernetes-ssh-jump.yml.j2 +0 -94
- sky/utils/kubernetes/ssh_jump_lifecycle_manager.py +0 -191
- /sky/dashboard/out/_next/static/{16g0-hgEgk6Db72hpE8MY → KL03GEega4QqDqTOMtA_w}/_ssgManifest.js +0 -0
- {skypilot_nightly-1.0.0.dev20251002.dist-info → skypilot_nightly-1.0.0.dev20251004.dist-info}/WHEEL +0 -0
- {skypilot_nightly-1.0.0.dev20251002.dist-info → skypilot_nightly-1.0.0.dev20251004.dist-info}/entry_points.txt +0 -0
- {skypilot_nightly-1.0.0.dev20251002.dist-info → skypilot_nightly-1.0.0.dev20251004.dist-info}/licenses/LICENSE +0 -0
- {skypilot_nightly-1.0.0.dev20251002.dist-info → skypilot_nightly-1.0.0.dev20251004.dist-info}/top_level.txt +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3015],{23015:function(e,s,t){t.r(s),t.d(s,{ClusterJobs:function(){return H},ManagedJobs:function(){return Z},ManagedJobsTable:function(){return B},Status2Actions:function(){return q},filterJobsByName:function(){return J},filterJobsByPool:function(){return O},filterJobsByUser:function(){return W},filterJobsByWorkspace:function(){return U},statusGroups:function(){return z}});var a=t(85893),r=t(67294),l=t(11163),n=t(41664),i=t.n(n),c=t(55739),o=t(30803),d=t(37673),u=t(68764),h=t(36989),x=t(51214),m=t(68969),p=t(6378);class j{_generateFilterKey(e){let{allUsers:s=!0,nameMatch:t,userMatch:a,workspaceMatch:r,poolMatch:l,statuses:n}=e;return["allUsers:".concat(s),t?"name:".concat(t):"",a?"user:".concat(a):"",r?"workspace:".concat(r):"",l?"pool:".concat(l):"",n&&n.length>0?"statuses:".concat(n.sort().join(",")):""].filter(Boolean).join("|")||"default"}_getCacheStatus(e){let s=this.fullDataCache.get(e),t=Date.now();if(!s)return{isCached:!1,isFresh:!1,age:0,maxAge:12e4,hasData:!1};let a=t-s.timestamp;return{isCached:!0,isFresh:a<12e4,age:a,maxAge:12e4,hasData:s.jobs&&Array.isArray(s.jobs),data:s}}async getPaginatedJobs(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{page:s=1,limit:t=10,...a}=e,r=this._generateFilterKey(a);try{let e=this._getCacheStatus(r);if(e.isCached&&e.hasData){let l=e.data;if(!l.jobs||Array.isArray(l.jobs)&&0===l.jobs.length){if(!this.prefetching.has(r)){let e=this._loadFullDataset(a,r).catch(()=>{}).finally(()=>this.prefetching.delete(r));this.prefetching.set(r,e)}}else{let n=(s-1)*t,i=l.jobs.slice(n,n+t);if(!this.prefetching.has(r)&&(!e.isFresh||e.age>e.maxAge/2)){let e=this._loadFullDataset(a,r).catch(()=>{}).finally(()=>this.prefetching.delete(r));this.prefetching.set(r,e)}return{jobs:i,total:l.total,totalNoFilter:l.totalNoFilter||l.total,controllerStopped:l.controllerStopped,statusCounts:l.statusCounts||{},fromCache:!0,cacheStatus:e.isFresh?"local_cache_hit":"local_cache_stale_hit"}}}let l=await p.default.get(m.getManagedJobs,[{...a,page:s,limit:t}]),n=(null==l?void 0:l.jobs)||[],i="number"==typeof(null==l?void 0:l.total)?l.total:n.length,c=!!(null==l?void 0:l.controllerStopped);if(!this.prefetching.has(r)){let e=this._loadFullDataset(a,r).catch(e=>{console.warn("Background prefetch of full jobs failed:",e)}).finally(()=>{this.prefetching.delete(r)});this.prefetching.set(r,e)}return{jobs:n,total:i,totalNoFilter:(null==l?void 0:l.totalNoFilter)||i,controllerStopped:c,statusCounts:(null==l?void 0:l.statusCounts)||{},fromCache:!1,cacheStatus:"server_page_fetch"}}catch(e){return console.error("Error in getPaginatedJobs:",e),{jobs:[],total:0,totalNoFilter:0,controllerStopped:!1,statusCounts:{},fromCache:!1,cacheStatus:"error"}}}async _loadFullDataset(e,s){let t=await p.default.get(m.getManagedJobs,[e]);if(t.controllerStopped||!t.jobs)return t;let a={jobs:t.jobs,total:t.jobs.length,totalNoFilter:t.totalNoFilter||t.jobs.length,controllerStopped:!1,statusCounts:t.statusCounts||{},timestamp:Date.now()};return this.fullDataCache.set(s,a),a}isDataLoading(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e);return this.isLoading.has(s)||this.prefetching.has(s)}isDataCached(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e),t=this._getCacheStatus(s);return t.isCached&&t.isFresh&&t.hasData}getCacheStatus(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=this._generateFilterKey(e);return this._getCacheStatus(s)}invalidateCache(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(e){let s=this._generateFilterKey(e);this.fullDataCache.delete(s),this.isLoading.delete(s),this.prefetching.delete(s)}else this.fullDataCache.clear(),this.isLoading.clear(),this.prefetching.clear();p.default.invalidateFunction(m.getManagedJobs)}getCacheStats(){let e={cachedFilters:Array.from(this.fullDataCache.keys()),loadingFilters:Array.from(this.isLoading.keys()),prefetchingFilters:Array.from(this.prefetching.keys()),cacheSize:this.fullDataCache.size,loadingCount:this.isLoading.size,prefetchingCount:this.prefetching.size};for(let[s,t]of(e.detailedStatus={},this.fullDataCache.entries())){let a=this._getCacheStatus(s);e.detailedStatus[s]={age:a.age,isFresh:a.isFresh,hasData:a.hasData,jobCount:t.jobs?t.jobs.length:0}}return e}constructor(){this.fullDataCache=new Map,this.isLoading=new Map,this.prefetching=new Map}}let f=new j;var g=t(23266),b=t(17324),v=t(53081),w=t(13626),y=t(23293),N=t(6521),k=t(16826),C=t(92128),S=t(94545),_=t(99307),L=t(20546),E=t(23001),R=t(88950);let D=(e,s)=>{let t={...e.query},a=[],r=[],l=[];s.map((e,s)=>{var t;a.push(null!==(t=e.property.toLowerCase())&&void 0!==t?t:""),r.push(e.operator),l.push(e.value)}),t.property=a,t.operator=r,t.value=l,e.replace({pathname:e.pathname,query:t},void 0,{shallow:!0})},F=(e,s)=>{let t={...e.query},a=t.property,r=t.operator,l=t.value;if(void 0===a)return[];let n=[],i=Array.isArray(a)?a.length:1;if(1===i)n.push({property:s.get(a),operator:r,value:l});else for(let e=0;e<i;e++)n.push({property:s.get(a[e]),operator:r[e],value:l[e]});return n},M=e=>{var s,t;let{propertyList:l=[],valueList:n,setFilters:i,updateURLParams:c,placeholder:o="Filter items"}=e,d=(0,r.useRef)(null),u=(0,r.useRef)(null),[h,x]=(0,r.useState)(!1),[m,p]=(0,r.useState)(""),[j,f]=(0,r.useState)((null===(s=l[0])||void 0===s?void 0:s.value)||"status"),[g,b]=(0,r.useState)([]);(0,r.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&d.current&&!d.current.contains(e.target)&&x(!1)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[]),(0,r.useEffect)(()=>{let e=[];n&&"object"==typeof n&&(e=n[j]||[]),""!==m.trim()&&(e=e.filter(e=>e&&e.toString().toLowerCase().includes(m.toLowerCase()))),b(e)},[j,n,m]);let v=e=>{let s=l.find(s=>s.value===e);return s?s.label:e},w=e=>{i(s=>{let t=[...s,{property:v(j),operator:":",value:e}];return c(t),t}),x(!1),p(""),d.current.focus()};return(0,a.jsxs)("div",{className:"flex flex-row border border-gray-300 rounded-md overflow-visible",children:[(0,a.jsx)("div",{className:"border-r border-gray-300 flex-shrink-0",children:(0,a.jsxs)(R.Ph,{onValueChange:f,value:j,children:[(0,a.jsx)(R.i4,{"aria-label":"Filter Property",className:"focus:ring-0 focus:ring-offset-0 border-none rounded-l-md rounded-r-none w-20 sm:w-24 md:w-32 h-8 text-xs sm:text-sm",children:(0,a.jsx)(R.ki,{placeholder:(null===(t=l[0])||void 0===t?void 0:t.label)||"Status"})}),(0,a.jsx)(R.Bw,{children:l.map((e,s)=>(0,a.jsx)(R.Ql,{value:e.value,children:e.label},"property-item-".concat(s)))})]})}),(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)("input",{type:"text",ref:d,placeholder:o,value:m,onChange:e=>{p(e.target.value),h||x(!0)},onFocus:()=>{x(!0)},onKeyDown:e=>{"Enter"===e.key&&""!==m.trim()?(i(e=>{let s=[...e,{property:v(j),operator:":",value:m}];return c(s),s}),p(""),x(!1)):"Escape"===e.key&&(x(!1),d.current.blur())},className:"h-8 w-full sm:w-96 px-3 pr-8 text-sm border-none rounded-l-none rounded-r-md focus:ring-0 focus:outline-none",autoComplete:"off"}),m&&(0,a.jsx)("button",{onClick:()=>{p(""),x(!1)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",title:"Clear filter",tabIndex:-1,children:(0,a.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h&&g.length>0&&(0,a.jsx)("div",{ref:u,className:"absolute z-50 mt-1 w-full bg-white border border-gray-200 rounded-md shadow-lg max-h-60 overflow-y-auto",style:{zIndex:9999},children:g.map((e,s)=>(0,a.jsx)("div",{className:"px-3 py-2 cursor-pointer hover:bg-gray-50 text-sm ".concat(s!==g.length-1?"border-b border-gray-100":""),onClick:()=>w(e),children:(0,a.jsx)("span",{className:"text-sm text-gray-700",children:e})},"".concat(e,"-").concat(s)))})]})]})},I=e=>{let{filters:s=[],setFilters:t,updateURLParams:r}=e,l=e=>{t(s=>{let t=s.filter((s,t)=>t!==e);return r(t),t})};return(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"flex items-center gap-4 py-2 px-2",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-content gap-2",children:[s.map((e,s)=>(0,a.jsx)(A,{filter:e,onRemove:()=>l(s)},"filteritem-".concat(s))),s.length>0&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("button",{onClick:()=>{r([]),t([])},className:"rounded-full px-4 py-1 text-sm text-gray-700 bg-gray-200 hover:bg-gray-300",children:"Clear filters"})})]})})})},A=e=>{let{filter:s,onRemove:t}=e;return(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)("div",{className:"flex items-center text-blue-600 bg-blue-100 px-1 py-1 rounded-full text-sm",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 px-2",children:[(0,a.jsx)("span",{children:"".concat(s.property," ")}),(0,a.jsx)("span",{children:"".concat(s.operator," ")}),(0,a.jsx)("span",{children:" ".concat(s.value)})]}),(0,a.jsx)("button",{onClick:()=>t(),className:"p-0.5 ml-1 transform text-gray-400 hover:text-gray-600 bg-blue-500 hover:bg-blue-600 rounded-full flex flex-col items-center",title:"Clear filter",children:(0,a.jsx)("svg",{className:"h-3 w-3",fill:"none",stroke:"white",viewBox:"0 0 24 24",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:5,d:"M6 18L18 6M6 6l12 12"})})})]})})},z={active:["PENDING","RUNNING","RECOVERING","SUBMITTED","STARTING","CANCELLING"],finished:["SUCCEEDED","FAILED","CANCELLED","FAILED_SETUP","FAILED_PRECHECKS","FAILED_NO_RESOURCE","FAILED_CONTROLLER"]},P=[{label:"Name",value:"name"},{label:"User",value:"user"},{label:"Workspace",value:"workspace"},{label:"Pool",value:"pool"}];function J(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.name||"").toLowerCase().includes(t))}function U(e,s){return s&&"ALL_WORKSPACES"!==s?e.filter(e=>(e.workspace||"default").toLowerCase()===s.toLowerCase()):e}function W(e,s){return s&&"ALL_USERS"!==s?e.filter(e=>(e.user_hash||e.user)===s):e}function O(e,s){if(!s||""===s.trim())return e;let t=s.toLowerCase().trim();return e.filter(e=>(e.pool||"").toLowerCase().includes(t))}let T=e=>{if(!e)return"-";let s=e instanceof Date?e:new Date(1e3*e);return(0,a.jsx)(h.Zg,{date:s})};function Z(){let e=(0,l.useRouter)(),[s,t]=(0,r.useState)(!1),[n,c]=(0,r.useState)(!0),[o,d]=(0,r.useState)(!0),u=r.useRef(null),x=r.useRef(null),[j,g]=(0,r.useState)([]),[w,y]=(0,r.useState)([]),N=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t(!0),!e&&o&&c(!0);try{let[e]=await Promise.all([p.default.get(m.vs,[{}])]);g(e.pools||[])}catch(e){console.error("Error fetching data:",e)}finally{t(!1),!e&&o&&(c(!1),d(!1))}};(0,r.useEffect)(()=>{N()},[]);let k=s=>{D(e,s)},C=r.useCallback(()=>{let s=new Map;s.set("",""),s.set("status","Status"),s.set("name","Name"),s.set("user","User"),s.set("workspace","Workspace"),s.set("pool","Pool"),y(F(e,s))},[e,y]);return(0,r.useEffect)(()=>{e.isReady&&C()},[e.isReady,e.query.tab,C]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-1",children:[(0,a.jsx)("div",{className:"text-base",children:(0,a.jsx)(i(),{href:"/jobs",className:"text-sky-blue hover:underline leading-none",children:"Managed Jobs"})}),(0,a.jsx)("div",{className:"w-full sm:w-auto",children:(0,a.jsx)(M,{propertyList:P,valueList:{},setFilters:y,updateURLParams:k,placeholder:"Filter jobs"})})]}),(0,a.jsx)(I,{filters:w,setFilters:y,updateURLParams:k}),(0,a.jsx)(B,{refreshInterval:h.yc,setLoading:t,refreshDataRef:u,filters:w,onRefresh:()=>{f.invalidateCache(),p.default.invalidate(m.vs,[{}]),p.default.invalidate(b.getWorkspaces),p.default.invalidate(v.R),u.current&&u.current(),x.current&&x.current()},poolsData:j,poolsLoading:n}),(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)(V,{refreshInterval:h.yc,setLoading:t,refreshDataRef:x})})]})}function B(e){let{refreshInterval:s,setLoading:t,refreshDataRef:l,filters:n,onRefresh:j,poolsData:b,poolsLoading:v}=e,[N,k]=(0,r.useState)([]),[R,D]=(0,r.useState)(0),[F,M]=(0,r.useState)(0),[I,A]=(0,r.useState)({key:null,direction:"ascending"}),[P,J]=(0,r.useState)(!1),[U,W]=(0,r.useState)(!0),[O,Z]=(0,r.useState)(1),[B,H]=(0,r.useState)(10),[V,Y]=(0,r.useState)(null),Q=(0,r.useRef)(null),[X,$]=(0,r.useState)([]),[ee,es]=(0,r.useState)({}),[et,ea]=(0,r.useState)({}),[er,el]=(0,r.useState)(!1),[en,ei]=(0,r.useState)(!1),[ec,eo]=(0,r.useState)(!1),[ed,eu]=(0,r.useState)("all"),[eh,ex]=(0,r.useState)(!0),[em,ep]=(0,r.useState)({isOpen:!1,title:"",message:"",onConfirm:null}),ej=(0,E.X)(),ef=(0,r.useRef)(0),eg=async()=>{ep({isOpen:!0,title:"Restart Controller",message:"Are you sure you want to restart the controller?",onConfirm:async()=>{try{eo(!0),J(!0),await (0,m.Ce)("restartcontroller"),await eb()}catch(e){console.error("Error restarting controller:",e)}finally{eo(!1),J(!1)}}})},eb=r.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=!1!==e.includeStatus,a=ef.current+1;ef.current=a,J(!0),t(!0);try{let e,t;let r=e=>{let s=(n||[]).find(s=>(s.property||"").toLowerCase()===e);return s&&s.value?String(s.value):void 0};X.length>0?t=X:eh?"active"===ed?t=z.active:"finished"===ed&&(t=z.finished):t=[];let l={allUsers:!0,nameMatch:r("name"),userMatch:r("user"),workspaceMatch:r("workspace"),poolMatch:r("pool"),statuses:t,page:O,limit:B},i=null;if(f.isDataCached(l),f.isDataLoading(l),s){let[s,t]=await Promise.all([f.getPaginatedJobs(l),p.default.get(g.getClusters)]);e=s,i=t}else e=await f.getPaginatedJobs(l);let{jobs:c=[],total:o=0,totalNoFilter:d=0,controllerStopped:u=!1,cacheStatus:h="unknown",statusCounts:x={}}=e||{},m=!1,j=!1;if(s&&i){let e=null==i?void 0:i.find(e=>(0,S.Ym)(e.cluster)),s=e?e.status:"NOT_FOUND";"STOPPED"==s&&u&&(m=!0),"LAUNCHING"==s&&(j=!0)}a===ef.current&&(k(c),D(o||0),M(d||0),el(!!m),ei(!!j),ea(x),W(!1))}catch(e){console.error("Error fetching data:",e),a===ef.current&&(k([]),el(!1),W(!1))}finally{a===ef.current&&(J(!1),t(!1))}},[t,n,O,B,X,eh,ed]);r.useEffect(()=>{l&&(l.current=eb)},[l,eb]);let ev=r.useRef(eb);r.useEffect(()=>{ev.current=eb},[eb]),r.useEffect(()=>{eb({includeStatus:!0})},[]),r.useEffect(()=>{eb({includeStatus:!1})},[O]),r.useEffect(()=>{eb({includeStatus:!0})},[n,B]),r.useEffect(()=>{eb({includeStatus:!0})},[ed,X,eh]),(0,r.useEffect)(()=>{let e=setInterval(()=>{ev.current&&ev.current({includeStatus:!0})},s);return()=>{clearInterval(e)}},[s]),(0,r.useEffect)(()=>{Z(1)},[ed]),(0,r.useEffect)(()=>{Z(1)},[n,B]),(0,r.useEffect)(()=>{$([]),ex(!0)},[ed]);let ew=e=>{let s="ascending";I.key===e&&"ascending"===I.direction&&(s="descending"),A({key:e,direction:s})},ey=e=>I.key===e?"ascending"===I.direction?" ↑":" ↓":"";r.useMemo(()=>{let e=N||[];return{active:e.filter(e=>z.active.includes(e.status)).length,finished:e.filter(e=>z.finished.includes(e.status)).length}},[N]);let eN=e=>X.length>0?X.includes(e):"all"===ed||z[ed].includes(e),ek=r.useMemo(()=>N,[N]),eC=r.useMemo(()=>I.key?[...ek].sort((e,s)=>e[I.key]<s[I.key]?"ascending"===I.direction?-1:1:e[I.key]>s[I.key]?"ascending"===I.direction?1:-1:0):ek,[ek,I]),eS=(O-1)*B,e_=R>0?Math.ceil(R/B):0,eL=R>0?Math.min(eS+eC.length,R):0,eE=e=>{if(X.includes(e)){let s=X.filter(s=>s!==e);0===s.length?(ex(!0),$([])):($(s),ex(!1))}else $([...X,e]),ex(!1);Z(1)};return(0,r.useEffect)(()=>{es(et)},[et]),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("div",{className:"flex flex-col space-y-1 mb-1",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between text-sm mb-1",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center",children:[(0,a.jsx)("span",{className:"mr-2 text-sm font-medium",children:"Statuses:"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[!P&&0===F&&!U&&(0,a.jsx)("span",{className:"text-gray-500 mr-2",children:"No jobs found"}),Object.entries(ee).map(e=>{let[s,t]=e;return(0,a.jsxs)("button",{onClick:()=>eE(s),className:"px-3 py-0.5 rounded-full flex items-center space-x-2 ".concat(eN(s)||X.includes(s)?(0,_.Cl)(s):"bg-gray-50 text-gray-600 hover:bg-gray-100"),children:[(0,a.jsx)("span",{children:s}),(0,a.jsx)("span",{className:"text-xs ".concat(eN(s)||X.includes(s)?"bg-white/50":"bg-gray-200"," px-1.5 py-0.5 rounded"),children:t})]},s)}),F>0&&(0,a.jsxs)("div",{className:"flex items-center ml-2 gap-2",children:[(0,a.jsx)("span",{className:"text-gray-500",children:"("}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("all"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("all"===ed&&eh?"text-purple-700 underline":"text-gray-600 hover:text-purple-700 hover:underline"),children:"show all jobs"}),(0,a.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("active"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("active"===ed&&eh?"text-green-700 underline":"text-gray-600 hover:text-green-700 hover:underline"),children:"show all active jobs"}),(0,a.jsx)("span",{className:"text-gray-500 mx-1",children:"|"}),(0,a.jsx)("button",{onClick:()=>{r.startTransition(()=>{eu("finished"),$([]),ex(!0),Z(1)})},className:"text-sm font-medium ".concat("finished"===ed&&eh?"text-blue-700 underline":"text-gray-600 hover:text-blue-700 hover:underline"),children:"show all finished jobs"}),(0,a.jsx)("span",{className:"text-gray-500",children:")"})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[P&&(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500 text-sm",children:"Loading..."})]}),(0,a.jsxs)("button",{onClick:()=>{j&&j()},disabled:P,className:"text-sky-blue hover:text-sky-blue-bright flex items-center text-sm",children:[(0,a.jsx)(w.Z,{className:"h-4 w-4 mr-1.5"}),(0,a.jsx)("span",{children:"Refresh"})]})]})]})}),ej&&er&&0===eC.length&&!P&&!U&&(0,a.jsx)("div",{className:"mb-4 p-4 bg-gray-50 rounded-lg border",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,a.jsxs)("p",{className:"text-gray-700 text-center text-sm",children:["Job controller stopped.",(0,a.jsx)("br",{}),"Restart to check status."]}),(0,a.jsx)(o.z,{variant:"outline",size:"sm",onClick:eg,className:"text-sky-blue hover:text-sky-blue-bright",disabled:P||ec,children:ec?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y.Z,{className:"h-4 w-4 mr-2"}),"Restart"]})})]})}),(0,a.jsx)(d.Zb,{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,a.jsxs)(u.iA,{className:"min-w-full",children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("id"),children:["ID",ey("id")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("name"),children:["Name",ey("name")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("user"),children:["User",ey("user")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("workspace"),children:["Workspace",ey("workspace")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("submitted_at"),children:["Submitted",ey("submitted_at")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("job_duration"),children:["Duration",ey("job_duration")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("status"),children:["Status",ey("status")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("resources_str"),children:["Requested",ey("resources_str")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("infra"),children:["Infra",ey("infra")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("cluster"),children:["Resources",ey("cluster")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("recoveries"),children:["Recoveries",ey("recoveries")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>ew("pool"),children:["Worker Pool",ey("pool")]}),(0,a.jsx)(u.ss,{children:"Details"}),(0,a.jsx)(u.ss,{children:"Logs"})]})}),(0,a.jsx)(u.RM,{children:P&&U?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:12,className:"text-center py-6 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]})})}):eC.length>0?(0,a.jsx)(a.Fragment,{children:eC.map(e=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)(u.SC,{children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.id})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/".concat(e.id),className:"text-blue-600",children:e.name})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,a.jsx)(u.pj,{children:T(e.submitted_at)}),(0,a.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(_.OE,{status:e.status})}),(0,a.jsx)(u.pj,{children:e.requested_resources}),(0,a.jsx)(u.pj,{children:e.infra&&"-"!==e.infra?(0,a.jsx)(h.Md,{content:e.full_infra||e.infra,className:"text-sm text-muted-foreground",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(i(),{href:"/infra",className:"text-blue-600 hover:underline",children:e.cloud||e.infra.split("(")[0].trim()}),e.infra.includes("(")&&(0,a.jsx)("span",{children:" "+(()=>{let s=x.MO.NAME_TRUNCATE_LENGTH,t=e.infra.substring(e.infra.indexOf("(")),a=t.substring(1,t.length-1);if(a.length<=s)return t;let r="".concat(a.substring(0,Math.floor((s-3)/2)),"...").concat(a.substring(a.length-Math.ceil((s-3)/2)));return"(".concat(r,")")})()})]})}):(0,a.jsx)("span",{children:e.infra||"-"})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(h.Md,{content:e.resources_str_full||e.resources_str,className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{children:e.resources_str})})}),(0,a.jsx)(u.pj,{children:e.recoveries}),(0,a.jsx)(u.pj,{children:(0,a.jsx)("div",{className:v?"blur-sm transition-all duration-300":"",children:v?"-":(0,h.os)(e.pool,e.pool_hash,b)})}),(0,a.jsx)(u.pj,{children:e.details?(0,a.jsx)(G,{text:e.details,rowId:e.id,expandedRowId:V,setExpandedRowId:Y}):"-"}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(q,{jobParent:"/jobs",jobId:e.id,managed:!0,workspace:e.workspace})})]}),V===e.id&&(0,a.jsx)(K,{text:e.details,colSpan:13,innerRef:Q})]},e.task_job_id))}):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:13,className:"text-center py-6",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[en&&(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,a.jsx)("p",{className:"text-gray-700",children:"The managed job controller is launching. It will be ready shortly."}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Launching..."})]})]}),!er&&!en&&(0,a.jsx)("p",{className:"text-gray-500",children:"No active jobs"}),!ej&&er&&(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-3 px-4",children:[(0,a.jsx)("p",{className:"text-gray-700 text-center text-sm sm:text-base max-w-md",children:"The managed job controller has been stopped. Restart to check the latest job status."}),(0,a.jsx)(o.z,{variant:"outline",size:"sm",onClick:eg,className:"text-sky-blue hover:text-sky-blue-bright",disabled:P||ec,children:ec?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.Z,{size:12,className:"mr-2"}),"Restarting..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y.Z,{className:"h-4 w-4 mr-2"}),"Restart Controller"]})})]})]})})})})]})})}),(0,a.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,a.jsxs)("div",{className:"relative inline-block",children:[(0,a.jsxs)("select",{value:B,onChange:e=>{H(parseInt(e.target.value,10)),Z(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:30,children:"30"}),(0,a.jsx)("option",{value:50,children:"50"}),(0,a.jsx)("option",{value:100,children:"100"}),(0,a.jsx)("option",{value:200,children:"200"})]}),(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500 absolute right-0 top-1/2 transform -translate-y-1/2 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,a.jsx)("div",{children:R>0?"".concat(eS+1," – ").concat(eL," of ").concat(R):"0 – 0 of 0"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{Z(e=>Math.max(e-1,1))},disabled:1===O||!eC||0===eC.length,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-left",children:(0,a.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{e_>0&&O<e_&&Z(e=>e+1)},disabled:0===e_||O>=e_||!eC||0===eC.length,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-right",children:(0,a.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})}),(0,a.jsx)(C.cV,{isOpen:em.isOpen,onClose:()=>ep({...em,isOpen:!1}),onConfirm:em.onConfirm,title:em.title,message:em.message,confirmClassName:"bg-blue-600 hover:bg-blue-700 text-white"})]})}function q(e){let{withLabel:s=!1,jobParent:t,jobId:r,managed:n,workspace:i="default"}=e,c=(0,l.useRouter)(),o=(e,s)=>{e.preventDefault(),e.stopPropagation(),c.push({pathname:"".concat(t,"/").concat(r),query:{tab:s}})},d=function(e){let s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(e.preventDefault(),e.stopPropagation(),n)(0,m.jh)({jobId:parseInt(r),controller:s});else{let e=t.match(/\/clusters\/(.+)/);if(e){let s=e[1];(0,g.GH)({clusterName:s,jobIds:[r],workspace:i})}}};return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(h.WH,{content:"View Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,a.jsxs)("button",{onClick:e=>o(e,"logs"),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,a.jsx)(N.Z,{className:"w-4 h-4"}),s&&(0,a.jsx)("span",{className:"ml-1.5",children:"Logs"})]})},"logs"),(0,a.jsx)(h.WH,{content:"Download Job Logs",className:"capitalize text-sm text-muted-foreground",children:(0,a.jsxs)("button",{onClick:e=>d(e,!1),className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,a.jsx)(k.Z,{className:"w-4 h-4"}),s&&(0,a.jsx)("span",{className:"ml-1.5",children:"Download"})]})},"downloadlogs")]})}function H(e){let{clusterName:s,clusterJobData:t,loading:l,refreshClusterJobsOnly:n,userFilter:x=null,nameFilter:m=null,workspace:p="default"}=e,[j,f]=(0,r.useState)(null),[g,b]=(0,r.useState)({key:null,direction:"ascending"}),[v,y]=(0,r.useState)(1),[N,k]=(0,r.useState)(10),C=(0,r.useRef)(null),[S,E]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=e=>{j&&C.current&&!C.current.contains(e.target)&&f(null)};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[j]);let R=r.useMemo(()=>{let e=t||[];return x&&"ALL_USERS"!==x&&(e=W(e,x)),m&&(e=J(e,m)),e},[t,x,m]);(0,r.useEffect)(()=>{JSON.stringify(t)!==JSON.stringify(S)&&E(t)},[t,S]);let D=r.useMemo(()=>g.key?[...R].sort((e,s)=>e[g.key]<s[g.key]?"ascending"===g.direction?-1:1:e[g.key]>s[g.key]?"ascending"===g.direction?1:-1:0):R,[R,g]),F=e=>{let s="ascending";g.key===e&&"ascending"===g.direction&&(s="descending"),b({key:e,direction:s})},M=e=>g.key===e?"ascending"===g.direction?" ↑":" ↓":"",I=Math.ceil(D.length/N),A=(v-1)*N,z=A+N,P=D.slice(A,z);return(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)(d.Zb,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Cluster Jobs"}),(0,a.jsx)("div",{className:"flex items-center",children:n&&(0,a.jsxs)("button",{onClick:n,disabled:l,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center text-sm ml-2",children:[(0,a.jsx)(w.Z,{className:"w-4 h-4 mr-1"}),"Refresh Jobs"]})})]}),(0,a.jsxs)(u.iA,{children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("id"),children:["ID",M("id")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("job"),children:["Name",M("job")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("user"),children:["User",M("user")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("workspace"),children:["Workspace",M("workspace")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("submitted_at"),children:["Submitted",M("submitted_at")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("job_duration"),children:["Duration",M("job_duration")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("status"),children:["Status",M("status")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap",onClick:()=>F("resources"),children:["Resources",M("resources")]}),(0,a.jsx)(u.ss,{className:"whitespace-nowrap",children:"Logs"})]})}),(0,a.jsx)(u.RM,{children:l?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:9,className:"text-center py-12 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading cluster jobs..."})]})})}):P.length>0?P.map(e=>(0,a.jsxs)(r.Fragment,{children:[(0,a.jsxs)(u.SC,{className:j===e.id?"selected-row":"",children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:e.id})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/clusters/".concat(s,"/").concat(e.id),className:"text-blue-600",children:(0,a.jsx)(G,{text:e.job||"Unnamed job",rowId:e.id,expandedRowId:j,setExpandedRowId:f})})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(L.H,{username:e.user,userHash:e.user_hash})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:e.workspace||"default"})}),(0,a.jsx)(u.pj,{children:T(e.submitted_at)}),(0,a.jsx)(u.pj,{children:(0,h.LU)(e.job_duration)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(_.OE,{status:e.status})}),(0,a.jsx)(u.pj,{children:e.resources}),(0,a.jsx)(u.pj,{className:"flex content-center items-center",children:(0,a.jsx)(q,{jobParent:"/clusters/".concat(s),jobId:e.id,managed:!1,workspace:p})})]}),j===e.id&&(0,a.jsx)(K,{text:e.job||"Unnamed job",colSpan:9,innerRef:C})]},e.id)):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:8,className:"text-center py-6 text-gray-500",children:"No jobs found"})})})]})]}),D&&D.length>0&&(0,a.jsx)("div",{className:"flex justify-end items-center py-2 px-4 text-sm text-gray-700",children:(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("span",{className:"mr-2",children:"Rows per page:"}),(0,a.jsxs)("div",{className:"relative inline-block",children:[(0,a.jsxs)("select",{value:N,onChange:e=>{k(parseInt(e.target.value,10)),y(1)},className:"py-1 pl-2 pr-6 appearance-none outline-none cursor-pointer border-none bg-transparent",style:{minWidth:"40px"},children:[(0,a.jsx)("option",{value:5,children:"5"}),(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:20,children:"20"}),(0,a.jsx)("option",{value:50,children:"50"})]}),(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4 text-gray-500 absolute right-0 top-1/2 transform -translate-y-1/2 pointer-events-none",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})]}),(0,a.jsxs)("div",{children:[A+1," – ",Math.min(z,D.length)," of"," ",D.length]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{y(e=>Math.max(e-1,1))},disabled:1===v,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-left",children:(0,a.jsx)("path",{d:"M15 18l-6-6 6-6"})})}),(0,a.jsx)(o.z,{variant:"ghost",size:"icon",onClick:()=>{y(e=>Math.min(e+1,I))},disabled:v===I||0===I,className:"text-gray-500 h-8 w-8 p-0",children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"chevron-right",children:(0,a.jsx)("path",{d:"M9 18l6-6-6-6"})})})]})]})})]})}function K(e){let{text:s,colSpan:t,innerRef:r}=e;return(0,a.jsx)(u.SC,{className:"expanded-details",children:(0,a.jsx)(u.pj,{colSpan:t,children:(0,a.jsx)("div",{className:"p-4 bg-gray-50 rounded-md border border-gray-200",ref:r,children:(0,a.jsx)("div",{className:"flex justify-between items-start",children:(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-gray-900",children:"Full Details"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-gray-700",style:{whiteSpace:"pre-wrap"},children:s})]})})})})})}function G(e){let{text:s,rowId:t,expandedRowId:l,setExpandedRowId:n}=e,i=s||"",c=i.length>50,o=l===t,d=c?"".concat(i.substring(0,50)):i,u=(0,r.useRef)(null);return(0,a.jsxs)("div",{className:"truncated-details relative max-w-full flex items-center",children:[(0,a.jsx)("span",{className:"truncate",children:d}),c&&(0,a.jsx)("button",{ref:u,type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),n(o?null:t)},className:"text-blue-600 hover:text-blue-800 font-medium ml-1 flex-shrink-0","data-button-type":"show-more-less",children:o?"... show less":"... show more"})]})}function V(e){let{refreshInterval:s,setLoading:t,refreshDataRef:l}=e,[n,o]=(0,r.useState)([]),[x,j]=(0,r.useState)({key:null,direction:"ascending"}),[f,g]=(0,r.useState)(!1),[b,v]=(0,r.useState)(!0),[w,y]=(0,r.useState)(1),[N,k]=(0,r.useState)(10),C=r.useCallback(async()=>{g(!0),t(!0);try{let{pools:e=[]}=await p.default.get(m.vs,[{}])||{};o(e),v(!1)}catch(e){console.error("Error fetching pools data:",e),o([]),v(!1)}finally{g(!1),t(!1)}},[t]);r.useEffect(()=>{l&&(l.current=C)},[l,C]),(0,r.useEffect)(()=>{o([]);let e=!0;C();let t=setInterval(()=>{e&&C()},s);return()=>{e=!1,clearInterval(t)}},[s,C]);let S=e=>{let s="ascending";x.key===e&&"ascending"===x.direction&&(s="descending"),j({key:e,direction:s})},L=e=>x.key===e?"ascending"===x.direction?" ↑":" ↓":"",E=r.useMemo(()=>x.key?[...n].sort((e,s)=>e[x.key]<s[x.key]?"ascending"===x.direction?-1:1:e[x.key]>s[x.key]?"ascending"===x.direction?1:-1:0):n,[n,x]),R=Math.ceil(E.length/N),D=(w-1)*N,F=D+N,M=E.slice(D,F),I=e=>{if(!e||!e.replica_info||0===e.replica_info.length)return"0 (target: 0)";let s=e.replica_info.filter(e=>"READY"===e.status).length,t=e.target_num_replicas||0;return"".concat(s," (target: ").concat(t,")")},A=e=>{let{jobCounts:s}=e;return(0,a.jsx)(h.x9,{jobCounts:s,getStatusStyle:_.Cl})},z=e=>{let{replicaInfo:s}=e;return(0,a.jsx)(h.Kl,{replicaInfo:s})};return(0,a.jsxs)(d.Zb,{children:[(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg",children:(0,a.jsxs)(u.iA,{className:"min-w-full table-fixed",children:[(0,a.jsx)(u.xD,{children:(0,a.jsxs)(u.SC,{children:[(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-32",onClick:()=>S("name"),children:["Pool",L("name")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-40",onClick:()=>S("job_counts"),children:["Jobs",L("job_counts")]}),(0,a.jsx)(u.ss,{className:"whitespace-nowrap w-20",children:"Workers"}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-36",onClick:()=>S("requested_resources_str"),children:["Worker Details",L("requested_resources_str")]}),(0,a.jsxs)(u.ss,{className:"sortable whitespace-nowrap w-40",onClick:()=>S("requested_resources_str"),children:["Worker Resources",L("requested_resources_str")]})]})}),(0,a.jsx)(u.RM,{children:f&&b?(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:(0,a.jsxs)("div",{className:"flex justify-center items-center",children:[(0,a.jsx)(c.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]})})}):M.length>0?M.map(e=>(0,a.jsxs)(u.SC,{children:[(0,a.jsx)(u.pj,{children:(0,a.jsx)(i(),{href:"/jobs/pools/".concat(e.name),className:"text-blue-600 hover:text-blue-800",children:e.name})}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(A,{jobCounts:e.jobCounts})}),(0,a.jsx)(u.pj,{children:I(e)}),(0,a.jsx)(u.pj,{children:(0,a.jsx)(z,{replicaInfo:e.replica_info})}),(0,a.jsx)(u.pj,{children:e.requested_resources_str||"-"})]},e.name)):(0,a.jsx)(u.SC,{children:(0,a.jsx)(u.pj,{colSpan:5,className:"text-center py-6 text-gray-500",children:"No pools found"})})})]})}),M.length>0&&R>1&&(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-gray-200",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"text-sm text-gray-700",children:"Rows per page:"}),(0,a.jsxs)("select",{value:N,onChange:e=>{k(parseInt(e.target.value,10)),y(1)},className:"border border-gray-300 rounded px-2 py-1 text-sm",children:[(0,a.jsx)("option",{value:5,children:"5"}),(0,a.jsx)("option",{value:10,children:"10"}),(0,a.jsx)("option",{value:25,children:"25"}),(0,a.jsx)("option",{value:50,children:"50"})]})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)("span",{className:"text-sm text-gray-700",children:[D+1,"-",Math.min(F,E.length)," of"," ",E.length]}),(0,a.jsx)("button",{onClick:()=>{y(e=>Math.max(e-1,1))},disabled:1===w,className:"px-2 py-1 text-sm border border-gray-300 rounded disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Previous"}),(0,a.jsx)("button",{onClick:()=>{y(e=>Math.min(e+1,R))},disabled:w===R,className:"px-2 py-1 text-sm border border-gray-300 rounded disabled:opacity-50 disabled:cursor-not-allowed hover:bg-gray-50",children:"Next"})]})]})]})}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8969],{68969:function(e,t,o){o.d(t,{Ce:function(){return p},NJ:function(){return h},UA:function(){return u},aT:function(){return i},getManagedJobs:function(){return l},jh:function(){return b},vs:function(){return d}});var r=o(67294),a=o(15821),n=o(93225),c=o(6378),s=o(47145);async function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var t;let{allUsers:o=!0,skipFinished:r=!1,nameMatch:a,userMatch:c,workspaceMatch:l,poolMatch:i,page:d,limit:u,statuses:h}=e,p={all_users:o,verbose:!0,skip_finished:r};void 0!==a&&(p.name_match=a),void 0!==c&&(p.user_match=c),void 0!==l&&(p.workspace_match=l),void 0!==i&&(p.pool_match=i),void 0!==d&&(p.page=d),void 0!==u&&(p.limit=u),void 0!==h&&h.length>0&&(p.statuses=h);let b=(await s.x.post("/jobs/queue/v2",p)).headers.get("X-Skypilot-Request-ID"),f=await s.x.get("/api/get?request_id=".concat(b));if(500===f.status){try{let e=await f.json();if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);if(t.type&&t.type===n.iW)return{jobs:[],total:0,controllerStopped:!0}}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{jobs:[],total:0,controllerStopped:!1}}let g=await f.json(),m=g.return_value?JSON.parse(g.return_value):[],_=Array.isArray(m)?m:(null==m?void 0:m.jobs)||[],y=Array.isArray(m)?_.length:null!==(t=null==m?void 0:m.total)&&void 0!==t?t:_.length,w=(null==m?void 0:m.total_no_filter)||y,j=(null==m?void 0:m.status_counts)||{};return{jobs:_.map(e=>{var t;let o=0;e.end_at&&e.submitted_at?o=e.end_at-e.submitted_at:e.submitted_at&&(o=Date.now()/1e3-e.submitted_at);let r=[];e.submitted_at&&r.push({type:"PENDING",timestamp:e.submitted_at}),e.start_at&&r.push({type:"RUNNING",timestamp:e.start_at}),e.end_at&&r.push({type:e.status,timestamp:e.end_at});let a="",n="",c="",s="",l="";try{if(a=e.cloud||"",c=e.cluster_resources,n=e.region||"",a&&(s=a,n&&(s+="/".concat(n))),l=s,e.accelerators){let t=Object.entries(e.accelerators).map(e=>{let[t,o]=e;return"".concat(o,"x").concat(t)}).join(", ");t&&(l+=" (".concat(t,")"))}}catch(t){c=e.cluster_resources}return{id:e.job_id,task_job_id:e._job_id,task:e.task_name,name:e.job_name,job_duration:e.job_duration,total_duration:o,workspace:e.workspace,status:e.status,requested_resources:e.resources,resources_str:c,resources_str_full:e.cluster_resources_full||c,cloud:a,region:e.region,infra:s,full_infra:l,recoveries:e.recovery_count,details:e.details||e.failure_reason,user:e.user_name,user_hash:e.user_hash,submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,events:r,dag_yaml:e.user_yaml,entrypoint:e.entrypoint,git_commit:(null===(t=e.metadata)||void 0===t?void 0:t.git_commit)||"-",pool:e.pool,pool_hash:e.pool_hash,current_cluster_name:e.current_cluster_name,job_id_on_pool_cluster:e.job_id_on_pool_cluster}}),total:y,totalNoFilter:w,controllerStopped:!1,statusCounts:j}}catch(e){return console.error("Error fetching managed job data:",e),{jobs:[],total:0,totalNoFilter:0,controllerStopped:!1,statusCounts:{}}}}async function i(e){let{allUsers:t=!0,nameMatch:o,userMatch:r,workspaceMatch:a,poolMatch:n,page:c=1,limit:s=10,useClientPagination:i=!0}=e||{};try{if(!i)return await l(e);let d=await l({allUsers:t,nameMatch:o,userMatch:r,workspaceMatch:a,poolMatch:n});if(d.controllerStopped||!d.jobs)return d;let u=d.jobs,h=u.length,p=(c-1)*s;return{jobs:u.slice(p,p+s),total:h,controllerStopped:!1}}catch(e){return console.error("Error fetching managed job data with client pagination:",e),{jobs:[],total:0,controllerStopped:!1}}}async function d(){try{let e=(await s.x.post("/jobs/pool_status",{pool_names:null})).headers.get("X-Skypilot-Request-ID"),t=await s.x.get("/api/get?request_id=".concat(e));if(500===t.status){try{let e=await t.json();if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);if(t.type&&t.type===n.iW)return{pools:[],controllerStopped:!0}}catch(e){console.error("Failed to parse error JSON:",e)}}catch(e){console.error("Failed to parse response JSON:",e)}throw Error("Server error")}let o=await t.json(),r=o.return_value?JSON.parse(o.return_value):[],a={jobs:[]};try{let e=await l({allUsers:!0,skipFinished:!0});e.controllerStopped||(a=e)}catch(e){console.warn("Failed to fetch jobs for pool job counts:",e)}let c={},i=["SUCCEEDED","FAILED","FAILED_SETUP","FAILED_PRECHECKS","FAILED_NO_RESOURCE","FAILED_CONTROLLER","CANCELLED"];return a.jobs&&Array.isArray(a.jobs)&&a.jobs.forEach(e=>{let t=e.pool,o=e.status;t&&!i.includes(o)&&(c[t]||(c[t]={}),c[t][o]=(c[t][o]||0)+1)}),{pools:r.map(e=>({...e,jobCounts:c[e.name]||{}})),controllerStopped:!1}}catch(e){throw console.error("Error fetching pools:",e),e}}function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,[o,a]=(0,r.useState)(null),[n,s]=(0,r.useState)(!0);return(0,r.useEffect)(()=>{(async function(){if(e)try{var t;s(!0);let o=await c.default.get(l,[{allUsers:!0}]),r=null==o?void 0:null===(t=o.jobs)||void 0===t?void 0:t.find(t=>String(t.id)===String(e));r?a({jobs:[r],controllerStopped:o.controllerStopped||!1}):a({jobs:[],controllerStopped:o.controllerStopped||!1})}catch(e){console.error("Error fetching single managed job data:",e),a({jobs:[],controllerStopped:!1})}finally{s(!1)}})()},[e,t]),{jobData:o,loading:n}}async function h(e){let t,{jobId:o,controller:r=!1,signal:c,onNewLog:s}=e,l=Date.now(),i=new Promise(e=>{let o=()=>{let r=Date.now()-l;r>=3e4?e({timeout:!0}):t=setTimeout(o,3e4-r)};t=setTimeout(o,3e4)}),d=window.location.origin,u="".concat(d).concat(n.f4),h=(async()=>{try{let e=(await fetch("".concat(u,"/jobs/logs"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({controller:r,follow:!1,job_id:o,tail:1e4}),...c?{signal:c}:{}})).body.getReader();try{for(;;){let{done:t,value:o}=await e.read();if(t)break;l=Date.now();let r=new TextDecoder().decode(o);s(r)}}finally{if(!c||!c.aborted)try{e.cancel()}catch(e){"AbortError"!==e.name&&console.warn("Error canceling reader:",e)}t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),p=await Promise.race([h,i]);if(t&&clearTimeout(t),p.timeout){(0,a.C)("Log request for job ".concat(o," timed out after ").concat(30,"s of inactivity"),"warning");return}}async function p(e,t,o){let r="",c="",s="",l={};if("restartcontroller"===e)r="Restarting",c="restarted",s="jobs/queue/v2",l={all_users:!0,refresh:!0},t="controller";else throw Error("Invalid action: ".concat(e));(0,a.C)("".concat(r," job ").concat(t,"..."),"info");let i=window.location.origin,d="".concat(i).concat(n.f4);try{try{let e=(await fetch("".concat(d,"/").concat(s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})).headers.get("X-Skypilot-Request-ID"),i=await fetch("".concat(d,"/api/get?request_id=").concat(e));if(200===i.status)(0,a.C)("Job ".concat(t," ").concat(c," successfully."),"success");else if(500===i.status)try{let e=await i.json();if(e.detail&&e.detail.error)try{let c=JSON.parse(e.detail.error);c.type&&c.type===n.Bo?(0,a.C)("".concat(r," job ").concat(t," is not supported!"),"error",1e4):c.type&&c.type===n.mF?(0,a.C)("Cluster ".concat(o," does not exist."),"error"):c.type&&c.type===n.iW?(0,a.C)("Cluster ".concat(o," is not up."),"error"):(0,a.C)("".concat(r," job ").concat(t," failed: ").concat(c.type),"error")}catch(o){(0,a.C)("".concat(r," job ").concat(t," failed: ").concat(e.detail.error),"error")}else(0,a.C)("".concat(r," job ").concat(t," failed with no details."),"error")}catch(e){(0,a.C)("".concat(r," job ").concat(t," failed with parse error."),"error")}else(0,a.C)("".concat(r," job ").concat(t," failed with status ").concat(i.status,"."),"error")}catch(e){console.error("Fetch error:",e),(0,a.C)("Network error ".concat(r," job ").concat(t,": ").concat(e.message),"error")}}catch(e){console.error("Error in handleStop:",e),(0,a.C)("Critical error ".concat(r," job ").concat(t,": ").concat(e.message),"error")}}async function b(e){let{jobId:t=null,name:o=null,controller:r=!1}=e;try{let e=await s.x.fetch("/jobs/download_logs",{job_id:t,name:o,controller:r,refresh:!1}),c=Object.values(e||{});if(!c.length){(0,a.C)("No logs found to download.","warning");return}let l=window.location.origin,i="".concat(l).concat(n.f4,"/download"),d=await fetch("".concat(i,"?relative=items"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folder_paths:c})});if(!d.ok){let e=await d.text();throw Error("Download failed: ".concat(d.status," ").concat(e))}let u=await d.blob(),h=window.URL.createObjectURL(u),p=document.createElement("a"),b=new Date().toISOString().replace(/[:.]/g,"-"),f=t?"job-".concat(t):o?"job-".concat(o):"job";p.href=h,p.download="managed-".concat(f,"-").concat(r?"controller-logs":"logs","-").concat(b,".zip"),document.body.appendChild(p),p.click(),p.remove(),window.URL.revokeObjectURL(h)}catch(e){console.error("Error downloading managed job logs:",e),(0,a.C)("Error downloading managed job logs: ".concat(e.message),"error")}}},15821:function(e,t,o){o.d(t,{C:function(){return r}});function r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,r=document.getElementById("toast-container");r||((r=document.createElement("div")).id="toast-container",r.className="fixed top-0 right-0 p-4 z-[9999] flex flex-col items-end space-y-2",document.body.appendChild(r));let a=document.createElement("div");switch(a.className="rounded-md border-l-4 p-4 shadow-md flex items-center justify-between max-w-md w-full mb-2 pointer-events-auto",t){case"success":a.className+=" bg-green-100 border-green-500 text-green-800";break;case"error":a.className+=" bg-red-100 border-red-500 text-red-800";break;case"warning":a.className+=" bg-yellow-100 border-yellow-500 text-yellow-800";break;default:a.className+=" bg-blue-100 border-blue-500 text-blue-800"}return a.innerHTML='\n <div class="flex-1 mr-2">\n <p class="text-sm font-medium">'.concat(e,'</p>\n </div>\n <button class="text-gray-500 hover:text-gray-700 focus:outline-none" aria-label="Close toast">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n </button>\n '),r.appendChild(a),a.querySelector("button").addEventListener("click",()=>{r.removeChild(a)}),setTimeout(()=>{r.contains(a)&&r.removeChild(a)},o),a}},6378:function(e,t,o){o.r(t),o.d(t,{DashboardCache:function(){return a},dashboardCache:function(){return n}});let r=o(51214).ej.DEFAULT_TTL;class a{setPreloader(e){this.preloader=e}async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=o.ttl||r,n=!1!==o.refreshOnAccess,c=this._generateKey(e,t),s=e.name||"anonymous",l=this.cache.get(c),i=Date.now();if(l&&i-l.lastUpdated<a){let o=Math.round((i-l.lastUpdated)/1e3);if(this._debug("Cache HIT for ".concat(s," (age: ").concat(o,"s, TTL: ").concat(Math.round(a/1e3),"s)")),n&&(this.cache.set(c,{data:l.data,lastUpdated:i}),this._debug("Cache TTL refreshed for ".concat(s))),!this.backgroundJobs.has(c)){var d;(null===(d=this.preloader)||void 0===d?void 0:d.wasRecentlyPreloaded(e,t))?this._debug("Skipping background refresh for ".concat(s," - recently preloaded")):this._refreshInBackground(e,t,c)}return l.data}try{let o=await e(...t);return this.cache.set(c,{data:o,lastUpdated:i}),o}catch(e){if(l)return console.warn("Failed to fetch fresh data for ".concat(c,", returning stale data:"),e),l.data;throw e}}invalidate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],o=this._generateKey(e,t);this.cache.delete(o),this.backgroundJobs.delete(o)}invalidateFunction(e){let t=e.name||"anonymous",o=[];for(let e of this.cache.keys())e.startsWith("".concat(t,"_"))&&o.push(e);o.forEach(e=>{this.cache.delete(e),this.backgroundJobs.delete(e)})}clear(){this.cache.clear(),this.backgroundJobs.clear()}getStats(){return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,keys:Array.from(this.cache.keys())}}getDetailedStats(){let e=Date.now(),t=[];for(let[o,r]of this.cache.entries()){let a=e-r.lastUpdated;t.push({key:o,age:Math.round(a/1e3),lastUpdated:new Date(r.lastUpdated).toISOString(),hasBackgroundJob:this.backgroundJobs.has(o)})}return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,entries:t.sort((e,t)=>e.age-t.age)}}setDebugMode(e){this.debugMode=e}_debug(e){for(var t=arguments.length,o=Array(t>1?t-1:0),r=1;r<t;r++)o[r-1]=arguments[r];this.debugMode&&console.log("[DashboardCache] ".concat(e),...o)}_refreshInBackground(e,t,o){this.backgroundJobs.set(o,!0),e(...t).then(e=>{this.cache.set(o,{data:e,lastUpdated:Date.now()})}).catch(e=>{console.warn("Background refresh failed for ".concat(o,":"),e)}).finally(()=>{this.backgroundJobs.delete(o)})}_generateKey(e,t){let o=function(e){let t=5381;for(let o=0;o<e.length;o++)t=(t<<5)+t+e.charCodeAt(o);return t>>>0}(e.toString()),r=t.length>0?JSON.stringify(t):"";return"".concat(o,"_").concat(r)}constructor(){this.cache=new Map,this.backgroundJobs=new Map,this.debugMode=!1,this.preloader=null}}let n=new a;t.default=n}}]);
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
pod_spec:
|
|
2
|
-
apiVersion: v1
|
|
3
|
-
kind: Pod
|
|
4
|
-
metadata:
|
|
5
|
-
name: {{ name }}
|
|
6
|
-
labels:
|
|
7
|
-
component: {{ name }}
|
|
8
|
-
parent: skypilot
|
|
9
|
-
spec:
|
|
10
|
-
serviceAccountName: sky-ssh-jump-sa
|
|
11
|
-
volumes:
|
|
12
|
-
- name: secret-volume
|
|
13
|
-
secret:
|
|
14
|
-
secretName: {{ secret }}
|
|
15
|
-
containers:
|
|
16
|
-
- name: {{ name }}
|
|
17
|
-
imagePullPolicy: Always
|
|
18
|
-
image: {{ image }}
|
|
19
|
-
command: ["python3", "-u", "/skypilot/sky/utils/kubernetes/ssh_jump_lifecycle_manager.py"]
|
|
20
|
-
ports:
|
|
21
|
-
- containerPort: 22
|
|
22
|
-
volumeMounts:
|
|
23
|
-
- name: secret-volume
|
|
24
|
-
readOnly: true
|
|
25
|
-
mountPath: /etc/secret-volume
|
|
26
|
-
lifecycle:
|
|
27
|
-
postStart:
|
|
28
|
-
exec:
|
|
29
|
-
command: ["/bin/bash", "-c", "mkdir -p ~/.ssh && cat /etc/secret-volume/ssh-publickey* > ~/.ssh/authorized_keys && sudo service ssh restart"]
|
|
30
|
-
env:
|
|
31
|
-
- name: MY_POD_NAME
|
|
32
|
-
valueFrom:
|
|
33
|
-
fieldRef:
|
|
34
|
-
fieldPath: metadata.name
|
|
35
|
-
- name: MY_POD_NAMESPACE
|
|
36
|
-
valueFrom:
|
|
37
|
-
fieldRef:
|
|
38
|
-
fieldPath: metadata.namespace
|
|
39
|
-
- name: ALERT_THRESHOLD
|
|
40
|
-
# seconds
|
|
41
|
-
value: "600"
|
|
42
|
-
- name: RETRY_INTERVAL
|
|
43
|
-
# seconds
|
|
44
|
-
value: "60"
|
|
45
|
-
terminationGracePeriodSeconds: 0
|
|
46
|
-
service_spec:
|
|
47
|
-
apiVersion: v1
|
|
48
|
-
kind: Service
|
|
49
|
-
metadata:
|
|
50
|
-
name: {{ name }}
|
|
51
|
-
labels:
|
|
52
|
-
parent: skypilot
|
|
53
|
-
spec:
|
|
54
|
-
type: {{ service_type }}
|
|
55
|
-
selector:
|
|
56
|
-
component: {{ name }}
|
|
57
|
-
ports:
|
|
58
|
-
- protocol: TCP
|
|
59
|
-
port: 22
|
|
60
|
-
targetPort: 22
|
|
61
|
-
# The following ServiceAccount/Role/RoleBinding sets up an RBAC for life cycle
|
|
62
|
-
# management of the jump pod/service
|
|
63
|
-
service_account:
|
|
64
|
-
apiVersion: v1
|
|
65
|
-
kind: ServiceAccount
|
|
66
|
-
metadata:
|
|
67
|
-
name: sky-ssh-jump-sa
|
|
68
|
-
labels:
|
|
69
|
-
parent: skypilot
|
|
70
|
-
role:
|
|
71
|
-
kind: Role
|
|
72
|
-
apiVersion: rbac.authorization.k8s.io/v1
|
|
73
|
-
metadata:
|
|
74
|
-
name: sky-ssh-jump-role
|
|
75
|
-
labels:
|
|
76
|
-
parent: skypilot
|
|
77
|
-
rules:
|
|
78
|
-
- apiGroups: [""]
|
|
79
|
-
resources: ["pods", "pods/status", "pods/exec", "services"]
|
|
80
|
-
verbs: ["get", "list", "create", "delete"]
|
|
81
|
-
role_binding:
|
|
82
|
-
apiVersion: rbac.authorization.k8s.io/v1
|
|
83
|
-
kind: RoleBinding
|
|
84
|
-
metadata:
|
|
85
|
-
name: sky-ssh-jump-rb
|
|
86
|
-
labels:
|
|
87
|
-
parent: skypilot
|
|
88
|
-
subjects:
|
|
89
|
-
- kind: ServiceAccount
|
|
90
|
-
name: sky-ssh-jump-sa
|
|
91
|
-
roleRef:
|
|
92
|
-
kind: Role
|
|
93
|
-
name: sky-ssh-jump-role
|
|
94
|
-
apiGroup: rbac.authorization.k8s.io
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"""Manages lifecycle of ssh jump pod.
|
|
2
|
-
|
|
3
|
-
This script runs inside ssh jump pod as the main process (PID 1).
|
|
4
|
-
|
|
5
|
-
It terminates itself (by removing ssh jump service and pod via a call to
|
|
6
|
-
kubeapi) if it does not see ray pods in the duration of 10 minutes. If the
|
|
7
|
-
user re-launches a task before the duration is over, then ssh jump pod is being
|
|
8
|
-
reused and will terminate itself when it sees that no ray clusters exist in
|
|
9
|
-
that duration.
|
|
10
|
-
|
|
11
|
-
To allow multiple users to the share the same SSH jump pod,
|
|
12
|
-
this script also reloads SSH keys from the mounted secret volume on an
|
|
13
|
-
interval and updates `~/.ssh/authorized_keys`.
|
|
14
|
-
"""
|
|
15
|
-
import datetime
|
|
16
|
-
import os
|
|
17
|
-
import subprocess
|
|
18
|
-
import sys
|
|
19
|
-
import threading
|
|
20
|
-
import time
|
|
21
|
-
|
|
22
|
-
from kubernetes import client
|
|
23
|
-
from kubernetes import config
|
|
24
|
-
|
|
25
|
-
# Load kube config
|
|
26
|
-
config.load_incluster_config()
|
|
27
|
-
|
|
28
|
-
v1 = client.CoreV1Api()
|
|
29
|
-
|
|
30
|
-
current_name = os.getenv('MY_POD_NAME')
|
|
31
|
-
current_namespace = os.getenv('MY_POD_NAMESPACE')
|
|
32
|
-
|
|
33
|
-
# The amount of time in seconds where no Ray pods exist in which after that time
|
|
34
|
-
# ssh jump pod terminates itself
|
|
35
|
-
alert_threshold = int(os.getenv('ALERT_THRESHOLD', '600'))
|
|
36
|
-
# The amount of time in seconds to wait between Ray pods existence checks
|
|
37
|
-
retry_interval = int(os.getenv('RETRY_INTERVAL', '60'))
|
|
38
|
-
# The amount of time in seconds to wait between SSH key reloads
|
|
39
|
-
reload_interval = int(os.getenv('RELOAD_INTERVAL', '5'))
|
|
40
|
-
|
|
41
|
-
# Ray pods are labeled with this value i.e., ssh jump name which is unique per
|
|
42
|
-
# user (based on user hash)
|
|
43
|
-
label_selector = f'skypilot-ssh-jump={current_name}'
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def poll(interval, leading=True):
|
|
47
|
-
"""Decorator factory for polling function. To stop polling, return True.
|
|
48
|
-
|
|
49
|
-
Args:
|
|
50
|
-
interval (int): The amount of time to wait between function calls.
|
|
51
|
-
leading (bool): Whether to wait before (rather than after) calls.
|
|
52
|
-
"""
|
|
53
|
-
|
|
54
|
-
def decorator(func):
|
|
55
|
-
|
|
56
|
-
def wrapper(*args, **kwargs):
|
|
57
|
-
while True:
|
|
58
|
-
if leading:
|
|
59
|
-
time.sleep(interval)
|
|
60
|
-
done = func(*args, **kwargs)
|
|
61
|
-
if done:
|
|
62
|
-
return
|
|
63
|
-
if not leading:
|
|
64
|
-
time.sleep(interval)
|
|
65
|
-
|
|
66
|
-
return wrapper
|
|
67
|
-
|
|
68
|
-
return decorator
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
# Flag to terminate the reload keys thread when the lifecycle thread
|
|
72
|
-
# terminates.
|
|
73
|
-
terminated = False
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
@poll(interval=reload_interval, leading=False)
|
|
77
|
-
def reload_keys():
|
|
78
|
-
"""Reloads SSH keys from mounted secret volume."""
|
|
79
|
-
|
|
80
|
-
if terminated:
|
|
81
|
-
sys.stdout.write('[SSH Key Reloader] Terminated.\n')
|
|
82
|
-
return True
|
|
83
|
-
|
|
84
|
-
# Reload SSH keys from mounted secret volume if changed.
|
|
85
|
-
tmpfile = '/tmp/sky-ssh-keys'
|
|
86
|
-
try:
|
|
87
|
-
subprocess.check_output(
|
|
88
|
-
f'cat /etc/secret-volume/ssh-publickey* > {tmpfile}', shell=True)
|
|
89
|
-
try:
|
|
90
|
-
subprocess.check_output(f'diff {tmpfile} ~/.ssh/authorized_keys',
|
|
91
|
-
shell=True)
|
|
92
|
-
sys.stdout.write(
|
|
93
|
-
'[SSH Key Reloader] No keys changed, continuing.\n')
|
|
94
|
-
except subprocess.CalledProcessError as e:
|
|
95
|
-
if e.returncode == 1:
|
|
96
|
-
sys.stdout.write(
|
|
97
|
-
'[SSH Key Reloader] Changes detected, reloading.\n')
|
|
98
|
-
subprocess.check_output(f'mv {tmpfile} ~/.ssh/authorized_keys',
|
|
99
|
-
shell=True)
|
|
100
|
-
else:
|
|
101
|
-
raise
|
|
102
|
-
except Exception as e:
|
|
103
|
-
sys.stdout.write(
|
|
104
|
-
f'[SSH Key Reloader][ERROR] Failed to reload SSH keys: {e}\n')
|
|
105
|
-
raise
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
alert_delta = datetime.timedelta(seconds=alert_threshold)
|
|
109
|
-
retry_interval_delta = datetime.timedelta(seconds=retry_interval)
|
|
110
|
-
# Accumulated time of where no SkyPilot cluster exists. Compared
|
|
111
|
-
# against alert_threshold.
|
|
112
|
-
nocluster_delta = datetime.timedelta()
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
@poll(interval=retry_interval)
|
|
116
|
-
def manage_lifecycle():
|
|
117
|
-
"""Manages lifecycle of ssh jump pod."""
|
|
118
|
-
|
|
119
|
-
global terminated, nocluster_delta
|
|
120
|
-
|
|
121
|
-
try:
|
|
122
|
-
ret = v1.list_namespaced_pod(current_namespace,
|
|
123
|
-
label_selector=label_selector)
|
|
124
|
-
except Exception as e:
|
|
125
|
-
sys.stdout.write('[Lifecycle] [ERROR] listing pods failed with '
|
|
126
|
-
f'error: {e}\n')
|
|
127
|
-
raise
|
|
128
|
-
|
|
129
|
-
if not ret.items:
|
|
130
|
-
sys.stdout.write(
|
|
131
|
-
f'[Lifecycle] Did not find pods with label '
|
|
132
|
-
f'"{label_selector}" in namespace {current_namespace}\n')
|
|
133
|
-
nocluster_delta = nocluster_delta + retry_interval_delta
|
|
134
|
-
sys.stdout.write(
|
|
135
|
-
f'[Lifecycle] Time since no pods found: {nocluster_delta}, alert '
|
|
136
|
-
f'threshold: {alert_delta}\n')
|
|
137
|
-
else:
|
|
138
|
-
sys.stdout.write(
|
|
139
|
-
f'[Lifecycle] Found pods with label "{label_selector}" in '
|
|
140
|
-
f'namespace {current_namespace}\n')
|
|
141
|
-
# reset ..
|
|
142
|
-
nocluster_delta = datetime.timedelta()
|
|
143
|
-
sys.stdout.write(
|
|
144
|
-
f'[Lifecycle] nocluster_delta is reset: {nocluster_delta}\n')
|
|
145
|
-
|
|
146
|
-
if nocluster_delta >= alert_delta:
|
|
147
|
-
sys.stdout.write(
|
|
148
|
-
f'[Lifecycle] nocluster_delta: {nocluster_delta} crossed alert '
|
|
149
|
-
f'threshold: {alert_delta}. Time to terminate myself and my '
|
|
150
|
-
'service.\n')
|
|
151
|
-
try:
|
|
152
|
-
# ssh jump resources created under same name
|
|
153
|
-
v1.delete_namespaced_service(current_name, current_namespace)
|
|
154
|
-
v1.delete_namespaced_pod(current_name, current_namespace)
|
|
155
|
-
except Exception as e:
|
|
156
|
-
sys.stdout.write('[Lifecycle][ERROR] Deletion failed. Exiting '
|
|
157
|
-
f'poll() with error: {e}\n')
|
|
158
|
-
raise
|
|
159
|
-
|
|
160
|
-
terminated = True
|
|
161
|
-
return True
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
def main():
|
|
165
|
-
sys.stdout.write('SkyPilot SSH Jump Pod Lifecycle Manager\n')
|
|
166
|
-
sys.stdout.write(f'current_name: {current_name}\n')
|
|
167
|
-
sys.stdout.write(f'current_namespace: {current_namespace}\n')
|
|
168
|
-
sys.stdout.write(f'alert_threshold time: {alert_threshold}\n')
|
|
169
|
-
sys.stdout.write(f'retry_interval time: {retry_interval}\n')
|
|
170
|
-
sys.stdout.write(f'reload_interval time: {reload_interval}\n')
|
|
171
|
-
sys.stdout.write(f'label_selector: {label_selector}\n')
|
|
172
|
-
|
|
173
|
-
if not current_name or not current_namespace:
|
|
174
|
-
# Raise Exception with message to terminate pod
|
|
175
|
-
raise Exception('Missing environment variables MY_POD_NAME or '
|
|
176
|
-
'MY_POD_NAMESPACE')
|
|
177
|
-
|
|
178
|
-
threads = [
|
|
179
|
-
threading.Thread(target=manage_lifecycle),
|
|
180
|
-
threading.Thread(target=reload_keys)
|
|
181
|
-
]
|
|
182
|
-
sys.stdout.write(f'Polling with {len(threads)} threads.\n')
|
|
183
|
-
for t in threads:
|
|
184
|
-
t.start()
|
|
185
|
-
for t in threads:
|
|
186
|
-
t.join()
|
|
187
|
-
sys.stdout.write('Done.\n')
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if __name__ == '__main__':
|
|
191
|
-
main()
|
/sky/dashboard/out/_next/static/{16g0-hgEgk6Db72hpE8MY → KL03GEega4QqDqTOMtA_w}/_ssgManifest.js
RENAMED
|
File without changes
|
{skypilot_nightly-1.0.0.dev20251002.dist-info → skypilot_nightly-1.0.0.dev20251004.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|