Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI] Display system partitions in node page #3045

Merged

Conversation

ChengYanJin
Copy link
Contributor

@ChengYanJin ChengYanJin commented Jan 15, 2021

Component: ui, node

Context: We would like to add a tab in the Node page to display the information of system partitions.

Summary:

Update:
Will address hiding the warning alert in the next PR.

Acceptance criteria:
image

image


Closes: #2932
Closes: #2173

@ChengYanJin ChengYanJin requested a review from a team as a code owner January 15, 2021 16:20
@bert-e
Copy link
Contributor

bert-e commented Jan 15, 2021

Hello chengyanjin,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Jan 15, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin ChengYanJin changed the title Improvement/2932 display system partitions in node page [UI] Display system partitions in node page Jan 15, 2021
@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch 2 times, most recently from 1679c59 to 3277a91 Compare January 15, 2021 16:33
Copy link
Contributor

@JBWatenbergScality JBWatenbergScality left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,
Good job for introducing react query and enhanced typing !
I've added a few comment about typing which can be a bit improved, also we have to check if we can merge #3002 before this PR in order to benefit from eea1b97 and useTypedSelector.
I think we may have to review a bit the style implementation because it seems not to be adapted for other screen resolution, eg on my screen :
image
The tbody height goes beyond my screen height and trigger the visibility of the scrollbar despite that there is no scroll necessity. I think that we should not define the tbody height and instead let the array fills the necessary place according to the number of partitions. Doing so also simplify reuse of the table component as it won't impact the style of the page where it is included.

ui/src/services/NodeVolumesUtils.js Outdated Show resolved Hide resolved
ui/src/services/NodeVolumesUtils.js Outdated Show resolved Hide resolved
ui/src/services/NodeVolumesUtils.js Outdated Show resolved Hide resolved
ui/src/services/NodeVolumesUtils.js Outdated Show resolved Hide resolved
ui/src/services/NodeVolumesUtils.js Outdated Show resolved Hide resolved
ui/src/components/NodePagePartitionTab.js Outdated Show resolved Hide resolved
ui/src/components/NodePartitionTable.js Outdated Show resolved Hide resolved
ui/src/components/NodePartitionTable.js Show resolved Hide resolved
ui/src/components/NodePartitionTable.js Outdated Show resolved Hide resolved
ui/src/services/prometheus/fetchMetrics.js Outdated Show resolved Hide resolved
@bert-e
Copy link
Contributor

bert-e commented Jan 18, 2021

Branches have diverged

This pull request's source branch improvement/2932-display-system-partitions-in-node-page has diverged from
development/2.8 by more than 50 commits.

To avoid any integration risks, please re-synchronize them using one of the
following solutions:

  • Merge origin/development/2.8 into improvement/2932-display-system-partitions-in-node-page
  • Rebase improvement/2932-display-system-partitions-in-node-page onto origin/development/2.8

Note: If you choose to rebase, you may have to ask me to rebuild
integration branches using the reset command.

@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch from 354380f to 30d99ff Compare January 18, 2021 12:07
@bert-e
Copy link
Contributor

bert-e commented Jan 18, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch from 30d99ff to 0662278 Compare January 18, 2021 14:54
@bert-e
Copy link
Contributor

bert-e commented Jan 18, 2021

Conflict

There is a conflict between your branch improvement/2932-display-system-partitions-in-node-page and the
destination branch development/2.8.

Please resolve the conflict on the feature branch (improvement/2932-display-system-partitions-in-node-page).

 $ git fetch
 $ git checkout origin/improvement/2932-display-system-partitions-in-node-page
 $ git merge origin/development/2.8
 $ # <intense conflict resolution>
 $ git commit
 $ git push origin HEAD:improvement/2932-display-system-partitions-in-node-page

@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch from bbd60c7 to 660558f Compare January 20, 2021 13:24
@bert-e
Copy link
Contributor

bert-e commented Jan 20, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch 3 times, most recently from ccfe468 to 7252781 Compare January 21, 2021 15:15
Copy link
Contributor

@JBWatenbergScality JBWatenbergScality left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change-log entry referring this change seems to be missing

