Skip to content

Commit a63bea9

Browse files
NVSHAS-9931: Add warning if there are inconsistent version of NeuVector products in multi-cluster
1 parent 0273e08 commit a63bea9

File tree

4 files changed

+57
-4
lines changed

4 files changed

+57
-4
lines changed

admin/webapp/websrc/app/common/types/multi-cluster/cluster.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export interface Cluster {
1010
rest_version: string;
1111
clusterType: string;
1212
proxy_required: boolean;
13+
component_versions: string[];
1314
}

admin/webapp/websrc/app/routes/components/multi-cluster-grid/multi-cluster-grid.component.ts

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { MultiClusterGridActionCellComponent } from '@components/multi-cluster-g
2727
import { finalize, takeWhile } from 'rxjs/operators';
2828
import { interval } from 'rxjs';
2929
import { GlobalConstant } from '@common/constants/global.constant';
30+
import { NotificationService } from '@services/notification.service';
3031

3132
type Task = {
3233
index: number;
@@ -43,7 +44,9 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
4344
private readonly $win;
4445
private _activeTaskNum: number = 0;
4546
private _taskQueue: Task[] = [];
47+
private _finishedNum: number = 0;
4648
private _getSummarySubscription;
49+
private rowData: Cluster[] = [];
4750
@Input() clusterData!: ClusterData;
4851
@Input() gridHeight: number = 200;
4952
isMasterRole;
@@ -135,6 +138,11 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
135138
},
136139
width: 90,
137140
},
141+
{
142+
headerName: '',
143+
field: 'component_versions',
144+
hide: true,
145+
},
138146
];
139147

140148
statusColumn = [
@@ -165,15 +173,46 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
165173
filtered: boolean = false;
166174
filteredCount: number = 0;
167175
context;
176+
hasDiffManager: boolean = false;
168177

169178
get clusterCount() {
170179
return this.clusterData.clusters!.length;
171180
}
181+
182+
get taskQueue(): Task[] {
183+
return this._taskQueue;
184+
}
185+
186+
set taskQueue(value: Task[]) {
187+
this._taskQueue = value;
188+
}
189+
190+
get finishedNum(): number {
191+
return this._finishedNum;
192+
}
193+
194+
set finishedNum(value: number) {
195+
if (value === this.clusterCount && this.taskQueue.length === 0) {
196+
let componentVersions = this.rowData.map(data => {
197+
data.component_versions;
198+
});
199+
this.hasDiffManager = componentVersions.some((ver) => ver !== componentVersions[0]);
200+
if (this.hasDiffManager) {
201+
this.notificationService.open(
202+
this.translate.instant('multiCluster.HAS_INCOMPATIBLE_VERSION'),
203+
GlobalConstant.NOTIFICATION_TYPE.ERROR
204+
);
205+
}
206+
}
207+
this._finishedNum = value;
208+
}
209+
172210
constructor(
173211
public multiClusterService: MultiClusterService,
174212
private translate: TranslateService,
175213
private utils: UtilsService,
176214
private sanitizer: DomSanitizer,
215+
private notificationService: NotificationService,
177216
private cd: ChangeDetectorRef
178217
) {
179218
this.$win = $(GlobalVariable.window);
@@ -213,7 +252,9 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
213252
this.columnDefs.push(this.actionColumn);
214253
}
215254

216-
this.context = { componentParent: this };
255+
this.context = {
256+
componentParent: this,
257+
};
217258

218259
this.gridOptions = this.utils.createGridOptions(this.columnDefs, this.$win);
219260

@@ -225,6 +266,9 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
225266
onGridReady: event => this.onGridReady(event),
226267
onRowSelected: event => this.onRowSelected(event),
227268
};
269+
270+
this._activeTaskNum = 0;
271+
this.finishedNum = 0;
228272
}
229273

230274
updateSummaryForRow(rowNode: IRowNode, cluster: Cluster, index: number) {
@@ -270,6 +314,7 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
270314
cluster: cluster,
271315
};
272316
this._taskQueue.push(task);
317+
this.taskQueue = this._taskQueue;
273318
}
274319
}
275320
});
@@ -279,12 +324,13 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
279324
this._getSummarySubscription = interval(500)
280325
.pipe(
281326
takeWhile(() => {
282-
return this._taskQueue.length > 0;
327+
return this.taskQueue.length > 0;
283328
})
284329
)
285330
.subscribe(() => {
286-
while (this._activeTaskNum < limit && this._taskQueue.length > 0) {
287-
const task = this._taskQueue.shift();
331+
while (this._activeTaskNum < limit && this.taskQueue.length > 0) {
332+
const task = this.taskQueue.shift();
333+
this.taskQueue = this._taskQueue;
288334
if (task) {
289335
this._activeTaskNum++;
290336
this.updateSummaryForRow(task.rowNode, task.cluster, task.index);
@@ -497,6 +543,7 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
497543
rowNode.data.hosts = summaryDetail.hosts;
498544
rowNode.data.running_pods = summaryDetail.running_pods.toString();
499545
rowNode.data.cvedb_version = summaryDetail.cvedb_version;
546+
rowNode.data.component_versions = summaryDetail.component_versions;
500547
} else {
501548
rowNode.data.hosts = this.translate.instant(
502549
'multiCluster.messages.SCORE_UNAVAILIBlE'
@@ -519,8 +566,11 @@ export class MultiClusterGridComponent implements OnInit, OnDestroy {
519566
);
520567
}
521568

569+
this.rowData.push(rowNode.data);
570+
522571
if (this.gridOptions && this.gridApi) {
523572
this.gridApi!.redrawRows({ rowNodes: [rowNode] });
573+
this.finishedNum++;
524574
}
525575
}
526576

admin/webapp/websrc/assets/i18n/en-common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,6 +2898,7 @@
28982898
"USE_HTTP_PROXY": "Use http proxy configured in Settings > Configuration page",
28992899
"USE_HTTPS_PROXY": "Use https proxy configured in Settings > Configuration page",
29002900
"NO_PROXY": "Does not use any proxy",
2901+
"HAS_INCOMPATIBLE_VERSION": "Incompatible cluster versions were found. Please ensure all clusters are using the same version.",
29012902
"fed_sync_repository": "Sync CI/CD image scan results to managed clusters",
29022903
"tips": {
29032904
"policy": "Manage Federated Policy",

admin/webapp/websrc/assets/i18n/zh_cn-common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2898,6 +2898,7 @@
28982898
"USE_HTTP_PROXY":"使用配置在\"设置>配置\"页面的http代理",
28992899
"USE_HTTPS_PROXY": "使用配置在\"设置>配置\"页面的https代理",
29002900
"NO_PROXY": "不使用任何代理",
2901+
"HAS_INCOMPATIBLE_VERSION": "检测到集群版本不兼容。请确保所有集群使用相同的版本。",
29012902
"fed_sync_repository": "将CI/CD镜像扫描结果同步到托管集群",
29022903
"tips": {
29032904
"policy": "管理集群策略",

0 commit comments

Comments
 (0)