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

ROX-19735: PR suggestions #1287

Merged

Conversation

ludydoo
Copy link
Collaborator

@ludydoo ludydoo commented Sep 20, 2023

No description provided.

@ludydoo ludydoo temporarily deployed to development September 20, 2023 08:38 — with GitHub Actions Inactive
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 20, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ludydoo
Once this PR has been reviewed and has the lgtm label, please assign porridge for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ludydoo ludydoo temporarily deployed to development September 20, 2023 08:38 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 08:38 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 08:45 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 08:45 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:08 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:08 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:08 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:24 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:24 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:24 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:25 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:25 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:25 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:27 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:27 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:27 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:28 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:28 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:28 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:29 — with GitHub Actions Inactive
Comment on lines +10 to +11
baseURL: https://raw.githubusercontent.com/stackrox/stackrox/{{ .GitRef }}/operator/bundle/manifests/
gitRef: 4.1.1
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do we really need a template here? Why not just specify the url directly

Copy link
Member

Choose a reason for hiding this comment

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

Most of the times it will only be necessary to adjust the GitRef instead of the whole URL. I've used a template in this case because %s seemed not obvious enough if a new engineer not familiar with the config looks at the file.
Example: https://raw.githubusercontent.com/stackrox/stackrox/%s/operator/bundle/manifests/

gitRef: 4.1.1
operators:
- gitRef: 4.1.1
image: "quay.io/rhacs-eng/stackrox-operator:4.1.1"
Copy link
Collaborator Author

@ludydoo ludydoo Sep 20, 2023

Choose a reason for hiding this comment

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

I would favor adding the centralLabelSelector here.

Otherwise the engineers will need to know that the Central label (present in patches below) rhacs.redhat.com/version-selector corresponds to the gitRef that is specified in the operators.

Copy link
Member

@SimonBaeumer SimonBaeumer Sep 21, 2023

Choose a reason for hiding this comment

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

What would you prefer, centralVersionSelector or naming the label?

  operators:
    - gitRef: 4.1.1
      centralVersionSelector: 4.1.1
      image: "quay.io/rhacs-eng/stackrox-operator:4.1.1"

vs naming the label explicitly as a key, it makes it very explicit how the correspond to each other:

  operators:
    - gitRef: 4.1.1
      rhacs.redhat.com/version-selector: 4.1.1
      image: "quay.io/rhacs-eng/stackrox-operator:4.1.1"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps the simplest would be to align with the helm values structure?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems like the current helm template uses labelSelector as a key

Copy link
Member

Choose a reason for hiding this comment

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

What is the simplest for the user? I think this is the most idiomatic rhacs.redhat.com/version-selector: 4.1.1 value.

@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:30 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:30 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:31 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:31 — with GitHub Actions Inactive
@ludydoo ludydoo temporarily deployed to development September 20, 2023 09:31 — with GitHub Actions Inactive
@@ -17,25 +16,12 @@ func parseConfig(content []byte) (OperatorConfigs, error) {
return out, nil
}

// GetConfig returns the rhacs operator configurations
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unused

return field.ErrorList{
field.Forbidden(path, fmt.Sprintf("could not render operator helm charts, got invalid configuration: %s", err.Error())),
}
} else if len(manifests) == 0 {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no operators in list is .. undesirable but not "invalid"

Copy link
Member

Choose a reason for hiding this comment

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

It's both, I've intended to catch templating errors. When an empty config is provided it is valid, when config contains operators it is invalid.

} else if len(configs.OperatorConfigs) > 0&& len(manifests) == 0 {

Copy link
Member

Choose a reason for hiding this comment

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

Done and added tests

return r.applyLabelSelector(remoteCentral, central)
}

func (r *CentralReconciler) applyLabelSelector(remoteCentral *private.ManagedCentral, central *v1alpha1.Central) error {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

label is applied using the gitops configMap

Copy link
Member

Choose a reason for hiding this comment

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

How is the default case handled? Does the default Central add the label to all instances outside of a group?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently not, but we could either

  • Specify a path with instanceIds: ["*"] where the label selector is set
  • Change the default central template.
  • Other?

Copy link
Member

@SimonBaeumer SimonBaeumer left a comment

Choose a reason for hiding this comment

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

Thanks for providing these fixes @ludydoo!

Comment on lines +10 to +11
baseURL: https://raw.githubusercontent.com/stackrox/stackrox/{{ .GitRef }}/operator/bundle/manifests/
gitRef: 4.1.1
Copy link
Member

Choose a reason for hiding this comment

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

Most of the times it will only be necessary to adjust the GitRef instead of the whole URL. I've used a template in this case because %s seemed not obvious enough if a new engineer not familiar with the config looks at the file.
Example: https://raw.githubusercontent.com/stackrox/stackrox/%s/operator/bundle/manifests/

gitRef: 4.1.1
operators:
- gitRef: 4.1.1
image: "quay.io/rhacs-eng/stackrox-operator:4.1.1"
Copy link
Member

@SimonBaeumer SimonBaeumer Sep 21, 2023

Choose a reason for hiding this comment

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

What would you prefer, centralVersionSelector or naming the label?

  operators:
    - gitRef: 4.1.1
      centralVersionSelector: 4.1.1
      image: "quay.io/rhacs-eng/stackrox-operator:4.1.1"

vs naming the label explicitly as a key, it makes it very explicit how the correspond to each other:

  operators:
    - gitRef: 4.1.1
      rhacs.redhat.com/version-selector: 4.1.1
      image: "quay.io/rhacs-eng/stackrox-operator:4.1.1"

return field.ErrorList{
field.Forbidden(path, fmt.Sprintf("could not render operator helm charts, got invalid configuration: %s", err.Error())),
}
} else if len(manifests) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

It's both, I've intended to catch templating errors. When an empty config is provided it is valid, when config contains operators it is invalid.

} else if len(configs.OperatorConfigs) > 0&& len(manifests) == 0 {

return r.applyLabelSelector(remoteCentral, central)
}

func (r *CentralReconciler) applyLabelSelector(remoteCentral *private.ManagedCentral, central *v1alpha1.Central) error {
Copy link
Member

Choose a reason for hiding this comment

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

How is the default case handled? Does the default Central add the label to all instances outside of a group?

@SimonBaeumer SimonBaeumer temporarily deployed to development September 21, 2023 08:23 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development September 21, 2023 08:23 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development September 21, 2023 08:23 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer merged commit 437ce5b into sb/rox-19735-add-operator-to-gitops Sep 21, 2023
@SimonBaeumer SimonBaeumer deleted the lc/rox-19735-suggestions branch September 21, 2023 08:33
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.

2 participants