ui/src/components/NodePartitionTable.js Outdated Show resolved Hide resolved
Comment on lines 444 to 480
const len = alerts.length;
// Record the index to be removed.
const removeIndex = [];
for (let i = 0, j = 1; i <= len - 2 && j <= len - 1; ) {
if (j === len - 1) {
i++;
j = i + 1;
} else if (
// Add more label conditions here when we need to address more alerts.
(alerts[i].labels.device &&
alerts[i].labels.alertname === alerts[j].labels.alertname &&
alerts[i].labels.device === alerts[j].labels.device &&
alerts[i].labels.instance === alerts[j].labels.instance) ||
(alerts[i].labels.persistentvolumeclaim &&
((alerts[i].labels.persistentvolumeclaim ===
alerts[j].labels.persistentvolumeclaim) ===
alerts[i].labels.alertname) ===
alerts[j].labels.alertname)
) {
if (alerts[i].labels.severity === 'warning') {
removeIndex.push(i);
i++;
j = i + 1;
} else if (alerts[j].labels.severity === 'warning') {
removeIndex.push(j);
i++;
j = i + 1;
}
} else {
j = j + 1;
}
}

let removedWarningAlerts = alerts;
removeIndex.forEach((index) => removedWarningAlerts.splice(index, 1));

return removedWarningAlerts;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to make it easier to take new alert rules into account I think it would be preferable to split the function similarly to this approach below :

function getAlertUniqueKey(alert: PrometheusAlert): string | null {
     if(alert.labels.alertname.startsWith("NodeFilesystem")) {
              return alert.labels.alertname + alert. labels.device + alert.labels.instance;
    }
    if(alert.labels.alertname.startsWith("PersistentVolume")) {
             return alert.labels.alertname + alert.persistentVolumeClaim;
    }
    return null;
}

export const removeWarningAlerts = (
  alerts: Array<PrometheusAlert>,
): Array<PrometheusAlert> => {
    const unfilteredAlerts: PrometheusAlert[] = [];
    const indexedAlerts: {[key: string]: PrometheusAlert} = {}; 
    
    alerts.forEach(alert => {
        const alertUniqueKey = getAlertUniqueKey(alert);
        if  (!alertUniqueKey){
            unfilteredAlerts.push(alert);
        } else if (alertUniqueKey && ((indexedAlerts[alertUniqueKey] && indexedAlerts[alertUniqueKey].labels.severity === 'warning') || !indexedAlerts[alertUniqueKey])) {
           indexedAlerts[alertUniqueKey] = alert;
        }
    })
    
    return [...unfilteredAlerts, ...Object.values(indexedAlerts)];
}

},
];

