DiskIOBandwidthWarnings.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import Link from 'next/link'
  2. import { Button } from 'ui'
  3. import { Admonition } from 'ui-patterns'
  4. // [Joshen] In the future, conditionals should be from resource exhaustion endpoint as single source of truth
  5. interface DiskIOBandwidthWarningsProps {
  6. hasAccessToComputeSizes: boolean
  7. hasLatest: boolean
  8. upgradeUrl: string
  9. currentBillingCycleSelected: boolean
  10. latestIoBudgetConsumption: number
  11. highestIoBudgetConsumption: number
  12. }
  13. export const DiskIOBandwidthWarnings = ({
  14. hasAccessToComputeSizes,
  15. hasLatest,
  16. currentBillingCycleSelected,
  17. upgradeUrl,
  18. latestIoBudgetConsumption,
  19. highestIoBudgetConsumption,
  20. }: DiskIOBandwidthWarningsProps) => {
  21. if (hasLatest && latestIoBudgetConsumption >= 100) {
  22. return (
  23. <Admonition
  24. type="destructive"
  25. title="Your Disk IO Budget has been used up"
  26. description={
  27. <>
  28. <p className="mb-4">
  29. Your workload has used up all your Disk IO Budget and is now running at the baseline
  30. performance. If you need consistent disk performance, consider upgrading to a larger
  31. compute add-on.
  32. </p>
  33. <Button asChild type="danger">
  34. <Link href={upgradeUrl}>
  35. {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
  36. </Link>
  37. </Button>
  38. </>
  39. }
  40. />
  41. )
  42. }
  43. if (hasLatest && latestIoBudgetConsumption >= 80) {
  44. return (
  45. <Admonition
  46. type="destructive"
  47. title="You are close to running out of Disk IO Budget"
  48. description={
  49. <>
  50. <p className="mb-4">
  51. Your workload has consumed {latestIoBudgetConsumption}% of your Disk IO Budget. If you
  52. use up all your Disk IO Budget, your instance will reverted to baseline performance.
  53. If you need consistent disk performance, consider upgrading to a larger compute
  54. add-on.
  55. </p>
  56. <Button asChild type="danger">
  57. <Link href={upgradeUrl}>
  58. {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
  59. </Link>
  60. </Button>
  61. </>
  62. }
  63. />
  64. )
  65. }
  66. if (currentBillingCycleSelected && highestIoBudgetConsumption >= 100) {
  67. return (
  68. <Admonition
  69. type="warning"
  70. title="You ran out of IO Budget at least once"
  71. description={
  72. <>
  73. <p className="mb-4">
  74. Your workload has used up all your Disk IO Budget and reverted to baseline performance
  75. at least once during this billing cycle. If you need consistent disk performance,
  76. consider upgrading to a larger compute add-on.
  77. </p>
  78. <Button asChild type="warning">
  79. <Link href={upgradeUrl}>
  80. {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
  81. </Link>
  82. </Button>
  83. </>
  84. }
  85. />
  86. )
  87. }
  88. if (currentBillingCycleSelected && highestIoBudgetConsumption >= 80) {
  89. return (
  90. <Admonition
  91. type="warning"
  92. title="You were close to using all your IO Budget at least once"
  93. description={
  94. <>
  95. <p className="mb-4">
  96. Your workload has consumed {highestIoBudgetConsumption}% of your Disk IO budget during
  97. this billing cycle. If you use up all your Disk IO Budget, your instance will reverted
  98. to baseline performance. If you need consistent disk performance, consider upgrading
  99. to a larger compute add-on.
  100. </p>
  101. <Button asChild type="warning">
  102. <Link href={upgradeUrl}>
  103. {hasAccessToComputeSizes ? 'Change compute add-on' : 'Upgrade project'}
  104. </Link>
  105. </Button>
  106. </>
  107. }
  108. />
  109. )
  110. }
  111. return null
  112. }