-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block Save on operator's reconciliation
- Loading branch information
1 parent
41279fb
commit 0aabec4
Showing
8 changed files
with
131 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
|
||
import { ClusterOperator, getCondition } from '../copy-backend-common'; | ||
import { getClusterOperators } from '../resources/clusteroperator'; | ||
|
||
import { CLUSTER_OPERATOR_POLLING_INTERVAL, MONITORED_CLUSTER_OPERATORS } from './constants'; | ||
import { delay } from './utils'; | ||
|
||
export const useOperatorsReconciling = (): ClusterOperator[] | undefined => { | ||
const [operatorsReconciling, setOperatorsReconciling] = React.useState<ClusterOperator[]>(); | ||
const [pollingTimmer, setPollingTimmer] = React.useState<number>(0); | ||
|
||
React.useEffect(() => { | ||
let stopIt = false; | ||
|
||
const doItAsync = async () => { | ||
const operators = await getClusterOperators().promise; | ||
|
||
const filteredOperators = operators.filter( | ||
(op) => | ||
MONITORED_CLUSTER_OPERATORS.includes(op.metadata.name as string) && | ||
(getCondition(op, 'Progressing')?.status === 'True' || | ||
getCondition(op, 'Degraded')?.status === 'True' || | ||
getCondition(op, 'Available')?.status === 'False'), | ||
); | ||
|
||
if (!stopIt) { | ||
setOperatorsReconciling( | ||
filteredOperators.sort( | ||
(op1, op2) => op1.metadata.name?.localeCompare(op2.metadata.name as string) || -1, | ||
), | ||
); | ||
|
||
await delay(CLUSTER_OPERATOR_POLLING_INTERVAL); | ||
|
||
if (!stopIt) { | ||
setPollingTimmer(pollingTimmer + 1); | ||
} | ||
} | ||
}; | ||
|
||
doItAsync(); | ||
|
||
return () => { | ||
stopIt = true; | ||
}; | ||
}, [pollingTimmer]); | ||
|
||
return operatorsReconciling; | ||
}; |