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

feat: pass reconciled revision id in service update components #246

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/open-policy-agent/gatekeeper/v3 v3.15.1
github.com/orcaman/concurrent-map/v2 v2.0.1
github.com/pkg/errors v0.9.1
github.com/pluralsh/console/go/client v1.0.0
github.com/pluralsh/console/go/client v1.4.0
github.com/pluralsh/controller-reconcile-helper v0.0.4
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34
github.com/pluralsh/polly v0.1.10
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rK
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pluralsh/console/go/client v1.0.0 h1:jsKmDjZFNEYMg6xgOeIjRyP/2oJXYOQqjUGeA6i0v84=
github.com/pluralsh/console/go/client v1.0.0/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k=
github.com/pluralsh/console/go/client v1.4.0 h1:Mr/gyU20jrLZZ9diEznv3aU/CJ5wk13qLes/4O9unwM=
github.com/pluralsh/console/go/client v1.4.0/go.mod h1:lpoWASYsM9keNePS3dpFiEisUHEfObIVlSL3tzpKn8k=
github.com/pluralsh/controller-reconcile-helper v0.0.4 h1:1o+7qYSyoeqKFjx+WgQTxDz4Q2VMpzprJIIKShxqG0E=
github.com/pluralsh/controller-reconcile-helper v0.0.4/go.mod h1:AfY0gtteD6veBjmB6jiRx/aR4yevEf6K0M13/pGan/s=
github.com/pluralsh/gophoenix v0.1.3-0.20231201014135-dff1b4309e34 h1:ab2PN+6if/Aq3/sJM0AVdy1SYuMAnq4g20VaKhTm/Bw=
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type Client interface {
GetClusterBackup(clusterID, namespace, name string) (*console.ClusterBackupFragment, error)
GetServices(after *string, first *int64) (*console.PagedClusterServices, error)
GetService(id string) (*console.GetServiceDeploymentForAgent_ServiceDeployment, error)
UpdateComponents(id string, components []*console.ComponentAttributes, errs []*console.ServiceErrorAttributes) error
UpdateComponents(id, revisionID string, sha *string, components []*console.ComponentAttributes, errs []*console.ServiceErrorAttributes) error
AddServiceErrors(id string, errs []*console.ServiceErrorAttributes) error
ParsePipelineGateCR(pgFragment *console.PipelineGateFragment, operatorNamespace string) (*v1alpha1.PipelineGate, error)
GateExists(id string) bool
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func (c *client) GetService(id string) (*console.GetServiceDeploymentForAgent_Se
return resp.ServiceDeployment, nil
}

func (c *client) UpdateComponents(id string, components []*console.ComponentAttributes, errs []*console.ServiceErrorAttributes) error {
_, err := c.consoleClient.UpdateServiceComponents(c.ctx, id, components, errs)
func (c *client) UpdateComponents(id, revisionID string, sha *string, components []*console.ComponentAttributes, errs []*console.ServiceErrorAttributes) error {
_, err := c.consoleClient.UpdateServiceComponents(c.ctx, id, components, revisionID, sha, errs)
return err
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/service/reconciler_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *ServiceReconciler) UpdatePruneStatus(ctx context.Context, svc *console.

components := statusCollector.componentsAttributes(vcache)
// delete service when components len == 0 (no new statuses, inventory file is empty, all deleted)
if err := s.UpdateStatus(svc.ID, components, errorAttributes("sync", err)); err != nil {
if err := s.UpdateStatus(svc.ID, svc.Revision.ID, svc.Sha, components, errorAttributes("sync", err)); err != nil {
logger.Error(err, "Failed to update service status, ignoring for now")
}

Expand Down Expand Up @@ -137,7 +137,7 @@ func (s *ServiceReconciler) UpdateApplyStatus(
return err
}
components := statusCollector.componentsAttributes(vcache)
if err := s.UpdateStatus(svc.ID, components, errorAttributes("sync", err)); err != nil {
if err := s.UpdateStatus(svc.ID, svc.Revision.ID, svc.Sha, components, errorAttributes("sync", err)); err != nil {
logger.Error(err, "Failed to update service status, ignoring for now")
}

Expand Down Expand Up @@ -216,13 +216,13 @@ func errorAttributes(source string, err error) *console.ServiceErrorAttributes {
}
}

func (s *ServiceReconciler) UpdateStatus(id string, components []*console.ComponentAttributes, err *console.ServiceErrorAttributes) error {
func (s *ServiceReconciler) UpdateStatus(id, revisionID string, sha *string, components []*console.ComponentAttributes, err *console.ServiceErrorAttributes) error {
errs := make([]*console.ServiceErrorAttributes, 0)
if err != nil {
errs = append(errs, err)
}

return s.ConsoleClient.UpdateComponents(id, components, errs)
return s.ConsoleClient.UpdateComponents(id, revisionID, sha, components, errs)
}

func (s *ServiceReconciler) AddErrors(id string, err *console.ServiceErrorAttributes) error {
Expand Down
Loading
Loading