it('should remove the wanring alerts', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo here warning


it('should remove the wanring alerts', () => {
const result = removeDiskWarningAlerts(alerts);
expect(result.length).toEqual(3);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to test if result array is the expecting one using

expect(result).toStrictEqual([
  {
    annotations: {
      description:
        'Filesystem on /dev/vdc2 at 192.168.1.6:9100 has only 0.00% available space left.',
      runbook_url:
        'https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-nodefilesystemalmostoutofspace',
      summary: 'Filesystem has less than 3% space left.',
    },
    endsAt: '2021-01-21T09:32:35.358Z',
    fingerprint: '5ef4c93e954ac2c9',
    receivers: [
      {
        name: 'null',
      },
    ],
    startsAt: '2021-01-18T16:43:35.358Z',
    status: {
      inhibitedBy: [],
      silencedBy: [],
      state: 'active',
    },
    updatedAt: '2021-01-21T09:28:40.099Z',
    generatorURL:
      'http://prometheus-operator-prometheus.metalk8s-monitoring:9090/graph?g0.expr=%28node_filesystem_avail_bytes%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%2F+node_filesystem_size_bytes%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%2A+100+%3C+3+and+node_filesystem_readonly%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%3D%3D+0%29&g0.tab=1',
    labels: {
      alertname: 'NodeFilesystemAlmostOutOfSpace',
      container: 'node-exporter',
      device: '/dev/vdc2',
      endpoint: 'metrics',
      fstype: 'ext4',
      instance: '192.168.1.6:9100',
      job: 'node-exporter',
      mountpoint: '/mnt/testpart2',
      namespace: 'metalk8s-monitoring',
      pod: 'prometheus-operator-prometheus-node-exporter-m9qcj',
      prometheus: 'metalk8s-monitoring/prometheus-operator-prometheus',
      service: 'prometheus-operator-prometheus-node-exporter',
      severity: 'critical',
    },
  },
  {
    annotations: {
      description:
        'Filesystem on /dev/vdc2 at 192.168.1.6:9100 has only 0.00% available space left.',
      runbook_url:
        'https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-nodefilesystemalmostoutofspace',
      summary: 'Filesystem has less than 5% space left.',
    },
    endsAt: '2021-01-21T09:32:35.358Z',
    fingerprint: '6331188d982cdcfc',
    receivers: [
      {
        name: 'null',
      },
    ],
    startsAt: '2021-01-18T16:43:35.358Z',
    status: {
      inhibitedBy: [],
      silencedBy: [],
      state: 'active',
    },
    updatedAt: '2021-01-21T09:28:40.092Z',
    generatorURL:
      'http://prometheus-operator-prometheus.metalk8s-monitoring:9090/graph?g0.expr=%28node_filesystem_avail_bytes%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%2F+node_filesystem_size_bytes%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%2A+100+%3C+5+and+node_filesystem_readonly%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%3D%3D+0%29&g0.tab=1',
    labels: {
      alertname: 'NodeFilesystemAlmostOutOfSpace',
      container: 'node-exporter',
      device: '/dev/vdc2',
      endpoint: 'metrics',
      fstype: 'ext4',
      instance: '192.168.1.6:9100',
      job: 'node-exporter',
      mountpoint: '/mnt/testpart2',
      namespace: 'metalk8s-monitoring',
      pod: 'prometheus-operator-prometheus-node-exporter-m9qcj',
      prometheus: 'metalk8s-monitoring/prometheus-operator-prometheus',
      service: 'prometheus-operator-prometheus-node-exporter',
      severity: 'warning',
    },
  },
  {
    annotations: {
      description:
        'Filesystem on /dev/vdc1 at 192.168.1.6:9100 has only 3.28% available space left.',
      runbook_url:
        'https://github.com/kubernetes-monitoring/kubernetes-mixin/tree/master/runbook.md#alert-name-nodefilesystemalmostoutofspace',
      summary: 'Filesystem has less than 5% space left.',
    },
    endsAt: '2021-01-21T09:32:35.358Z',
    fingerprint: '6c9be09b96993ce4',
    receivers: [
      {
        name: 'null',
      },
    ],
    startsAt: '2021-01-18T16:43:35.358Z',
    status: {
      inhibitedBy: [],
      silencedBy: [],
      state: 'active',
    },
    updatedAt: '2021-01-21T09:28:40.092Z',
    generatorURL:
      'http://prometheus-operator-prometheus.metalk8s-monitoring:9090/graph?g0.expr=%28node_filesystem_avail_bytes%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%2F+node_filesystem_size_bytes%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%2A+100+%3C+5+and+node_filesystem_readonly%7Bfstype%21%3D%22%22%2Cjob%3D%22node-exporter%22%7D+%3D%3D+0%29&g0.tab=1',
    labels: {
      alertname: 'NodeFilesystemAlmostOutOfSpace',
      container: 'node-exporter',
      device: '/dev/vdc1',
      endpoint: 'metrics',
      fstype: 'xfs',
      instance: '192.168.1.6:9100',
      job: 'node-exporter',
      mountpoint: '/mnt/testpart1',
      namespace: 'metalk8s-monitoring',
      pod: 'prometheus-operator-prometheus-node-exporter-m9qcj',
      prometheus: 'metalk8s-monitoring/prometheus-operator-prometheus',
      service: 'prometheus-operator-prometheus-node-exporter',
      severity: 'warning',
    },
  },
])

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

additionally your test seems to lack coverage on persistentvolume alerts and alerts of other kinds that should not be filtered

ui/src/components/NodePartitionTable.js Show resolved Hide resolved
@bert-e
Copy link
Contributor

bert-e commented Jan 22, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

The following reviewers are expecting changes from the author, or must review again:

@bert-e
Copy link
Contributor

bert-e commented Jan 22, 2021

Conflict

There is a conflict between your branch improvement/2932-display-system-partitions-in-node-page and the
destination branch development/2.8.

Please resolve the conflict on the feature branch (improvement/2932-display-system-partitions-in-node-page).

 $ git fetch
 $ git checkout origin/improvement/2932-display-system-partitions-in-node-page
 $ git merge origin/development/2.8
 $ # <intense conflict resolution>
 $ git commit
 $ git push origin HEAD:improvement/2932-display-system-partitions-in-node-page

@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch from a07aff7 to 8365d01 Compare January 22, 2021 09:44
@bert-e
Copy link
Contributor

bert-e commented Jan 22, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

The following reviewers are expecting changes from the author, or must review again:

@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch from 8365d01 to f222ca8 Compare January 27, 2021 10:25
@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch 3 times, most recently from 78031a1 to 6dd67ab Compare January 31, 2021 09:40
@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch 9 times, most recently from 7bba179 to 72f96b6 Compare February 2, 2021 10:55
@JBWatenbergScality JBWatenbergScality force-pushed the improvement/2932-display-system-partitions-in-node-page branch from 72f96b6 to fa698ca Compare February 2, 2021 13:07
@ChengYanJin ChengYanJin force-pushed the improvement/2932-display-system-partitions-in-node-page branch 2 times, most recently from 2ed5b6f to 5d779b8 Compare February 2, 2021 13:24
When installing kubernetes client, the library is being built in the context of the consumer project meaning that it has access to the consumer node_modules.
That bring the issue that typescript was trying to build metalk8s types dependency to build kubernetes client leading to a build failure.

The issue has been resolved by this commit : scality/kubernetes-client-javascript@579d066 which lists explicitly the types dependency of kubernetes client.
Copy link
Contributor

@JBWatenbergScality JBWatenbergScality left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats, LGTM !

@bert-e
Copy link
Contributor

bert-e commented Feb 2, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin
Copy link
Contributor Author

/approve

@bert-e
Copy link
Contributor

bert-e commented Feb 2, 2021

In the queue

The changeset has received all authorizations and has been added to the
relevant queue(s). The queue(s) will be merged in the target development
branch(es) as soon as builds have passed.

The changeset will be merged in:

  • ✔️ development/2.8

The following branches will NOT be impacted:

  • development/1.0
  • development/1.1
  • development/1.2
  • development/1.3
  • development/2.0
  • development/2.1
  • development/2.2
  • development/2.3
  • development/2.4
  • development/2.5
  • development/2.6
  • development/2.7

There is no action required on your side. You will be notified here once
the changeset has been merged. In the unlikely event that the changeset
fails permanently on the queue, a member of the admin team will
contact you to help resolve the matter.

IMPORTANT

Please do not attempt to modify this pull request.

  • Any commit you add on the source branch will trigger a new cycle after the
    current queue is merged.
  • Any commit you add on one of the integration branches will be lost.

If you need this pull request to be removed from the queue, please contact a
member of the admin team now.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Feb 2, 2021

I have successfully merged the changeset of this pull request
into targetted development branches:

  • ✔️ development/2.8

The following branches have NOT changed:

  • development/1.0
  • development/1.1
  • development/1.2
  • development/1.3
  • development/2.0
  • development/2.1
  • development/2.2
  • development/2.3
  • development/2.4
  • development/2.5
  • development/2.6
  • development/2.7

Please check the status of the associated issue None.

Goodbye chengyanjin.

@bert-e bert-e merged commit 5d779b8 into development/2.8 Feb 2, 2021
@bert-e bert-e deleted the improvement/2932-display-system-partitions-in-node-page branch February 2, 2021 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display System partitions in Node Page NodeFilesystemSpaceFillingUp alert does not show node name in message
3 participants