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) PR for Installation outputs GRPC Service #245

Merged
merged 11 commits into from
Sep 20, 2023

Conversation

troy0820
Copy link
Member

@troy0820 troy0820 commented Aug 9, 2023

What does this change

  • Create the installationoutputs custom resource definition via api/v1
  • Create the intallationoutoutputs deep copy functions
  • Add additional printer columns
  • Add condition on installationoutputs custom resource
  • Add the necessary rbac for installation controller to mess with installationoutputs
  • Add the roles (generated) with the installationoutputs

Above is now merged but leaving for visibility

  • Add the porter grpc client to the installation controller struct (to query the grpc endpoint)
  • Add owner reference and options in for Owns(&v1.InstallationOutput{}, builder.MatchEveryOwner)
  • Hardcoded service to client connection in main.go (TODO: fix this or make sure we don't do this if we can't establish connection)
  • Do not fail if we can't get the outputs from the grpc server
  • Requeue if outputs is deleted and recreate
  • Add annotation on installation resource that outputs were made/created getporter.org/installationoutput: "true"
  • Add porter installation for operator to launch service when the operator installs.
    • This is moving to getporter/deployment but also being made a helm chart.
  • Add test to demonstrate flow
  • Make sure outputs get updated when install updates (deferred until after v1.0.0)
  • Clean up code (get rid of TODOs)
  • Waiting on a bundle for upgrade to test logic

What issue does it fix

Closes #63

Notes for the reviewer

What is struck through is being handled by PR #246 to lessen the load when reviewing.

NAME                      PORTER NAME               PORTER NAMESPACE   PHASE
test-install-1691504789   test-install-1691504789   demo               Succeeded
NAMESPACE   NAME                      PORTER NAME               PORTER NAMESPACE   PHASE       OUTPUT NAMES
demo        test-install-1691504789   test-install-1691504789   demo               Succeeded   outAction,outDelay,outExitStatus,outInsecureValue
apiVersion: v1
items:
- apiVersion: getporter.org/v1
  kind: InstallationOutput
  metadata:
    creationTimestamp: "2023-08-09T18:55:48Z"
    generation: 1
    name: test-install-1691504789
    namespace: demo
    ownerReferences:
    - apiVersion: getporter.org/v1
      kind: Installation
      name: test-install-1691504789-nf9k2
      uid: a7d5ba66-c4e9-4a3c-9241-d6957e46aa72
    resourceVersion: "1119303"
    uid: aee802c4-01e8-418b-8266-628665807fbd
  spec:
    name: test-install-1691504789
    namespace: demo
  status:
    conditions:
    - lastTransitionTime: "2023-08-09T18:55:48Z"
      message: outputs custom resource generated succeeded
      reason: InstallationOutputCreatedSuccess
      status: "True"
      type: InstallationOutputSucceeded
    outputs:
    - name: outAction
      sensitive: false
      type: string
      value: install
    - name: outDelay
      sensitive: false
      type: integer
      value: "3"
    - name: outExitStatus
      sensitive: false
      type: integer
      value: "0"
    - name: outInsecureValue
      sensitive: false
      type: string
      value: default
    phase: Succeeded

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you make any API changes? Update the corresponding API documentation.
    • Yes, added a new type to api/v1 called InstallationOuput. No api documentation change is necessary.

@troy0820 troy0820 mentioned this pull request Aug 9, 2023
3 tasks
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #245 (6515752) into main (85d24a5) will increase coverage by 0.37%.
Report is 1 commits behind head on main.
The diff coverage is 77.19%.

@@            Coverage Diff             @@
##             main     #245      +/-   ##
==========================================
+ Coverage   67.67%   68.04%   +0.37%     
==========================================
  Files          14       14              
  Lines        2147     2241      +94     
==========================================
+ Hits         1453     1525      +72     
- Misses        547      564      +17     
- Partials      147      152       +5     
Flag Coverage Δ
unittests 68.04% <77.19%> (+0.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
controllers/agentconfig_controller.go 58.78% <ø> (ø)
controllers/installation_controller.go 65.81% <77.19%> (+5.59%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@troy0820 troy0820 force-pushed the troy0820/installation-outputs branch from 89cbda4 to 3f381f7 Compare August 10, 2023 15:22
@troy0820 troy0820 added the enhancement New code, ahoy! label Aug 10, 2023
@troy0820 troy0820 force-pushed the troy0820/installation-outputs branch 2 times, most recently from 0aae39a to c175bc3 Compare August 17, 2023 20:09
@troy0820 troy0820 changed the title WIP: Draft PR for installation outputs CR/GRPC Service WIP: Draft PR for Installation outputs GRPC Service Aug 22, 2023
@troy0820 troy0820 force-pushed the troy0820/installation-outputs branch from c175bc3 to 279f1c1 Compare September 6, 2023 22:14
@troy0820 troy0820 force-pushed the troy0820/installation-outputs branch from 279f1c1 to d771ea3 Compare September 13, 2023 14:56

func (r *InstallationReconciler) CreateInstallationOutputsCR(ctx context.Context, install *v1.Installation, in *installationv1.ListInstallationLatestOutputResponse) (*v1.InstallationOutput, error) {
if len(in.Outputs) < 1 {
return nil, fmt.Errorf("no outputs for the installation %s", install.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Instead of error, maybe best to log?
Some installations may not have outputs

Copy link
Member

Choose a reason for hiding this comment

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

Could the installationoutput cr have an owner ref to the installation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Instead of error, maybe best to log?

This only makes the CR if the outputs exist from the previous call.

Some installations may not have outputs

It errors only to requeue in the event that the output length being returned from the grpc server is less than 1 . I agree, I should probably still log. I have to short circuit in the event that the output doesn't exist or it'll make a CR with a blank output.

main.go Outdated
@@ -62,11 +66,19 @@ func main() {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}

// TODO: Set this with credentials on the server side
// TODO: This needs to be set so we don't fail when instantiating client
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this is most important todo, the other ones we can live with

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I was thinking tls and generate key/pair before creating the server, however that is done outside of this PR to manipulate the grpc server. (The GRPC service is a deployment outside of the controller-manager). The client setting up however, I can pass it credentials to interact with this. I can clean up the TODO but need more cycles to do the grpc server credentialing on the server side.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, we should separate this into it's own issue perhaps

@schristoff schristoff changed the title WIP: Draft PR for Installation outputs GRPC Service (feat) PR for Installation outputs GRPC Service Sep 19, 2023
@schristoff schristoff marked this pull request as ready for review September 19, 2023 23:49
@schristoff
Copy link
Member

I'm moving this out of draft :)


// TODO: Set this with credentials on the server side
// TODO: This needs to be set so we don't fail when instantiating client
conn, err := grpc.DialContext(context.Background(), "porter-grpc-service:3001", grpc.WithTransportCredentials(insecure.NewCredentials()))
Copy link
Member Author

Choose a reason for hiding this comment

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

What I can do to not be dependent on the gRPC server being there is to only set this if the service is present.

Basically, don't error if this fails but pass an empty listener and log "no grpc client for installationoutputs" @schristoff

Copy link
Member

Choose a reason for hiding this comment

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

Sgtm

@troy0820 troy0820 force-pushed the troy0820/installation-outputs branch from 27bee7a to 6515752 Compare September 20, 2023 16:40
Copy link
Member

@schristoff schristoff left a comment

Choose a reason for hiding this comment

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

Looking through I see there's already an ownerref for instllation outputs in the installation_controller.go - so we should be good to go.

@troy0820 troy0820 merged commit 6ae9dae into getporter:main Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New code, ahoy!
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Expose bundle outputs inside a cluster
2 participants