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

Add a cloud credentials checker asset #1100

Merged
merged 2 commits into from
Jan 26, 2019

Conversation

rajatchopra
Copy link
Contributor

A cloud creds checker asset just checks upon the credentials. The 'cluster' target
can then depend on it and, thus, cloud creds will be checked again before the
cluster is finally created.
The reason for a double check is that a cluster can be created through an
imported install-config and the credentials may be missing then.
If the cluster were to be created in one go (i.e. no install-config generation
as a sub-step), then the asset creation ensures that they are checked upon only once.
Or rather asked about the creds only once.

Solves: https://jira.coreos.com/projects/CORS/issues/CORS-949

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 18, 2019
@rajatchopra
Copy link
Contributor Author

@staebler PTAL. Looks like a lot of code churn but really not. Important part is that cluster asset now includes this new 'platformCredsCheck' as a dependency.

@rajatchopra rajatchopra force-pushed the aws_creds branch 3 times, most recently from 69ef03d to a21fa57 Compare January 22, 2019 18:20
Copy link
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

This is not going to work well when the user brings their own install-config.yaml. In that case, the installer will prompt the user for the platform even though the platform has been specified already in the install-config.yaml.

Copy link
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

Don't use underscores in the names of the go files. In other words, platform_creds_check.go should be platformcredscheck.go.

pkg/asset/cluster/cluster.go Show resolved Hide resolved
Copy link
Contributor

@staebler staebler left a comment

Choose a reason for hiding this comment

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

There are other places where the AWS creds are used. Those places need to use the creds checker, too. For example, https://github.com/openshift/installer/blob/master/pkg/asset/machines/aws/zones.go.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 23, 2019
@rajatchopra
Copy link
Contributor Author

@staebler credchecker now depends on installconfig, thanks for pointing out the loophole.

There are other places where the AWS creds are used. Those places need to use the creds checker, too. For example, https://github.com/openshift/installer/blob/master/pkg/asset/machines/aws/zones.go.

But it is not reachable directly via a target without going through 'create cluster'. Or so far as I could tell.

Copy link
Contributor

@flaper87 flaper87 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 this patch. I've dropped a comment on the openstack check.

Please add me or @tomassedovic on patches that have an impact on OpenStack. 😃

Thanks

pkg/asset/installconfig/platformcredscheck.go Show resolved Hide resolved
@staebler
Copy link
Contributor

@staebler credchecker now depends on installconfig, thanks for pointing out the loophole.

There are other places where the AWS creds are used. Those places need to use the creds checker, too. For example, https://github.com/openshift/installer/blob/master/pkg/asset/machines/aws/zones.go.

But it is not reachable directly via a target without going through 'create cluster'. Or so far as I could tell.

@rajatchopra In the particular case of the AvailabilityZones function, that is used by the Master and Worker assets, which are parents of the Openshift Manifest asset, which is targeted by the manifests target. But, even if it were only assets targeted by the cluster target that needed the creds checker, the individual assets need the dependency not the target.

@wking
Copy link
Member

wking commented Jan 25, 2019

I agree with @staebler that ec2Client should be updated to use GetSession (it would still have to insert the region locally). That way we don't have to worry about targets and access paths to that code, and we can also benefit from centralizing the NewSessionWithOptions etc. in a single helper around the vendored AWS code.

@wking wking added this to the 0.11.0 milestone Jan 25, 2019
A cloud creds checker asset just checks upon the credentials. The 'cluster' target
can then depend on it and, thus, cloud creds will be checked again before the
cluster is finally created.
The reason for a double check is that a cluster can be created through an
imported install-config and the credentials may be missing then.
If the cluster were to be created in one go (i.e. no install-config generation
as a sub-step), then the asset creation graph ensures that they are checked upon only once.
(Or rather asked about the creds only once.)
@rajatchopra
Copy link
Contributor Author

I agree with @staebler that ec2Client should be updated to use GetSession (it would still have to insert the region locally). That way we don't have to worry about targets and access paths to that code, and we can also benefit from centralizing the NewSessionWithOptions etc. in a single helper around the vendored AWS code.

I will get the centralizing the GetSession in another PR (the minor difference right now in the two usages is that one is generic and the other is specific to the region).
I have updated the machines/{master,worker} assets meanwhile to depend upon CredsCheck, which is what @staebler was asking as a must I think.

@wking
Copy link
Member

wking commented Jan 25, 2019

I will get the centralizing the GetSession in another PR (the minor difference right now in the two usages is that one is generic and the other is specific to the region).

Adjusting the region will look like this, but with the EC2 client as the wrapper. So:

func ec2Client(region string) (*ec2.EC2, error) {
  ssn, err := installeraws.GetSession()
  if err != nil {
    return nil, err
  }

  client := ec2.New(ssn, aws.NewConfig().WithRegion(region))
  return client, nil
}

I'm ok punting that if you like, but I think it's about as complicated as your current asset-dependency stopgap ;).

Reuse removes code duplication as well as ensuring there is one central
way of creating the sessions.
@rajatchopra
Copy link
Contributor Author

I'm ok punting that if you like, but I think it's about as complicated as your current asset-dependency stopgap ;).

You made it look easy :). Done as a separate commit in this PR.
The asset-dependency is not a stop-gap and this change really has no overlap with it though, am I missing some hint?

@staebler
Copy link
Contributor

I'm ok punting that if you like, but I think it's about as complicated as your current asset-dependency stopgap ;).

You made it look easy :). Done as a separate commit in this PR.
The asset-dependency is not a stop-gap and this change really has no overlap with it though, am I missing some hint?

@rajatchopra With the consolidation, I would like at some point (not necessarily for this PR) to go through the Credentials Checker Asset to get the session, making the reliance on the checker explicit.

@wking
Copy link
Member

wking commented Jan 25, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 25, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rajatchopra, wking

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

The pull request process is described 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

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@rajatchopra
Copy link
Contributor Author

/retest

1 similar comment
@rajatchopra
Copy link
Contributor Author

/retest

@wking
Copy link
Member

wking commented Jan 26, 2019

e2e-aws:

Flaky tests:

[sig-storage] Dynamic Provisioning DynamicProvisioner should provision storage with different parameters [Suite:openshift/conformance/parallel] [Suite:k8s]

Failing tests:

[sig-storage] Volume limits should verify that all nodes have volume limits [Suite:openshift/conformance/parallel] [Suite:k8s]

The volume failure should be ignored now, but looks like this test [started after that ignore landed][3]. Hmm...

/retest

@wking
Copy link
Member

wking commented Jan 26, 2019

/retest

Pick up openshift/origin#21867.

@openshift-merge-robot openshift-merge-robot merged commit 7b64f2a into openshift:master Jan 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants