Skip to content

Commit

Permalink
Merge pull request #219 from buffalo1024/maintainschdulercm
Browse files Browse the repository at this point in the history
update scheduler configmap when source yaml file updated
  • Loading branch information
buffalo1024 authored Oct 19, 2023
2 parents fcb827a + 119f670 commit 9476c03
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion pkg/install/scheduler/scheduler_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,33 @@ func (m *SchedulerConfigMapMaintainer) Ensure() error {
if err := m.Client.Get(context.TODO(), key, &gotten); err != nil {
if errors.IsNotFound(err) {
if errCreate := m.Client.Create(context.TODO(), cmUnstructured); errCreate != nil {
log.Errorf("Create Scheduler ConfigMap err: %v", err)
log.Errorf("Create Scheduler ConfigMap err: %v", errCreate)
return errCreate
}
} else {
log.Errorf("Get Scheduler ConfigMap err: %v", err)
return err
}
} else {
wantedData, exist, err := unstructured.NestedMap(cmUnstructured.Object, "data")
if err != nil {
log.Errorf("get nested map from unstructured configmap err: ", err)
return err
}
if !exist {
log.Infof("not found data map in unstructured configmap")
return nil
}
for k, v := range wantedData {
s := v.(string)
if gotten.Data[k] != s {
log.Infof("scheduler configmap not the same as expected, update it")
if errUpdate := m.Client.Update(context.TODO(), cmUnstructured); errUpdate != nil {
log.Errorf("update scheduler configmap err: %v", errUpdate)
return errUpdate
}
}
}
}

return nil
Expand Down

0 comments on commit 9476c03

Please sign in to comment.