Skip to content

Commit

Permalink
update image limit (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaByte875 authored Aug 31, 2021
1 parent 0bc10c5 commit dc16714
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/controller/component/graphd_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ func (c *graphdCluster) syncGraphdWorkload(nc *v1alpha1.NebulaCluster) error {
return err
}

if nc.Status.Graphd.Version != "" {
oldImage := nc.Spec.Graphd.Image + ":" + nc.Status.Graphd.Version
if err := extender.SetContainerImage(
newWorkload,
nc.GraphdComponent().Type().String(),
oldImage); err != nil {
return err
}
}

if err := extender.SetTemplateAnnotations(
newWorkload,
map[string]string{annotation.AnnPodConfigMapHash: cmHash}); err != nil {
Expand Down
10 changes: 10 additions & 0 deletions pkg/controller/component/metad_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ func (c *metadCluster) syncMetadWorkload(nc *v1alpha1.NebulaCluster) error {
return err
}

if nc.Status.Metad.Version != "" {
oldImage := nc.Spec.Metad.Image + ":" + nc.Status.Metad.Version
if err := extender.SetContainerImage(
newWorkload,
nc.MetadComponent().Type().String(),
oldImage); err != nil {
return err
}
}

if err := extender.SetTemplateAnnotations(
newWorkload,
map[string]string{annotation.AnnPodConfigMapHash: cmHash}); err != nil {
Expand Down
10 changes: 10 additions & 0 deletions pkg/controller/component/storaged_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ func (c *storagedCluster) syncStoragedWorkload(nc *v1alpha1.NebulaCluster) error
return err
}

if nc.Status.Storaged.Version != "" {
oldImage := nc.Spec.Storaged.Image + ":" + nc.Status.Storaged.Version
if err := extender.SetContainerImage(
newWorkload,
nc.StoragedComponent().Type().String(),
oldImage); err != nil {
return err
}
}

if err := extender.SetTemplateAnnotations(
newWorkload,
map[string]string{annotation.AnnPodConfigMapHash: cmHash}); err != nil {
Expand Down
17 changes: 17 additions & 0 deletions pkg/controller/nebulacluster/nebula_cluster_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (c *defaultNebulaClusterControl) UpdateNebulaCluster(nc *v1alpha1.NebulaClu
var errs []error
oldStatus := nc.Status.DeepCopy()

c.resetImage(nc)
if err := c.nebulaClient.UpdateNebulaCluster(nc.DeepCopy()); err != nil {
errs = append(errs, err)
}

if err := c.updateNebulaCluster(nc); err != nil {
errs = append(errs, err)
}
Expand Down Expand Up @@ -112,6 +117,18 @@ func (c *defaultNebulaClusterControl) updateNebulaCluster(nc *v1alpha1.NebulaClu
return nil
}

func (c *defaultNebulaClusterControl) resetImage(nc *v1alpha1.NebulaCluster) {
if nc.Status.Graphd.Version != "" {
nc.Spec.Graphd.Version = nc.Status.Graphd.Version
}
if nc.Status.Metad.Version != "" {
nc.Spec.Metad.Version = nc.Status.Metad.Version
}
if nc.Status.Storaged.Version != "" {
nc.Spec.Storaged.Version = nc.Status.Storaged.Version
}
}

type FakeClusterControl struct {
err error
}
Expand Down

0 comments on commit dc16714

Please sign in to comment.