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

Don't fail when the cluster/users that a context refers to doesn't exist in ~/.kube/config #299

Open
jroper opened this issue Nov 4, 2019 · 1 comment

Comments

@jroper
Copy link
Contributor

jroper commented Nov 4, 2019

You can remove a cluster from your kubectl configuration by running kubectl config delete-cluster, and this will succeed even if a context referring to that cluster exists. kubectl will then continue to work normally, as long as you don't try to use that context, only then will it fail.

Skuber in comparison fails to parse the configuration file, even if you don't use that context. I think Skuber should, like kubectl, be more tolerant than this, and only fail when a user attempts to use that context. The simplest thing would probably be for it to just ignore contexts whose clusters or users don't exist, but ideally, if you tried to use the context, it would give a more meaningful error message, roughly like cluster "foo" not found for context "bar".

@jroper
Copy link
Contributor Author

jroper commented Nov 4, 2019

Also, this is the error that you currently get:

[info] java.util.NoSuchElementException: None.get
[info] mat scala.None$.get(Option.scala:529) 0s
[info] 	at scala.None$.get(Option.scala:527)
[info] 	at skuber.api.Configuration$.$anonfun$parseKubeconfigStream$11(Configuration.scala:212)
[info] 	at scala.Option.map(Option.scala:230)
[info] 	at skuber.api.Configuration$.toK8SContext$1(Configuration.scala:211)
[info] 	at skuber.api.Configuration$.$anonfun$parseKubeconfigStream$18(Configuration.scala:221)
[info] 	at skuber.api.Configuration$.$anonfun$parseKubeconfigStream$6(Configuration.scala:153)
[info] 	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:238)
[info] 	at scala.collection.Iterator.foreach(Iterator.scala:941)
[info] 	at scala.collection.Iterator.foreach$(Iterator.scala:941)
[info] 	at scala.collection.AbstractIterator.foreach(Iterator.scala:1429)
[info] 	at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[info] 	at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[info] 	at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[info] 	at scala.collection.TraversableLike.map(TraversableLike.scala:238)
[info] 	at scala.collection.TraversableLike.map$(TraversableLike.scala:231)
[info] 	at scala.collection.AbstractTraversable.map(Traversable.scala:108)
[info] 	at skuber.api.Configuration$.topLevelYamlToK8SConfigMap$1(Configuration.scala:153)
[info] 	at skuber.api.Configuration$.$anonfun$parseKubeconfigStream$1(Configuration.scala:221)
[info] 	at scala.util.Try$.apply(Try.scala:213)
[info] 	at skuber.api.Configuration$.parseKubeconfigStream(Configuration.scala:102)
[info] 	at skuber.api.Configuration$.$anonfun$parseKubeconfigFile$2(Configuration.scala:93)
[info] 	at scala.util.Success.flatMap(Try.scala:251)
[info] 	at skuber.api.Configuration$.parseKubeconfigFile(Configuration.scala:92)

Which doesn't tell you which cluster is missing.

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

No branches or pull requests

1 participant